Skip to content

Commit

Permalink
fix(html-parser): sanitize unclosed tags in markdown rendering (#14309)
Browse files Browse the repository at this point in the history
  • Loading branch information
WustLCQ authored Feb 26, 2025
1 parent 375a359 commit d571158
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions web/app/components/base/markdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,11 @@ export function Markdown(props: { content: string; className?: string }) {
if (node.type === 'element' && node.properties?.ref)
delete node.properties.ref

if (node.type === 'element' && !/^[a-z][a-z0-9]*$/i.test(node.tagName)) {
node.type = 'text'
node.value = `<${node.tagName}`
}

if (node.children)
node.children.forEach(iterate)
}
Expand Down

0 comments on commit d571158

Please sign in to comment.