Skip to content
Browse files

added test for sanitizing based on attribute value

  • Loading branch information...
1 parent 0781cd1 commit b997118e397b0a3bf47980998ceb71e6f5f7674a @tmont committed Feb 10, 2013
Showing with 11 additions and 1 deletion.
  1. +1 −1 src/parser.js
  2. +10 −0 tests/sanitization-tests.js
View
2 src/parser.js
@@ -379,7 +379,7 @@ exports.sanitize = function(htmlString, removalCallbacks) {
}
name = name.toLowerCase();
- if (toRemove.attributes(name,value)) {
+ if (toRemove.attributes(name, value)) {
return;
}
View
10 tests/sanitization-tests.js
@@ -156,4 +156,14 @@ describe('Sanitization', function() {
});
sanitized.should.equal('<baz>oh hai there</baz>');
});
+
+ it('should sanitize based on attribute value', function() {
+ var html = '<foo id="abc"></foo><foo id="def"></foo>';
+ var sanitized = helpers.parser.sanitize(html, {
+ attributes: function(name, value) {
+ return value === 'abc';
+ }
+ });
+ sanitized.should.equal('<foo></foo><foo id="def"></foo>');
+ });
});

0 comments on commit b997118

Please sign in to comment.
Something went wrong with that request. Please try again.