diff --git a/jeecgboot-vue3/src/utils/htmlSanitizer.ts b/jeecgboot-vue3/src/utils/htmlSanitizer.ts index f120bc7d3..2b346b14d 100644 --- a/jeecgboot-vue3/src/utils/htmlSanitizer.ts +++ b/jeecgboot-vue3/src/utils/htmlSanitizer.ts @@ -117,6 +117,20 @@ export function sanitizeRichText(value: unknown): string { return xss(normalizeHtml(value), richTextOptions); } +/** + * 转义 HTML 特殊字符,用于把纯文本安全地拼进 v-html + * @author scott + * @since 2026-10-31 【GHSA-867f-2922-wj26】Online 表单详情多行文本存储型 XSS + */ +export function escapeHtml(value: unknown): string { + return normalizeHtml(value) + .replace(/&/g, '&') + .replace(//g, '>') + .replace(/"/g, '"') + .replace(/'/g, '''); +} + /** 净化评论预览和评论列表,只允许换行及系统生成的 emoji 标签。 */ export function sanitizeCommentHtml(value: unknown): string { //console.log("xss filter value:", value); diff --git a/jeecgboot-vue3/src/views/super/online/cgform/extend/form/DetailForm.vue b/jeecgboot-vue3/src/views/super/online/cgform/extend/form/DetailForm.vue index 9db4e1bea..2776a0f2a 100644 --- a/jeecgboot-vue3/src/views/super/online/cgform/extend/form/DetailForm.vue +++ b/jeecgboot-vue3/src/views/super/online/cgform/extend/form/DetailForm.vue @@ -8,7 +8,9 @@