-
Notifications
You must be signed in to change notification settings - Fork 0
Potential fix for code scanning alert no. 93: DOM text reinterpreted as HTML #160
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,6 +2,7 @@ | |
| // Copyright (c) 2026 GitStore contributors | ||
|
|
||
| import React, { useState } from 'react'; | ||
| import DOMPurify from 'dompurify'; | ||
|
|
||
| interface MarkdownEditorProps { | ||
| value: string; | ||
|
|
@@ -95,6 +96,8 @@ export function MarkdownEditor({ | |
| return html; | ||
| }; | ||
|
|
||
| const sanitizedPreviewHtml = DOMPurify.sanitize(renderMarkdown(value)); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Computing Useful? React with 👍 / 👎. |
||
|
|
||
| return ( | ||
| <div style={styles.container}> | ||
| {/* Toolbar */} | ||
|
|
@@ -220,7 +223,7 @@ export function MarkdownEditor({ | |
| ) : ( | ||
| <div | ||
| style={styles.preview} | ||
| dangerouslySetInnerHTML={{ __html: renderMarkdown(value) }} | ||
| dangerouslySetInnerHTML={{ __html: sanitizedPreviewHtml }} | ||
| /> | ||
| )} | ||
| </div> | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change introduces
import DOMPurify from 'dompurify', butgitstore-admin/package.jsonandpackage-lock.jsondo not includedompurify, so a clean install/build of the admin app cannot resolve this module and will fail at compile/bundle time. Because CI and new environments rely on declared dependencies, this breaks the feature universally until the dependency is added and locked.Useful? React with 👍 / 👎.