validator
Advanced tools
Comparing version 0.2.7 to 0.2.8
@@ -297,1 +297,10 @@ var net = require('net'); | ||
//Will work against Visa, MasterCard, American Express, Discover, Diners Club, and JCB card numbering formats | ||
Validator.prototype.isCreditCard = function() { | ||
this.str.replace(/[^0-9]+/g, ''); //remove all dashes, spaces, etc. | ||
if (!this.str.match(/^(?:4[0-9]{12}(?:[0-9]{3})?|5[1-5][0-9]{14}|6(?:011|5[0-9][0-9])[0-9]{12}|3[47][0-9]{13}|3(?:0[0-5]|[68][0-9])[0-9]{11}|(?:2131|1800|35\d{3})\d{11})$/)) { | ||
return this.error(this.msg || 'Invalid credit card'); | ||
} | ||
return this; | ||
} | ||
@@ -67,3 +67,8 @@ //This module is adapted from the CodeIgniter framework | ||
//<a href="http://%77%77%77%2E%67%6F%6F%67%6C%65%2E%63%6F%6D">Google</a> | ||
str = decodeURIComponent(str); | ||
try{ | ||
str = decodeURIComponent(str); | ||
} | ||
catch(error){ | ||
// str was not actually URI-encoded | ||
} | ||
@@ -70,0 +75,0 @@ //Convert character entities to ASCII - this permits our tests below to work reliably. |
{ "name" : "validator", | ||
"description" : "Data validation, filtering and sanitization for node.js", | ||
"version" : "0.2.7", | ||
"version" : "0.2.8", | ||
"homepage" : "http://github.com/chriso/node-validator", | ||
@@ -5,0 +5,0 @@ "keywords" : ["validator", "validation", "assert", "params", "sanitization", "xss", "entities", "sanitize", "sanitisation", "input"], |
@@ -544,2 +544,11 @@ /*! | ||
//Will work against Visa, MasterCard, American Express, Discover, Diners Club, and JCB card numbering formats | ||
Validator.prototype.isCreditCard = function() { | ||
this.str.replace(/[^0-9]+/g, ''); //remove all dashes, spaces, etc. | ||
if (!this.str.match(/^(?:4[0-9]{12}(?:[0-9]{3})?|5[1-5][0-9]{14}|6(?:011|5[0-9][0-9])[0-9]{12}|3[47][0-9]{13}|3(?:0[0-5]|[68][0-9])[0-9]{11}|(?:2131|1800|35\d{3})\d{11})$/)) { | ||
return this.error(this.msg || 'Invalid credit card'); | ||
} | ||
return this; | ||
} | ||
Validator.prototype.isUrl = function() { | ||
@@ -769,3 +778,3 @@ if (!this.str.match(/^(?:(?:ht|f)tp(?:s?)\:\/\/|~\/|\/)?(?:\w+:\w+@)?((?:(?:[-\w\d{1-3}]+\.)+(?:com|org|net|gov|mil|biz|info|mobi|name|aero|jobs|edu|co\.uk|ac\.uk|it|fr|tv|museum|asia|local|travel|[a-z]{2}))|((\b25[0-5]\b|\b[2][0-4][0-9]\b|\b[0-1]?[0-9]?[0-9]\b)(\.(\b25[0-5]\b|\b[2][0-4][0-9]\b|\b[0-1]?[0-9]?[0-9]\b)){3}))(?::[\d]{1,5})?(?:(?:(?:\/(?:[-\w~!$+|.,=]|%[a-f\d]{2})+)+|\/)+|\?|#)?(?:(?:\?(?:[-\w~!$+|.,*:]|%[a-f\d{2}])+=?(?:[-\w~!$+|.,*:=]|%[a-f\d]{2})*)(?:&(?:[-\w~!$+|.,*:]|%[a-f\d{2}])+=?(?:[-\w~!$+|.,*:=]|%[a-f\d]{2})*)*)*(?:#(?:[-\w~!$ |\/.,*:;=]|%[a-f\d]{2})*)?$/)) { | ||
Filter.prototype.xss = function(is_image) { | ||
this.modify(xssClean(this.str, is_image)); | ||
this.modify(exports.xssClean(this.str, is_image)); | ||
return this.str; | ||
@@ -853,2 +862,3 @@ } | ||
})(this); | ||
})(typeof(exports) === 'undefined' ? window : exports); | ||
104747
2232