-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
minor changes and feat: create Post #15
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
> | ||
{imgPreview ? ( | ||
<img | ||
src={imgPreview} |
Check warning
Code scanning / CodeQL
DOM text reinterpreted as HTML Medium
DOM text
This autofix suggestion was applied.
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix AI about 1 month ago
To fix the problem, we need to ensure that the imgPreview
value is safe before using it as the src
attribute of an img
element. One way to do this is to validate the file type and ensure it is an image before creating the object URL. Additionally, we can use a library like DOMPurify
to sanitize the URL if necessary.
- Validate the file type to ensure it is an image.
- Create the object URL only if the file is a valid image.
- Use the validated and sanitized URL as the
src
attribute of theimg
element.
-
Copy modified lines R25-R31
@@ -24,4 +24,9 @@ | ||
if (files && files.length > 0) { | ||
setImage(files[0]); | ||
setImgPreview(URL.createObjectURL(files[0])); | ||
const file = files[0]; | ||
if (file.type.startsWith("image/")) { | ||
setImage(file); | ||
setImgPreview(URL.createObjectURL(file)); | ||
} else { | ||
toast.error("Please select a valid image file."); | ||
} | ||
} |
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
No description provided.