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

pull/14361/head
Chuckie Li 11 months ago committed by GitHub
parent 375a359c97
commit d5711589cd
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

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