-
Notifications
You must be signed in to change notification settings - Fork 18
updated UI #126
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
base: main
Are you sure you want to change the base?
updated UI #126
Conversation
✅ Deploy Preview for alloradocs ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Signed-off-by: AJ Mannan <amannan@usc.edu>
Signed-off-by: AJ Mannan <amannan@usc.edu>
| return ( | ||
| <div | ||
| className="markdown-content" | ||
| dangerouslySetInnerHTML={{ __html: renderMarkdown(content) }} |
Check warning
Code scanning / CodeQL
DOM text reinterpreted as HTML Medium
DOM text
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 8 months ago
To fix the issue, the input to renderMarkdown must be sanitized to remove any potentially malicious content before it is processed and injected into the DOM. This can be achieved by using a library like DOMPurify to sanitize the HTML output generated by renderMarkdown.
Steps to implement the fix:
- Install the
dompurifylibrary to sanitize HTML content. - Import
DOMPurifyinto the file. - Use
DOMPurify.sanitizeto clean the HTML output fromrenderMarkdownbefore passing it todangerouslySetInnerHTML.
-
Copy modified line R2 -
Copy modified lines R36-R37 -
Copy modified line R41
| @@ -1,2 +1,3 @@ | ||
| import React, { useState, useRef, useEffect } from "react"; | ||
| import DOMPurify from "dompurify"; | ||
|
|
||
| @@ -34,2 +35,4 @@ | ||
|
|
||
| const sanitizedHtml = DOMPurify.sanitize(renderMarkdown(content)); | ||
|
|
||
| return ( | ||
| @@ -37,3 +40,3 @@ | ||
| className="markdown-content" | ||
| dangerouslySetInnerHTML={{ __html: renderMarkdown(content) }} | ||
| dangerouslySetInnerHTML={{ __html: sanitizedHtml }} | ||
| /> |
-
Copy modified lines R9-R10
| @@ -8,3 +8,4 @@ | ||
| "react-dom": "^18.3.1", | ||
| "react-katex": "^3.0.1" | ||
| "react-katex": "^3.0.1", | ||
| "dompurify": "^3.2.6" | ||
| }, |
| Package | Version | Security advisories |
| dompurify (npm) | 3.2.6 | None |
Signed-off-by: AJ Mannan <amannan@usc.edu>
Signed-off-by: AJ Mannan <amannan@usc.edu>
Signed-off-by: AJ Mannan <amannan@usc.edu>
No description provided.