-
Notifications
You must be signed in to change notification settings - Fork 25
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
meta: update packages #94
Conversation
export const Markdown: FC<MarkdownProps> = ({ text, isNonSelectable }) => { | ||
if (!text) return null | ||
|
||
const innerHTML = { __html: md.render(text) } |
Check warning
Code scanning / CodeQL
Unsafe HTML constructed from library input Medium
library input
cross-site scripting
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix AI about 1 month ago
To fix the problem, we need to ensure that the text
input is sanitized before it is used to construct HTML content. This can be achieved by using a library that sanitizes HTML, such as dompurify
. This will help prevent XSS attacks by removing any potentially harmful scripts from the input.
- Install the
dompurify
library. - Import
dompurify
in theMarkdown.tsx
file. - Use
dompurify
to sanitize thetext
input before passing it tomd.render
.
-
Copy modified line R6 -
Copy modified lines R11-R12
@@ -5,2 +5,3 @@ | ||
import type { MarkdownProps } from "./Markdown.types" | ||
import DOMPurify from 'dompurify'; | ||
|
||
@@ -9,3 +10,4 @@ | ||
|
||
const innerHTML = { __html: md.render(text) } | ||
const sanitizedText = DOMPurify.sanitize(text); | ||
const innerHTML = { __html: md.render(sanitizedText) } | ||
const markdownClasses: string = getClasses(styles.markdown, { |
-
Copy modified lines R40-R41
@@ -39,3 +39,4 @@ | ||
"react-dom": "^19.0.0", | ||
"react-plock": "^3.4.0" | ||
"react-plock": "^3.4.0", | ||
"dompurify": "^3.2.3" | ||
}, |
Package | Version | Security advisories |
dompurify (npm) | 3.2.3 | None |
No description provided.