Skip to content

Commit

Permalink
fix: Fixed an off-by-one with the nesting counter causing over-saniti…
Browse files Browse the repository at this point in the history
…zation
  • Loading branch information
cure53 committed Apr 23, 2024
1 parent c725ce0 commit f051738
Show file tree
Hide file tree
Showing 9 changed files with 13 additions and 13 deletions.
4 changes: 2 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.

4 changes: 2 additions & 2 deletions dist/purify.es.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -516,7 +516,7 @@ function createDOMPurify() {
let CONFIG = null;

/* Specify the maximum element nesting depth to prevent mXSS */
const MAX_NESTING_DEPTH = 511;
const MAX_NESTING_DEPTH = 512;

/* Ideally, do not touch anything below this line */
/* ______________________________________________ */
Expand Down Expand Up @@ -1388,7 +1388,7 @@ function createDOMPurify() {
}

/* Remove an element if nested too deeply to avoid mXSS */
if (depth >= MAX_NESTING_DEPTH) {
if (depth > MAX_NESTING_DEPTH) {
_forceRemove(currentNode);
}

Expand Down
2 changes: 1 addition & 1 deletion dist/purify.es.mjs.map

Large diffs are not rendered by default.

4 changes: 2 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.

4 changes: 2 additions & 2 deletions src/purify.js
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ function createDOMPurify(window = getGlobal()) {
let CONFIG = null;

/* Specify the maximum element nesting depth to prevent mXSS */
const MAX_NESTING_DEPTH = 511;
const MAX_NESTING_DEPTH = 512;

/* Ideally, do not touch anything below this line */
/* ______________________________________________ */
Expand Down Expand Up @@ -1511,7 +1511,7 @@ function createDOMPurify(window = getGlobal()) {
}

/* Remove an element if nested too deeply to avoid mXSS */
if (depth >= MAX_NESTING_DEPTH) {
if (depth > MAX_NESTING_DEPTH) {
_forceRemove(currentNode);
}

Expand Down

0 comments on commit f051738

Please sign in to comment.