Skip to content

Commit

Permalink
fix: Changed the behavior of the nesting counter ever so slightly
Browse files Browse the repository at this point in the history
  • Loading branch information
cure53 committed Apr 23, 2024
1 parent c5369f2 commit c725ce0
Show file tree
Hide file tree
Showing 9 changed files with 29 additions and 13 deletions.
8 changes: 6 additions & 2 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.

8 changes: 6 additions & 2 deletions dist/purify.es.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -1379,8 +1379,12 @@ function createDOMPurify() {
}

/* Count the nesting depth of an element */
if (currentNode.hasChildNodes()) {
depth++;
if (currentNode.nodeType === 1 && currentNode.hasChildNodes()) {
if (currentNode.hasChildNodes()) {
depth++;
} else {
depth--;
}
}

/* Remove an element if nested too deeply to avoid mXSS */
Expand Down
2 changes: 1 addition & 1 deletion dist/purify.es.mjs.map

Large diffs are not rendered by default.

8 changes: 6 additions & 2 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: 6 additions & 2 deletions src/purify.js
Original file line number Diff line number Diff line change
Expand Up @@ -1502,8 +1502,12 @@ function createDOMPurify(window = getGlobal()) {
}

/* Count the nesting depth of an element */
if (currentNode.hasChildNodes()) {
depth++;
if (currentNode.nodeType === 1 && currentNode.hasChildNodes()) {
if (currentNode.hasChildNodes()) {
depth++;
} else {
depth--;
}
}

/* Remove an element if nested too deeply to avoid mXSS */
Expand Down

0 comments on commit c725ce0

Please sign in to comment.