Skip to content

Commit b552659

Browse files
committedSep 24, 2020
fix: re-enabled the mXSS check for old Chrome at the right place
1 parent aec12c4 commit b552659

9 files changed

+32
-32
lines changed
 

‎dist/purify.cjs.js

+6-6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎dist/purify.cjs.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎dist/purify.es.js

+6-6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎dist/purify.es.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎dist/purify.js

+6-6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎dist/purify.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎dist/purify.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎dist/purify.min.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎src/purify.js

+9-9
Original file line numberDiff line numberDiff line change
@@ -643,6 +643,15 @@ function createDOMPurify(window = getGlobal()) {
643643
allowedTags: ALLOWED_TAGS,
644644
});
645645

646+
/* Take care of an mXSS pattern using p, br inside svg, math */
647+
if (
648+
(tagName === 'svg' || tagName === 'math') &&
649+
currentNode.querySelectorAll('p, br').length !== 0
650+
) {
651+
_forceRemove(currentNode);
652+
return true;
653+
}
654+
646655
/* Detect mXSS attempts abusing namespace confusion */
647656
if (
648657
!_isNode(currentNode.firstElementChild) &&
@@ -840,15 +849,6 @@ function createDOMPurify(window = getGlobal()) {
840849
continue;
841850
}
842851

843-
/* Take care of an mXSS pattern using namespace switches */
844-
if (
845-
regExpTest(/svg|math/i, currentNode.namespaceURI) &&
846-
regExpTest(/<\//, value)
847-
) {
848-
_removeAttribute(name, currentNode);
849-
continue;
850-
}
851-
852852
/* Sanitize attribute content to be template-safe */
853853
if (SAFE_FOR_TEMPLATES) {
854854
value = stringReplace(value, MUSTACHE_EXPR, ' ');

0 commit comments

Comments
 (0)
Please sign in to comment.