Skip to content

Commit

Permalink
Moved commonSvgAndHTMLElements out so _checkValidNamespace doesn't re…
Browse files Browse the repository at this point in the history
…-created in every call
  • Loading branch information
tiny-ben-tran committed May 11, 2022
1 parent 23ff095 commit 73f2168
Show file tree
Hide file tree
Showing 9 changed files with 47 additions and 47 deletions.
20 changes: 10 additions & 10 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.

20 changes: 10 additions & 10 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.

20 changes: 10 additions & 10 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.

24 changes: 12 additions & 12 deletions src/purify.js
Original file line number Diff line number Diff line change
Expand Up @@ -560,6 +560,18 @@ function createDOMPurify(window = getGlobal()) {
'annotation-xml',
]);

// Certain elements are allowed in both SVG and HTML
// namespace. We need to specify them explicitly
// so that they don't get erroneously deleted from
// HTML namespace.
const commonSvgAndHTMLElements = addToSet({}, [
'title',
'style',
'font',
'a',
'script',
]);

/* Keep track of all possible SVG and MathML tags
* so that we can perform the namespace checks
* correctly. */
Expand Down Expand Up @@ -654,18 +666,6 @@ function createDOMPurify(window = getGlobal()) {
return false;
}

// Certain elements are allowed in both SVG and HTML
// namespace. We need to specify them explicitly
// so that they don't get erroneously deleted from
// HTML namespace.
const commonSvgAndHTMLElements = addToSet({}, [
'title',
'style',
'font',
'a',
'script',
]);

// We disallow tags that are specific for MathML
// or SVG and should never appear in HTML namespace
return (
Expand Down

0 comments on commit 73f2168

Please sign in to comment.