Skip to content

Commit

Permalink
Merge pull request #4 from koto/patch-1
Browse files Browse the repository at this point in the history
Resolved NodeFilter and Node type constants
  • Loading branch information
cure53 committed Feb 28, 2014
2 parents 8ac5aea + 93de4af commit 9aeba50
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions purify.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,9 @@ DOMPurify.sanitize = function(dirty, cfg){
*/
var _createIterator = function(doc){
return document.createNodeIterator(
doc, 129, function() { return NodeFilter.FILTER_ACCEPT }, false
doc,
NodeFilter.SHOW_ELEMENT | NodeFilter.SHOW_COMMENT,
function() { return NodeFilter.FILTER_ACCEPT }, false
);
}

Expand All @@ -131,6 +133,7 @@ DOMPurify.sanitize = function(dirty, cfg){
|| typeof elm.nodeName !== 'string'
|| typeof elm.textContent !== 'string'
|| typeof elm.nodeType !== 'number'
|| typeof elm.COMMENT_NODE !== 'number'
|| typeof elm.setAttribute !== 'function'
|| typeof elm.cloneNode !== 'function'
|| typeof elm.removeAttributeNode !== 'function'
Expand All @@ -154,7 +157,7 @@ DOMPurify.sanitize = function(dirty, cfg){
* @return true if node was killed, false if left alive
*/
var _sanitizeElements = function(currentNode){
if(_isClobbered(currentNode) || currentNode.nodeType === 8
if(_isClobbered(currentNode) || currentNode.nodeType === currentNode.COMMENT_NODE
|| ALLOWED_TAGS.indexOf(currentNode.nodeName.toLowerCase()) === -1) {
currentNode.parentNode.removeChild(currentNode);
return true;
Expand Down Expand Up @@ -270,4 +273,4 @@ DOMPurify.sanitize = function(dirty, cfg){
}
return WHOLE_DOCUMENT ? body.outerHTML : body.innerHTML;
};
/* EOF */
/* EOF */

0 comments on commit 9aeba50

Please sign in to comment.