Open-source LLM knowledge platform: turn raw documents into a queryable RAG, an autonomous reasoning agent, and a self-maintaining Wiki.
Go agentagenticaichatbotdsh-pluginembeddingsevaluationgenerative-aigolangknowledge-basellmmulti-tenantollamaopenaiquestion-answeringragrerankingsemantic-searchvector-searchwiki
feat(document-preview): enhance security by sanitizing HTML and Markdown content
wizardchenfb714ea8836e
diff --git a/frontend/src/components/document-preview.vue b/frontend/src/components/document-preview.vueindex 4f83351f3..310c04276 100644--- a/frontend/src/components/document-preview.vue+++ b/frontend/src/components/document-preview.vue@@ -6,6 +6,7 @@ import { MessagePlugin } from 'tdesign-vue-next';import hljs from 'highlight.js';import 'highlight.js/styles/github.css';import { useI18n } from 'vue-i18n';+import { sanitizeHTML, safeMarkdownToHTML } from '@/utils/security';const VueOfficePptx = defineAsyncComponent(() => import('@vue-office/pptx'));@@ -174,7 +175,7 @@ async function renderExcel(blob: Blob, fileType?: string) {html += sheetHtml;html += `</div>`;});- excelHtml.value = html;+ excelHtml.value = sanitizeHTML(html);}async function renderText(blob: Blob, fileType: string) {@@ -223,7 +224,9 @@ async function renderMarkdown(blob: Blob) {return `<pre><code class="hljs">${highlighted}</code></pre>`;};marked.use({ renderer });- markdownHtml.value = marked.parse(text);+ const safeText = safeMarkdownToHTML(text);+ const rawHtml = marked.parse(safeText);+ markdownHtml.value = sanitizeHTML(rawHtml);}function onImageLoad(e: Event) {diff --git a/frontend/src/views/chat/components/botmsg.vue b/frontend/src/views/chat/components/botmsg.vueindex 059eea8ab..993ecf408 100644--- a/frontend/src/views/chat/components/botmsg.vue+++ b/frontend/src/views/chat/components/botmsg.vue@@ -189,10 +189,6 @@ const renderToken = (token) => {}};-const myMarkdown = (res) => {- return marked.parse(res, { renderer })-}-// 获取实际内容const getActualContent = () => {return (props.content || props.session?.content || '').trim();