Ueditor修改编辑器过滤style/script标签问题
第一步:UEditor取消html源代码切换时div/script/style等自动过滤
在Ueditor编辑器目录找到ueditor的js文件:ueditor.all.js 注意**return;**加入的位置!
ueditor.all.js
搜索 UE.plugins['defaultfilter']
UE.plugins['defaultfilter'] = function () {
return; //在这里添加return,不执行下面的格式化
var me = this;
me.setOpt({
'allowDivTransToP':false,
'disabledTableInTable':true
});
//默认的过滤处理
//进入编辑器的内容处理
ueditor.all.min.js
搜索UE.plugins.defaultfilter
UE.plugins.defaultfilter=
function(){return;var d=this;d.setOpt({allowDivTransToP:!0,d
第二步:确保配置文件中白名单列表中包含相关标签及对应的属性
找到配置文件:ueditor.config.js 搜索关键词:whitList 该列表下出现的标签及对应的属性是不会被过滤掉的。
// xss过滤白名单
,whitList: {
iframe: ['frameborder','border','width','height','src','id'],
a: ['target', 'href', 'title', 'class', 'style'],
abbr: ['title', 'class', 'style'],
script: ['type','src'],
address: ['class', 'style'],
area: ['shape', 'coords', 'href', 'alt'],
article: [],
aside: [],
audio: ['autoplay', 'controls', 'loop', 'preload', 'src', 'class', 'style'],
b: ['class', 'style'],
以上二步缺一不可,按照步骤修改相关标签及对应的属性,保存后覆盖原来的文件,清空站点及本地缓存后即可生效。
实在不行吧过滤的函数也return掉:
UE.plugins.xssFilter = function() {
//nsk修改
return ; //在此处修改
var config = UEDITOR_CONFIG;
var whitList = config.whitList;
function filter(node) {
var tagName = node.tagName;
var attrs = node.attrs;