在wangeditor使用xss防注入--vue


1,下载

npm install xss -S

2.在使用wang的地方引入

import xss from 'xss

3.找到editor实例

this.editor = new E(this.$refs.toolbar, this.$refs.editor);

4.找到html内容进行xss过滤

    
      this.editor.customConfig.onchange = (html) => {
        //可以自定义白名单
        var options = { whiteList: { img: ["src", "title", "target"], }, }; myxss = new xss.FilterXSS(options); let filterHtml = myxss.process(html); let filterHtml = filterXSS(html); // 此处进行 xss 攻击过滤 this.$emit("change", filterHtml ); // 将内容同步到父组件中 };

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM