From 8f09acb06d3eacc62121aedc8f50153dcf321fe7 Mon Sep 17 00:00:00 2001 From: Libin YANG Date: Mon, 6 Jan 2025 09:28:52 +0800 Subject: [PATCH] fix: escape html (#506) --- src/utils/renderer.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/utils/renderer.ts b/src/utils/renderer.ts index 75fa8d7..23c9622 100644 --- a/src/utils/renderer.ts +++ b/src/utils/renderer.ts @@ -40,6 +40,16 @@ function buildTheme({ theme: _theme, fonts, size, isUseIndent }: IOpts): ThemeSt } as ThemeStyles } +function escapeHtml(text: string): string { + return text + .replace(/&/g, `&`) // 转义 & + .replace(//g, `>`) // 转义 > + .replace(/"/g, `"`) // 转义 " + .replace(/'/g, `'`) // 转义 ' + .replace(/`/g, ```) // 转义 ` +} + function buildAddition(): string { return `