2021-10-07

UEditor切换到html源代码模式,手写一些div/script/style等html代码后,切换回默认模式,会自动把一些标签给过滤掉。

修改方法

1、关闭切换html时过滤代码

UE.plugins['defaultfilter'] = function () {  
    return;   //在这里添加return,不执行下面的格式化  
    var me = this;  
    me.setOpt({  
        'allowDivTransToP':false,  
        'disabledTableInTable':true  
    });  
    //默认的过滤处理  
    //进入编辑器的内容处理 





同理,对ueditor.all.min.js做同样处理:(可搜索 defaultfilter 定位)

2、关闭特殊html转义

 filterInputRule: function (root) {
            return;  //添加返回
            for (var i = 0, ci; ci = this.inputRules[i++];) {
                ci.call(this, root)
            }
        },




3,还有部分标签 则是在  ueditor.config.js 的白名单里 ,关闭xss 过滤 就三个 true 改成 false 就直接原样输出了: 

// xss 过滤是否开启,inserthtml等操作
,xssFilterRules: true

//input xss过滤
,inputXssFilter: true

//output xss过滤
,outputXssFilter: true

// xss过滤白名单 名单来源: https://raw.githubusercontent.com/leizongmin/js-xss/master/lib/default.js
,whitList: {
  body: [],
   html: [],
   //...把不用屏蔽的标签列出来即可,简单粗暴的话,直接把这个 whitList 对象全注释掉   
}

记得清除缓存刷新下。

打赏

好文章,更需要你的鼓励

本文由 氢设计 创作,除注明转载/出处外,均为本站原创,转载前请务必署名

最后编辑时间为:2021-11-23 10:21:01

本文链接:https://www.h2sheji.com/show-179.html