From 7ba11be42b0b0fc1eaedf79753311684d3a6ef9a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=A1=97=E8=A7=92=E5=B0=8F=E6=9E=97?= <1013335014@qq.com> Date: Fri, 30 Aug 2024 14:01:59 +0800 Subject: [PATCH] =?UTF-8?q?Fix=EF=BC=9A=E4=BF=AE=E5=A4=8D=E5=85=AC?= =?UTF-8?q?=E5=BC=8F=E4=B8=AD=E5=AD=98=E5=9C=A8<>=E7=AC=A6=E5=8F=B7?= =?UTF-8?q?=E6=97=B6=E5=AF=BC=E5=87=BAsvg=E6=8A=A5=E9=94=99=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- simple-mind-map/src/plugins/Formula.js | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/simple-mind-map/src/plugins/Formula.js b/simple-mind-map/src/plugins/Formula.js index b28926a8..8ac2da8c 100644 --- a/simple-mind-map/src/plugins/Formula.js +++ b/simple-mind-map/src/plugins/Formula.js @@ -1,6 +1,6 @@ import katex from 'katex' import Quill from 'quill' -import { getChromeVersion } from '../utils/index' +import { getChromeVersion, htmlEscape } from '../utils/index' import { getBaseStyleText, getFontStyleText } from './FormulaStyle' // 数学公式支持插件 @@ -58,7 +58,7 @@ class Formula { let node = super.create(value) if (typeof value === 'string') { katex.render(value, node, self.config) - node.setAttribute('data-value', value) + node.setAttribute('data-value', htmlEscape(value)) } return node } @@ -110,11 +110,7 @@ class Formula { for (const el of els) nodeText = nodeText.replace( el.outerHTML, - `\$${el - .getAttribute('data-value') - .replaceAll('&', '&') - .replaceAll('<', '<') - .replaceAll('>', '>')}\$` + `\$${htmlEscape(el.getAttribute('data-value'))}\$` ) } return nodeText