resanitize
Advanced tools
Comparing version 0.1.8 to 0.1.9
{ "name" : "resanitize" | ||
, "author" : "Dan MacTough <danmactough@gmail.com>" | ||
, "description" : "Regular expression-based HTML sanitizer and ad remover, geared toward RSS feed descriptions" | ||
, "version" : "0.1.8" | ||
, "version" : "0.1.9" | ||
, "keywords" : ["sanitize", "html", "regexp", "security"] | ||
@@ -6,0 +6,0 @@ , "homepage" : "http://github.com/danmactough/node-resanitize" |
@@ -16,2 +16,7 @@ /*! | ||
* | ||
* References: | ||
* - http://en.wikipedia.org/wiki/C0_and_C1_control_codes | ||
* - http://en.wikipedia.org/wiki/Unicode_control_characters | ||
* - http://www.utf8-chartable.de/unicode-utf8-table.pl | ||
* | ||
* @param {String|Buffer} HTML string to sanitize | ||
@@ -31,2 +36,3 @@ * @return {String} sanitized HTML | ||
str = stripAsciiCtrlChars(str); | ||
str = stripExtendedCtrlChars(str); | ||
str = fixSpace(str); | ||
@@ -48,3 +54,4 @@ str = stripComments(str); | ||
function fixSpace (str) { | ||
return str.replace(/\xc2\xa0/g, ' ') | ||
return str.replace(/\u00A0/g, ' ') // Unicode non-breaking space | ||
.replace(/\u2028\u2029/g, '') // UCS newline characters | ||
.replace(/\0/g, ''); | ||
@@ -72,2 +79,10 @@ } | ||
/** | ||
* Strip ISO 6429 control characters | ||
*/ | ||
function stripExtendedCtrlChars (str) { | ||
return str.replace(/[\u0080-\u009F]+/g, ''); | ||
} | ||
module.exports.stripExtendedCtrlChars = stripExtendedCtrlChars; | ||
/** | ||
* Strip HTML comments | ||
@@ -246,8 +261,8 @@ */ | ||
/* | ||
/** | ||
* Dumbly strip angle brackets | ||
*/ | ||
function stripHtml (str) { | ||
// @TODO | ||
return str; | ||
return str.replace(/<.*?>/g, ''); | ||
} | ||
module.exports.stripHtml = stripHtml; | ||
*/ |
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
13820
249
4