v0.2.0 使用cssfilter模块来过滤style属性
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
// 输出时需要转义<>"
|
||||
|
||||
Reference in New Issue
Block a user