fix: xss漏洞修复 fix #6349

This commit is contained in:
chenjianxing 2021-10-27 14:22:42 +08:00 committed by jianxing
parent 646d0d23ea
commit aee00fa827
4 changed files with 35 additions and 2 deletions

View File

@ -1,6 +1,7 @@
<template> <template>
<el-form-item v-loading="result.loading" :disable="true" :label="title" :prop="prop" :label-width="labelWidth"> <el-form-item v-loading="result.loading" :disable="true" :label="title" :prop="prop" :label-width="labelWidth">
<mavon-editor :id="id" v-if="active" :editable="!disabled" @imgAdd="imgAdd" :default-open="defaultOpen" class="mavon-editor" <mavon-editor :id="id" v-if="active" :editable="!disabled" @imgAdd="imgAdd" :default-open="defaultOpen" class="mavon-editor"
:xss-options="xssOptions"
:subfield="false" :toolbars="toolbars" :language="language" :toolbarsFlag="disabled ? false : true" @imgDel="imgDel" v-model="data[prop]" ref="md"/> :subfield="false" :toolbars="toolbars" :language="language" :toolbarsFlag="disabled ? false : true" @imgDel="imgDel" v-model="data[prop]" ref="md"/>
</el-form-item> </el-form-item>
</template> </template>
@ -15,6 +16,12 @@ export default {
return { return {
result: {loading: false}, result: {loading: false},
id: getUUID(), id: getUUID(),
xssOptions: {
whiteList: {
img: ["src", "alt", "width", "height"],
},
stripIgnoreTagBody: true
},
defaultOpen: 'preview', defaultOpen: 'preview',
toolbars: { toolbars: {
bold: true, // bold: true, //
@ -76,6 +83,9 @@ export default {
} }
}, },
mounted() { mounted() {
if (this.$refs.md) {
this.$refs.md.markdownIt.set({html: false});
}
// //
let el = document.getElementById(this.id); let el = document.getElementById(this.id);
if (el) { if (el) {

View File

@ -5,6 +5,7 @@
<div class="editors_div_style"> <div class="editors_div_style">
<div id="editorsDiv"> <div id="editorsDiv">
<mavon-editor :disabled="isReadOnly" <mavon-editor :disabled="isReadOnly"
:xss-options="xssOptions"
@imgAdd="imgAdd" :default-open="'edit'" class="review-mavon-editor" :imageFilter="imageFilter" @imgAdd="imgAdd" :default-open="'edit'" class="review-mavon-editor" :imageFilter="imageFilter"
:toolbars="richDataToolbars" @imgDel="imgDel" v-model="textarea" ref="md"/> :toolbars="richDataToolbars" @imgDel="imgDel" v-model="textarea" ref="md"/>
</div> </div>
@ -36,6 +37,12 @@ export default {
textarea: '', textarea: '',
isReadOnly: false, isReadOnly: false,
dialogTableVisible: false, dialogTableVisible: false,
xssOptions: {
whiteList: {
img: ["src", "alt", "width", "height"],
},
stripIgnoreTagBody: true
},
richDataToolbars: { richDataToolbars: {
bold: false, // bold: false, //
italic: false, // italic: false, //
@ -73,8 +80,10 @@ export default {
} }
}; };
}, },
created() { mounted() {
if (this.$refs.md) {
this.$refs.md.markdownIt.set({html: false});
}
}, },
methods: { methods: {
open() { open() {

View File

@ -12,6 +12,7 @@
popper-class="issues-popover" popper-class="issues-popover"
> >
<mavon-editor :editable="false" default-open="preview" class="mavon-editor" <mavon-editor :editable="false" default-open="preview" class="mavon-editor"
:xss-options="xssOptions"
:subfield="false" :toolbarsFlag="false" v-model="scope.row.description" ref="md"/> :subfield="false" :toolbarsFlag="false" v-model="scope.row.description" ref="md"/>
<el-button slot="reference" type="text">{{ $t('test_track.issue.preview') }}</el-button> <el-button slot="reference" type="text">{{ $t('test_track.issue.preview') }}</el-button>
</el-popover> </el-popover>
@ -27,6 +28,12 @@ export default {
data() { data() {
return { return {
readConfig: {toolbar: []}, readConfig: {toolbar: []},
xssOptions: {
whiteList: {
img: ["src", "alt", "width", "height"],
},
stripIgnoreTagBody: true
},
}; };
}, },
props: { props: {

View File

@ -18,6 +18,7 @@
<div class="editors_div_style"> <div class="editors_div_style">
<div id="editorsDiv" > <div id="editorsDiv" >
<mavon-editor v-if="showEditor" @imgAdd="imgAdd" :default-open="'edit'" class="review-mavon-editor" :imageFilter="imageFilter" <mavon-editor v-if="showEditor" @imgAdd="imgAdd" :default-open="'edit'" class="review-mavon-editor" :imageFilter="imageFilter"
:xss-options="xssOptions"
:toolbars="richDataToolbars" @imgDel="imgDel" v-model="textarea" ref="md"/> :toolbars="richDataToolbars" @imgDel="imgDel" v-model="textarea" ref="md"/>
</div> </div>
</div> </div>
@ -53,6 +54,12 @@ export default {
labelWidth: '120px', labelWidth: '120px',
showEditor:true, showEditor:true,
isReadOnly: false, isReadOnly: false,
xssOptions: {
whiteList: {
img: ["src", "alt", "width", "height"],
},
stripIgnoreTagBody: true
},
richDataToolbars: { richDataToolbars: {
bold: false, // bold: false, //
italic: false, // italic: false, //