Skip to content

Commit

Permalink
fix: Added same attribute clobbering check for 2.x branch
Browse files Browse the repository at this point in the history
  • Loading branch information
cure53 committed Dec 7, 2024
1 parent f7120a3 commit 9cd4f11
Show file tree
Hide file tree
Showing 9 changed files with 37 additions and 57 deletions.
21 changes: 8 additions & 13 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.

21 changes: 8 additions & 13 deletions dist/purify.es.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.es.js.map

Large diffs are not rendered by default.

21 changes: 8 additions & 13 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.

21 changes: 8 additions & 13 deletions src/purify.js
Original file line number Diff line number Diff line change
Expand Up @@ -1230,7 +1230,7 @@ function createDOMPurify(window = getGlobal()) {
const { attributes } = currentNode;

/* Check if we have attributes; if not we might have a text node */
if (!attributes) {
if (!attributes || _isClobbered(currentNode)) {
return;
}

Expand Down Expand Up @@ -1369,15 +1369,12 @@ function createDOMPurify(window = getGlobal()) {
while ((shadowNode = shadowIterator.nextNode())) {
/* Execute a hook if present */
_executeHook('uponSanitizeShadowNode', shadowNode, null);
/* Sanitize tags and elements */
_sanitizeElements(shadowNode);

/* Check attributes first */
/* Check attributes next */
_sanitizeAttributes(shadowNode);

/* Sanitize tags and elements */
if (_sanitizeElements(shadowNode)) {
continue;
}

/* Deep shadow DOM detected */
if (shadowNode.content instanceof DocumentFragment) {
_sanitizeShadowDOM(shadowNode.content);
Expand Down Expand Up @@ -1515,13 +1512,11 @@ function createDOMPurify(window = getGlobal()) {
continue;
}

/* Check attributes first */
_sanitizeAttributes(currentNode);

/* Sanitize tags and elements */
if (_sanitizeElements(currentNode)) {
continue;
}
_sanitizeElements(currentNode);

/* Check attributes next */
_sanitizeAttributes(currentNode);

/* Shadow DOM detected, sanitize it */
if (currentNode.content instanceof DocumentFragment) {
Expand Down

0 comments on commit 9cd4f11

Please sign in to comment.