Comparing version 0.0.2 to 0.0.3
@@ -47,3 +47,12 @@ /** | ||
var c = css[i]; | ||
if (c === '(') { | ||
if (c === '/' && css[i + 1] === '*') { | ||
// 备注开始 | ||
var j = css.indexOf('*/', i + 2); | ||
// 如果没有正常的备注结束,则后面的部分全部跳过 | ||
if (j === -1) break; | ||
// 直接将当前位置调到备注结尾,并且初始化状态 | ||
i = j + 1; | ||
lastPos = i + 1; | ||
isParenthesisOpen = false; | ||
} else if (c === '(') { | ||
isParenthesisOpen = true; | ||
@@ -50,0 +59,0 @@ } else if (c === ')') { |
{ | ||
"name": "cssfilter", | ||
"version": "0.0.2", | ||
"version": "0.0.3", | ||
"description": "Sanitize untrusted CSS with a configuration specified by a Whitelist. 根据白名单过滤CSS", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -16,3 +16,3 @@ # cssfilter | ||
var cssfilter = require('cssfilter'); | ||
var css = cssfilter('position:fixed; width:100px; height:100px; background:#aaa;'); | ||
var css = cssfilter('position:fixed; /* this is comments */ width:100px; height:100px; background:#aaa;'); | ||
console.log(css); | ||
@@ -19,0 +19,0 @@ // 输出:width:100px; height:100px; background:#aaa; |
@@ -26,2 +26,12 @@ /** | ||
it('stript comments', function () { | ||
parseStyle('/*width: 100px;\nhe*/ight:200px; /**/ y:url(a/*b*/); /*font-size:400; */font:none;', function (sourcePosition, position, name, value, source) { | ||
if (name === 'font') { | ||
value.should.equal('none'); | ||
} | ||
return name + ':' + value; | ||
}).should.equal('ight:200px; font:none;'); | ||
}); | ||
it('ending without `;`', function () { | ||
@@ -28,0 +38,0 @@ parseStyle('width: 100px;height:200px; font-size:400', function (sourcePosition, position, name, value, source) { |
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
35501
700