v0.2.0 使用cssfilter模块来过滤style属性

This commit is contained in:
Zongmin Lei
2015-05-05 22:50:56 +08:00
parent 900705dc04
commit 994f1a7045
4 changed files with 21 additions and 11 deletions

View File

@@ -136,9 +136,10 @@ function escapeHtml (html) {
* @param {String} tag
* @param {String} name
* @param {String} value
* @param {Object} cssFilter
* @return {String}
*/
function safeAttrValue (tag, name, value) {
function safeAttrValue (tag, name, value, cssFilter) {
// 转换为友好的属性值,再做判断
value = friendlyAttrValue(value);
@@ -162,10 +163,10 @@ function safeAttrValue (tag, name, value) {
}
} else if (name === 'style') {
// /*注释*/
REGEXP_DEFAULT_ON_TAG_ATTR_3.lastIndex = 0;
/*REGEXP_DEFAULT_ON_TAG_ATTR_3.lastIndex = 0;
if (REGEXP_DEFAULT_ON_TAG_ATTR_3.test(value)) {
return '';
}
}*/
// expression()
REGEXP_DEFAULT_ON_TAG_ATTR_7.lastIndex = 0;
if (REGEXP_DEFAULT_ON_TAG_ATTR_7.test(value)) {
@@ -179,6 +180,7 @@ function safeAttrValue (tag, name, value) {
return '';
}
}
value = cssFilter.process(value);
}
// 输出时需要转义<>"