Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

cssfilter

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cssfilter - npm Package Compare versions

Comparing version 0.0.1 to 0.0.2

19

lib/css.js

@@ -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 @@ });

2

package.json
{
"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;');
});
});
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc