Skip to content

armgit / dify

Public Imported from GitHub
0

Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.

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

Chuckie Lid5711589cde6
diff --git a/web/app/components/base/markdown.tsx b/web/app/components/base/markdown.tsx
index 8094739cc3d..1a4358c8bcf 100644
--- a/web/app/components/base/markdown.tsx
+++ b/web/app/components/base/markdown.tsx
@@ -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)
}