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

This commit is contained in:
Chuckie Li 2025-02-26 09:31:29 +08:00 committed by GitHub
parent 375a359c97
commit d5711589cd
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

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