-
Notifications
You must be signed in to change notification settings - Fork 440
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
165 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
node_modules | ||
dist | ||
asp/upload | ||
asp/upload | ||
.vscode |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
/** | ||
* @file xssFilter.js | ||
* @desc xss过滤器 | ||
* @author robbenmu | ||
*/ | ||
|
||
UM.plugins.xssFilter = function() { | ||
|
||
var config = UMEDITOR_CONFIG; | ||
var whiteList = config.whiteList; | ||
|
||
function filter(node) { | ||
|
||
var tagName = node.tagName; | ||
var attrs = node.attrs; | ||
|
||
if (!whiteList.hasOwnProperty(tagName)) { | ||
node.parentNode.removeChild(node); | ||
return false; | ||
} | ||
|
||
UM.utils.each(attrs, function (val, key) { | ||
|
||
if (whiteList[tagName].indexOf(key) === -1) { | ||
node.setAttr(key); | ||
} | ||
}); | ||
} | ||
|
||
// 添加inserthtml\paste等操作用的过滤规则 | ||
if (whiteList && config.xssFilterRules) { | ||
this.options.filterRules = function () { | ||
|
||
var result = {}; | ||
|
||
UM.utils.each(whiteList, function(val, key) { | ||
result[key] = function (node) { | ||
return filter(node); | ||
}; | ||
}); | ||
|
||
return result; | ||
}(); | ||
} | ||
|
||
var tagList = []; | ||
|
||
UM.utils.each(whiteList, function (val, key) { | ||
tagList.push(key); | ||
}); | ||
|
||
// 添加input过滤规则 | ||
// | ||
if (whiteList && config.inputXssFilter) { | ||
this.addInputRule(function (root) { | ||
|
||
root.traversal(function(node) { | ||
if (node.type !== 'element') { | ||
return false; | ||
} | ||
filter(node); | ||
}); | ||
}); | ||
} | ||
// 添加output过滤规则 | ||
// | ||
if (whiteList && config.outputXssFilter) { | ||
this.addOutputRule(function (root) { | ||
|
||
root.traversal(function(node) { | ||
if (node.type !== 'element') { | ||
return false; | ||
} | ||
filter(node); | ||
}); | ||
}); | ||
} | ||
|
||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 comment
on commit 1255447
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
`好像,字体,字体大小,标题都不能用了!```
这行导致1.2.3字体字号不好用!!! @Phinome