Skip to content

Commit

Permalink
fix: Removed the unnecessary clobbering check for elm.data
Browse files Browse the repository at this point in the history
  • Loading branch information
cure53 committed Mar 26, 2024
1 parent fc3c781 commit 1ebcfd4
Show file tree
Hide file tree
Showing 9 changed files with 20 additions and 28 deletions.
10 changes: 4 additions & 6 deletions dist/purify.cjs.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/purify.cjs.js.map

Large diffs are not rendered by default.

10 changes: 4 additions & 6 deletions dist/purify.es.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -919,7 +919,7 @@ function createDOMPurify() {
* @return {Boolean} true if clobbered, false if safe
*/
const _isClobbered = function _isClobbered(elm) {
return elm instanceof HTMLFormElement && (typeof elm.nodeName !== 'string' || typeof elm.textContent !== 'string' || typeof elm.data !== 'string' || typeof elm.removeChild !== 'function' || !(elm.attributes instanceof NamedNodeMap) || typeof elm.removeAttribute !== 'function' || typeof elm.setAttribute !== 'function' || typeof elm.namespaceURI !== 'string' || typeof elm.insertBefore !== 'function' || typeof elm.hasChildNodes !== 'function');
return elm instanceof HTMLFormElement && (typeof elm.nodeName !== 'string' || typeof elm.textContent !== 'string' || typeof elm.removeChild !== 'function' || !(elm.attributes instanceof NamedNodeMap) || typeof elm.removeAttribute !== 'function' || typeof elm.setAttribute !== 'function' || typeof elm.namespaceURI !== 'string' || typeof elm.insertBefore !== 'function' || typeof elm.hasChildNodes !== 'function');
};

/**
Expand Down Expand Up @@ -986,14 +986,12 @@ function createDOMPurify() {
return true;
}

/* Remove any ocurrence of possibly malicious comments */
if (currentNode.nodeType === 8 && regExpTest(/<[/\w]/g, currentNode.data)) {
/* Remove any ocurrence of processing instructions */
if (currentNode.nodeType === 7) {
_forceRemove(currentNode);
return true;
}

/* Remove any ocurrence of processing instructions */
if (currentNode.nodeType === 7) {
if (currentNode.nodeType === 8 && regExpTest(/<[/\w]/g, currentNode.data)) {
_forceRemove(currentNode);
return true;
}
Expand Down
2 changes: 1 addition & 1 deletion dist/purify.es.mjs.map

Large diffs are not rendered by default.

10 changes: 4 additions & 6 deletions dist/purify.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/purify.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/purify.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/purify.min.js.map

Large diffs are not rendered by default.

8 changes: 3 additions & 5 deletions src/purify.js
Original file line number Diff line number Diff line change
Expand Up @@ -930,7 +930,6 @@ function createDOMPurify(window = getGlobal()) {
elm instanceof HTMLFormElement &&
(typeof elm.nodeName !== 'string' ||
typeof elm.textContent !== 'string' ||
typeof elm.data !== 'string' ||
typeof elm.removeChild !== 'function' ||
!(elm.attributes instanceof NamedNodeMap) ||
typeof elm.removeAttribute !== 'function' ||
Expand Down Expand Up @@ -1011,14 +1010,13 @@ function createDOMPurify(window = getGlobal()) {
return true;
}

/* Remove any ocurrence of possibly malicious comments */
if (currentNode.nodeType === 8 && regExpTest(/<[/\w]/g, currentNode.data)) {
/* Remove any ocurrence of processing instructions */
if (currentNode.nodeType === 7) {
_forceRemove(currentNode);
return true;
}

/* Remove any ocurrence of processing instructions */
if (currentNode.nodeType === 7) {
if (currentNode.nodeType === 8 && regExpTest(/<[/\w]/g, currentNode.data)) {
_forceRemove(currentNode);
return true;
}
Expand Down

0 comments on commit 1ebcfd4

Please sign in to comment.