Skip to content

Commit

Permalink
fix: Fixed an issue with comment detection and possible bypasses with…
Browse files Browse the repository at this point in the history
… specific config settings, thanks @masatokinugawa

fix: Removed the foreeignObject element from the lost of HTML entrypoints, thanks @masatokinugawa
chore: Updated build and test dependencies
  • Loading branch information
cure53 committed Sep 26, 2024
1 parent 50ea515 commit 4a9ec1f
Show file tree
Hide file tree
Showing 10 changed files with 55 additions and 58 deletions.
14 changes: 7 additions & 7 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.

14 changes: 7 additions & 7 deletions dist/purify.es.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -720,7 +720,7 @@ function createDOMPurify() {
CONFIG = cfg;
};
const MATHML_TEXT_INTEGRATION_POINTS = addToSet({}, ['mi', 'mo', 'mn', 'ms', 'mtext']);
const HTML_INTEGRATION_POINTS = addToSet({}, ['foreignobject', 'annotation-xml']);
const HTML_INTEGRATION_POINTS = addToSet({}, ['annotation-xml']);

// Certain elements are allowed in both SVG and HTML
// namespace. We need to specify them explicitly
Expand Down Expand Up @@ -1181,12 +1181,6 @@ function createDOMPurify() {
_executeHook('uponSanitizeAttribute', currentNode, hookEvent);
value = hookEvent.attrValue;

/* Work around a security issue with comments inside attributes */
if (SAFE_FOR_XML && regExpTest(/((--!?|])>)|<\/(style|title)/i, value)) {
_removeAttribute(name, currentNode);
continue;
}

/* Did the hooks approve of the attribute? */
if (hookEvent.forceKeepAttr) {
continue;
Expand Down Expand Up @@ -1230,6 +1224,12 @@ function createDOMPurify() {
value = SANITIZE_NAMED_PROPS_PREFIX + value;
}

/* Work around a security issue with comments inside attributes */
if (SAFE_FOR_XML && regExpTest(/((--!?|])>)|<\/(style|title)/i, value)) {
_removeAttribute(name, currentNode);
continue;
}

/* Handle attributes that require Trusted Types */
if (trustedTypesPolicy && typeof trustedTypes === 'object' && typeof trustedTypes.getAttributeType === 'function') {
if (namespaceURI) ; else {
Expand Down
2 changes: 1 addition & 1 deletion dist/purify.es.mjs.map

Large diffs are not rendered by default.

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

44 changes: 22 additions & 22 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 7 additions & 10 deletions src/purify.js
Original file line number Diff line number Diff line change
Expand Up @@ -659,10 +659,7 @@ function createDOMPurify(window = getGlobal()) {
'mtext',
]);

const HTML_INTEGRATION_POINTS = addToSet({}, [
'foreignobject',
'annotation-xml',
]);
const HTML_INTEGRATION_POINTS = addToSet({}, ['annotation-xml']);

// Certain elements are allowed in both SVG and HTML
// namespace. We need to specify them explicitly
Expand Down Expand Up @@ -1282,12 +1279,6 @@ function createDOMPurify(window = getGlobal()) {
_executeHook('uponSanitizeAttribute', currentNode, hookEvent);
value = hookEvent.attrValue;

/* Work around a security issue with comments inside attributes */
if (SAFE_FOR_XML && regExpTest(/((--!?|])>)|<\/(style|title)/i, value)) {
_removeAttribute(name, currentNode);
continue;
}

/* Did the hooks approve of the attribute? */
if (hookEvent.forceKeepAttr) {
continue;
Expand Down Expand Up @@ -1331,6 +1322,12 @@ function createDOMPurify(window = getGlobal()) {
value = SANITIZE_NAMED_PROPS_PREFIX + value;
}

/* Work around a security issue with comments inside attributes */
if (SAFE_FOR_XML && regExpTest(/((--!?|])>)|<\/(style|title)/i, value)) {
_removeAttribute(name, currentNode);
continue;
}

/* Handle attributes that require Trusted Types */
if (
trustedTypesPolicy &&
Expand Down

0 comments on commit 4a9ec1f

Please sign in to comment.