Skip to content

Commit

Permalink
feat(md): xss过滤规则增加可排除标签渲染
Browse files Browse the repository at this point in the history
  • Loading branch information
GreatZPP committed Mar 5, 2024
1 parent ee724eb commit fe0fa8b
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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'];
}
});
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/devui-vue/devui/editor-md/src/editor-md-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export interface MdPlugin {

export interface ICustomXssRule {
key: string;
value: string[];
value: string[] | null;
}

export interface ICustomRenderRule {
Expand Down
6 changes: 5 additions & 1 deletion packages/devui-vue/docs/components/editor-md/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ export default defineComponent({
key: 'kbd',
value: [], // 为空表示过滤所有属性,放开属性则添加对应项,如['id', 'style']
},
{
key: 'input',
value: null, // value值为null,则对应标签不会被渲染
}
])
const customRendererRules = ref([
{
Expand Down Expand Up @@ -635,7 +639,7 @@ interface ICustomRenderRule {
```ts
interface ICustomXssRule {
key: string;
value: string[];
value: string[] | null;
}
```

Expand Down
2 changes: 1 addition & 1 deletion packages/devui-vue/package.json
Original file line number Diff line number Diff line change
@@ -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": [
Expand Down

0 comments on commit fe0fa8b

Please sign in to comment.