Comparing version 0.2.1 to 0.3.0
@@ -8,3 +8,3 @@ /* | ||
var fs = require('fs'), | ||
ent = require('ent'); | ||
he = require('he'); | ||
@@ -45,3 +45,3 @@ var bleach = { | ||
name: attr_name, | ||
value: attr_val | ||
value: attr_val | ||
}; | ||
@@ -60,3 +60,3 @@ if (!attr.value) delete attr.value; | ||
} | ||
return matches; | ||
@@ -99,3 +99,3 @@ }, | ||
if ( options.encode_entities ) html = ent.encode( html ); | ||
if ( options.encode_entities ) html = he.encode( html ); | ||
@@ -105,3 +105,3 @@ return html; | ||
filter: function(html, filters) { | ||
filterSync: function(html, filters) { | ||
html = String(html) || ''; | ||
@@ -139,3 +139,41 @@ | ||
} else return html; | ||
}, | ||
filter: function(html, filters, callback) { | ||
if (typeof(callback) != 'function') { | ||
return bleach.filterSync(html, filters); | ||
} | ||
html = String(html) || ''; | ||
if (!filters) callback('no filters provided', undefined); | ||
var available = fs.readdir(__dirname + '/../filters', function() { | ||
if (Array.isArray(filters)) { | ||
for (var i in filters) { | ||
if (typeof filters[i] == 'function') { | ||
html = filters[i](html); | ||
} else { | ||
var file = filters[i] + '.js'; | ||
for (var j in available) { | ||
if (file == available[j]) { | ||
html = require('../filters/' + file)(html); | ||
} | ||
} | ||
} | ||
} | ||
return html; | ||
} else if (typeof filters == 'string') { | ||
var file = filters + '.js'; | ||
for (var i in available) { | ||
if (file == available[i]) { | ||
html = require('../filters/' + file)(html); | ||
callback(undefined, html); | ||
} | ||
} | ||
} else if (typeof filters == 'function') { | ||
html = filters(undefined, html); | ||
callback(undefined, html); | ||
} else callback(undefined, html); | ||
}); | ||
} | ||
@@ -142,0 +180,0 @@ |
@@ -5,3 +5,3 @@ { | ||
"description": "A minimalistic HTML sanitizer", | ||
"version": "0.2.1", | ||
"version": "0.3.0", | ||
"homepage": "https://github.com/ecto/bleach/issues", | ||
@@ -17,3 +17,3 @@ "repository": { | ||
"dependencies": { | ||
"ent": "0.0.x" | ||
"he": "0.4.x" | ||
}, | ||
@@ -20,0 +20,0 @@ "devDependencies": { |
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
17219
341
0
5
+ Addedhe@0.4.x
+ Addedhe@0.4.1(transitive)
- Removedent@0.0.x
- Removedent@0.0.8(transitive)
- Removedpunycode@1.4.1(transitive)