Browse Source

fix(html-parser): sanitize unclosed tags in markdown rendering (#14309)

tags/1.0.0
Chuckie Li 8 months ago
parent
commit
d5711589cd
No account linked to committer's email address
1 changed files with 5 additions and 0 deletions
  1. 5
    0
      web/app/components/base/markdown.tsx

+ 5
- 0
web/app/components/base/markdown.tsx View File

@@ -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)
}

Loading…
Cancel
Save