From fe0fa8b598cb329b6aaed806d039d6e95770bb17 Mon Sep 17 00:00:00 2001 From: greatzp Date: Tue, 5 Mar 2024 22:59:00 +0800 Subject: [PATCH] =?UTF-8?q?feat(md):=20xss=E8=BF=87=E6=BB=A4=E8=A7=84?= =?UTF-8?q?=E5=88=99=E5=A2=9E=E5=8A=A0=E5=8F=AF=E6=8E=92=E9=99=A4=E6=A0=87?= =?UTF-8?q?=E7=AD=BE=E6=B8=B2=E6=9F=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../devui/editor-md/src/composables/md-render-service.ts | 6 +++++- packages/devui-vue/devui/editor-md/src/editor-md-types.ts | 2 +- packages/devui-vue/docs/components/editor-md/index.md | 6 +++++- packages/devui-vue/package.json | 2 +- 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/packages/devui-vue/devui/editor-md/src/composables/md-render-service.ts b/packages/devui-vue/devui/editor-md/src/composables/md-render-service.ts index 32e7c5e720..e3e3a688da 100644 --- a/packages/devui-vue/devui/editor-md/src/composables/md-render-service.ts +++ b/packages/devui-vue/devui/editor-md/src/composables/md-render-service.ts @@ -73,7 +73,11 @@ export class MDRenderService { setCustomXssRules(rules: ICustomXssRule[]) { if (rules) { rules.forEach((rule) => { - this.xssWhiteList[rule['key']] = rule['value']; + if (rule['value'] === null) { + delete this.xssWhiteList[rule['key']]; + } else { + this.xssWhiteList[rule['key']] = rule['value']; + } }); } } diff --git a/packages/devui-vue/devui/editor-md/src/editor-md-types.ts b/packages/devui-vue/devui/editor-md/src/editor-md-types.ts index 1774cbd148..40dc634df2 100644 --- a/packages/devui-vue/devui/editor-md/src/editor-md-types.ts +++ b/packages/devui-vue/devui/editor-md/src/editor-md-types.ts @@ -16,7 +16,7 @@ export interface MdPlugin { export interface ICustomXssRule { key: string; - value: string[]; + value: string[] | null; } export interface ICustomRenderRule { diff --git a/packages/devui-vue/docs/components/editor-md/index.md b/packages/devui-vue/docs/components/editor-md/index.md index badb30e6af..fb7b4d1c12 100644 --- a/packages/devui-vue/docs/components/editor-md/index.md +++ b/packages/devui-vue/docs/components/editor-md/index.md @@ -58,6 +58,10 @@ export default defineComponent({ key: 'kbd', value: [], // 为空表示过滤所有属性,放开属性则添加对应项,如['id', 'style'] }, + { + key: 'input', + value: null, // value值为null,则对应标签不会被渲染 + } ]) const customRendererRules = ref([ { @@ -635,7 +639,7 @@ interface ICustomRenderRule { ```ts interface ICustomXssRule { key: string; - value: string[]; + value: string[] | null; } ``` diff --git a/packages/devui-vue/package.json b/packages/devui-vue/package.json index 91b2c9f955..2992568eb6 100644 --- a/packages/devui-vue/package.json +++ b/packages/devui-vue/package.json @@ -1,6 +1,6 @@ { "name": "vue-devui", - "version": "1.6.3-markdown.1", + "version": "1.6.3-markdown.2", "license": "MIT", "description": "DevUI components based on Vite and Vue3", "keywords": [