Socket
Socket
Sign inDemoInstall

validator

Package Overview
Dependencies
Maintainers
1
Versions
211
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

validator - npm Package Compare versions

Comparing version 0.2.8 to 0.2.9

35

lib/filter.js

@@ -12,2 +12,15 @@ var entities = require('./entities');

Filter.prototype.wrap = function (str) {
return str;
}
Filter.prototype.value = function () {
return this.str;
}
Filter.prototype.chain = function () {
this.wrap = function () { return this };
return this;
}
//Create some aliases - may help code readability

@@ -21,3 +34,3 @@ Filter.prototype.convert = Filter.prototype.sanitize = function(str) {

this.modify(xss.clean(this.str, is_image));
return this.str;
return this.wrap(this.str);
}

@@ -27,3 +40,3 @@

this.modify(entities.decode(this.str));
return this.str;
return this.wrap(this.str);
}

@@ -33,3 +46,3 @@

this.modify(entities.encode(this.str));
return this.str;
return this.wrap(this.str);
}

@@ -40,3 +53,3 @@

this.modify(this.str.replace(new RegExp('^['+chars+']+', 'g'), ''));
return this.str;
return this.wrap(this.str);
}

@@ -47,3 +60,3 @@

this.modify(this.str.replace(new RegExp('['+chars+']+$', 'g'), ''));
return this.str;
return this.wrap(this.str);
}

@@ -54,3 +67,3 @@

this.modify(this.str.replace(new RegExp('^['+chars+']+|['+chars+']+$', 'g'), ''));
return this.str;
return this.wrap(this.str);
}

@@ -62,3 +75,3 @@

}
return this.str;
return this.wrap(this.str);
}

@@ -68,3 +81,3 @@

this.modify(parseFloat(this.str));
return this.str;
return this.wrap(this.str);
}

@@ -75,3 +88,3 @@

this.modify(parseInt(this.str, radix));
return this.str;
return this.wrap(this.str);
}

@@ -87,3 +100,3 @@

}
return this.str;
return this.wrap(this.str);
}

@@ -99,3 +112,3 @@

}
return this.str;
return this.wrap(this.str);
}
{ "name" : "validator",
"description" : "Data validation, filtering and sanitization for node.js",
"version" : "0.2.8",
"version" : "0.2.9",
"homepage" : "http://github.com/chriso/node-validator",

@@ -5,0 +5,0 @@ "keywords" : ["validator", "validation", "assert", "params", "sanitization", "xss", "entities", "sanitize", "sanitisation", "input"],

@@ -133,3 +133,8 @@ var node_validator = require('../lib'),

assert.equal('[removed] foobar', Filter.sanitize('j a vasc ri pt: foobar').xss());
},
'test chaining': function () {
assert.equal('&', Filter.sanitize('&').chain().entityEncode().entityEncode().entityEncode().value());
}
}
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