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: fix markdown escape issue (#30299)

wangxiaoleibf76f1065365
diff --git a/web/app/components/base/chat/chat/answer/basic-content.tsx b/web/app/components/base/chat/chat/answer/basic-content.tsx
index ed8f83d6a96..cda2dd6ffb8 100644
--- a/web/app/components/base/chat/chat/answer/basic-content.tsx
+++ b/web/app/components/base/chat/chat/answer/basic-content.tsx
@@ -18,12 +18,19 @@ const BasicContent: FC<BasicContentProps> = ({
if (annotation?.logAnnotation)
return <Markdown content={annotation?.logAnnotation.content || ''} />
+ // Preserve Windows UNC paths and similar backslash-heavy strings by
+ // wrapping them in inline code so Markdown renders backslashes verbatim.
+ let displayContent = content
+ if (typeof content === 'string' && /^\\\\\S.*/.test(content) && !/^`.*`$/.test(content)) {
+ displayContent = `\`${content}\``
+ }
+
return (
<Markdown
className={cn(
item.isError && '!text-[#F04438]',
)}
- content={content}
+ content={displayContent}
/>
)
}
diff --git a/web/app/components/base/chat/chat/answer/index.tsx b/web/app/components/base/chat/chat/answer/index.tsx
index 04b884388e7..7420b84ede7 100644
--- a/web/app/components/base/chat/chat/answer/index.tsx
+++ b/web/app/components/base/chat/chat/answer/index.tsx
@@ -111,7 +111,7 @@ const Answer: FC<AnswerProps> = ({
}
}, [switchSibling, item.prevSibling, item.nextSibling])
- const contentIsEmpty = content.trim() === ''
+ const contentIsEmpty = typeof content === 'string' && content.trim() === ''
return (
<div className="mb-2 flex last:mb-0">