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.

Merge commit from fork

veganmosfet378a1d7d08bd
diff --git a/web/app/components/base/markdown-blocks/code-block.tsx b/web/app/components/base/markdown-blocks/code-block.tsx
index b9b30743519..744a578ff6d 100644
--- a/web/app/components/base/markdown-blocks/code-block.tsx
+++ b/web/app/components/base/markdown-blocks/code-block.tsx
@@ -204,23 +204,10 @@ const CodeBlock: any = memo(({ inline, className, children = '', ...props }: any
}
}
catch {
- try {
- // eslint-disable-next-line no-new-func
- const result = new Function(`return ${trimmedContent}`)()
- if (typeof result === 'object' && result !== null) {
- setFinalChartOption(result)
- setChartState('success')
- processedRef.current = true
- return
- }
- }
- catch {
- // If we have a complete JSON structure but it doesn't parse,
- // it's likely an error rather than incomplete data
- setChartState('error')
- processedRef.current = true
- return
- }
+ // Avoid executing arbitrary code; require valid JSON for chart options.
+ setChartState('error')
+ processedRef.current = true
+ return
}
}
@@ -249,19 +236,9 @@ const CodeBlock: any = memo(({ inline, className, children = '', ...props }: any
}
}
catch {
- try {
- // eslint-disable-next-line no-new-func
- const result = new Function(`return ${trimmedContent}`)()
- if (typeof result === 'object' && result !== null) {
- setFinalChartOption(result)
- isValidOption = true
- }
- }
- catch {
- // Both parsing methods failed, but content looks complete
- setChartState('error')
- processedRef.current = true
- }
+ // Only accept JSON to avoid executing arbitrary code from the message.
+ setChartState('error')
+ processedRef.current = true
}
if (isValidOption) {