Skip to content

Commit

Permalink
fix: Added experiemental comment scrubbing inside attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
cure53 committed May 5, 2024
1 parent dc61232 commit d1d5d22
Show file tree
Hide file tree
Showing 9 changed files with 29 additions and 5 deletions.
6 changes: 6 additions & 0 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.

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

/* Work around an issue with comments inside attribites */
if (regExpTest(/(--!?|])>/i, value)) {
_removeAttribute(name, currentNode);
continue;
}

/* Sanitize attribute content to be template-safe */
if (SAFE_FOR_TEMPLATES) {
arrayForEach([MUSTACHE_EXPR, ERB_EXPR, TMPLIT_EXPR], expr => {
Expand Down
2 changes: 1 addition & 1 deletion dist/purify.es.mjs.map

Large diffs are not rendered by default.

6 changes: 6 additions & 0 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.

6 changes: 6 additions & 0 deletions src/purify.js
Original file line number Diff line number Diff line change
Expand Up @@ -1311,6 +1311,12 @@ function createDOMPurify(window = getGlobal()) {
continue;
}

/* Work around an issue with comments inside attribites */
if (regExpTest(/(--!?|])>/i, value)) {
_removeAttribute(name, currentNode);
continue;
}

/* Sanitize attribute content to be template-safe */
if (SAFE_FOR_TEMPLATES) {
arrayForEach([MUSTACHE_EXPR, ERB_EXPR, TMPLIT_EXPR], (expr) => {
Expand Down

0 comments on commit d1d5d22

Please sign in to comment.