Comparing version 0.0.1 to 0.0.2
@@ -52,2 +52,3 @@ /** | ||
var retCSS = parseStyle(css, function (sourcePosition, position, name, value, source) { | ||
var check = whiteList[name]; | ||
@@ -59,4 +60,12 @@ var isWhite = false; | ||
if (isWhite !== true) isWhite = false; | ||
var opts = {position: position, sourcePosition: sourcePosition, source: source, isWhite: isWhite}; | ||
var opts = { | ||
position: position, | ||
sourcePosition: sourcePosition, | ||
source: source, | ||
isWhite: isWhite | ||
}; | ||
if (isWhite) { | ||
var ret = onAttr(name, value, opts); | ||
@@ -68,4 +77,10 @@ if (isNull(ret)) { | ||
} | ||
} else { | ||
onIgnoreAttr(name, value, opts); | ||
var ret = onIgnoreAttr(name, value, opts); | ||
if (!isNull(ret)) { | ||
return ret; | ||
} | ||
} | ||
@@ -72,0 +87,0 @@ }); |
{ | ||
"name": "cssfilter", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"description": "Sanitize untrusted CSS with a configuration specified by a Whitelist. 根据白名单过滤CSS", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -19,2 +19,3 @@ # cssfilter | ||
// 输出:width:100px; height:100px; background:#aaa; | ||
// 因为position不在白名单允许范围 | ||
``` | ||
@@ -46,2 +47,4 @@ | ||
// value为属性值 | ||
// 返回字符串表示覆盖此段CSS | ||
// 不返回任何值表示使用默认生成方法,即将此段CSS去掉 | ||
} | ||
@@ -48,0 +51,0 @@ }; |
@@ -46,2 +46,15 @@ /** | ||
it('onIgnoreAttr() returns new sources', function () { | ||
filterCSS('position: fixed; width:100px; height: 200px', { | ||
onIgnoreAttr: function (name, value, options) { | ||
options.isWhite.should.equal(false); | ||
if (name === 'position') value.should.equal('fixed'); | ||
else throw new Error('bad attr name `' + name + '`'); | ||
return 'x-' + name + ':' + value; | ||
} | ||
}).should.equal('x-position:fixed; width:100px; height:200px;'); | ||
}); | ||
}); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
34758
683
81
0