在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