dompurify 3.1.0 → 3.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +17 -8
- package/dist/purify.cjs.js +54 -5
- package/dist/purify.cjs.js.map +1 -1
- package/dist/purify.es.mjs +54 -5
- package/dist/purify.es.mjs.map +1 -1
- package/dist/purify.js +54 -5
- package/dist/purify.js.map +1 -1
- package/dist/purify.min.js +2 -2
- package/dist/purify.min.js.map +1 -1
- package/package.json +1 -1
package/dist/purify.es.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @license DOMPurify 3.1.
|
|
1
|
+
/*! @license DOMPurify 3.1.2 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.1.2/LICENSE */
|
|
2
2
|
|
|
3
3
|
const {
|
|
4
4
|
entries,
|
|
@@ -282,7 +282,7 @@ function createDOMPurify() {
|
|
|
282
282
|
* Version label, exposed for easier checks
|
|
283
283
|
* if DOMPurify is up to date or not
|
|
284
284
|
*/
|
|
285
|
-
DOMPurify.version = '3.1.
|
|
285
|
+
DOMPurify.version = '3.1.2';
|
|
286
286
|
|
|
287
287
|
/**
|
|
288
288
|
* Array of elements that DOMPurify removed during sanitation.
|
|
@@ -515,6 +515,9 @@ function createDOMPurify() {
|
|
|
515
515
|
/* Keep a reference to config to pass to hooks */
|
|
516
516
|
let CONFIG = null;
|
|
517
517
|
|
|
518
|
+
/* Specify the maximum element nesting depth to prevent mXSS */
|
|
519
|
+
const MAX_NESTING_DEPTH = 255;
|
|
520
|
+
|
|
518
521
|
/* Ideally, do not touch anything below this line */
|
|
519
522
|
/* ______________________________________________ */
|
|
520
523
|
|
|
@@ -701,7 +704,7 @@ function createDOMPurify() {
|
|
|
701
704
|
CONFIG = cfg;
|
|
702
705
|
};
|
|
703
706
|
const MATHML_TEXT_INTEGRATION_POINTS = addToSet({}, ['mi', 'mo', 'mn', 'ms', 'mtext']);
|
|
704
|
-
const HTML_INTEGRATION_POINTS = addToSet({}, ['foreignobject', '
|
|
707
|
+
const HTML_INTEGRATION_POINTS = addToSet({}, ['foreignobject', 'annotation-xml']);
|
|
705
708
|
|
|
706
709
|
// Certain elements are allowed in both SVG and HTML
|
|
707
710
|
// namespace. We need to specify them explicitly
|
|
@@ -925,7 +928,11 @@ function createDOMPurify() {
|
|
|
925
928
|
* @return {Boolean} true if clobbered, false if safe
|
|
926
929
|
*/
|
|
927
930
|
const _isClobbered = function _isClobbered(elm) {
|
|
928
|
-
return elm instanceof HTMLFormElement && (
|
|
931
|
+
return elm instanceof HTMLFormElement && (
|
|
932
|
+
// eslint-disable-next-line unicorn/no-typeof-undefined
|
|
933
|
+
typeof elm.__depth !== 'undefined' && typeof elm.__depth !== 'number' ||
|
|
934
|
+
// eslint-disable-next-line unicorn/no-typeof-undefined
|
|
935
|
+
typeof elm.__removalCount !== 'undefined' && typeof elm.__removalCount !== 'number' || typeof elm.nodeName !== 'string' || typeof elm.textContent !== 'string' || typeof elm.removeChild !== 'function' || !(elm.attributes instanceof NamedNodeMap) || typeof elm.removeAttribute !== 'function' || typeof elm.setAttribute !== 'function' || typeof elm.namespaceURI !== 'string' || typeof elm.insertBefore !== 'function' || typeof elm.hasChildNodes !== 'function');
|
|
929
936
|
};
|
|
930
937
|
|
|
931
938
|
/**
|
|
@@ -1023,7 +1030,9 @@ function createDOMPurify() {
|
|
|
1023
1030
|
if (childNodes && parentNode) {
|
|
1024
1031
|
const childCount = childNodes.length;
|
|
1025
1032
|
for (let i = childCount - 1; i >= 0; --i) {
|
|
1026
|
-
|
|
1033
|
+
const childClone = cloneNode(childNodes[i], true);
|
|
1034
|
+
childClone.__removalCount = (currentNode.__removalCount || 0) + 1;
|
|
1035
|
+
parentNode.insertBefore(childClone, getNextSibling(currentNode));
|
|
1027
1036
|
}
|
|
1028
1037
|
}
|
|
1029
1038
|
}
|
|
@@ -1255,9 +1264,29 @@ function createDOMPurify() {
|
|
|
1255
1264
|
if (_sanitizeElements(shadowNode)) {
|
|
1256
1265
|
continue;
|
|
1257
1266
|
}
|
|
1267
|
+
const parentNode = getParentNode(shadowNode);
|
|
1268
|
+
|
|
1269
|
+
/* Set the nesting depth of an element */
|
|
1270
|
+
if (shadowNode.nodeType === 1) {
|
|
1271
|
+
if (parentNode && parentNode.__depth) {
|
|
1272
|
+
/*
|
|
1273
|
+
We want the depth of the node in the original tree, which can
|
|
1274
|
+
change when it's removed from its parent.
|
|
1275
|
+
*/
|
|
1276
|
+
shadowNode.__depth = (shadowNode.__removalCount || 0) + parentNode.__depth + 1;
|
|
1277
|
+
} else {
|
|
1278
|
+
shadowNode.__depth = 1;
|
|
1279
|
+
}
|
|
1280
|
+
}
|
|
1281
|
+
|
|
1282
|
+
/* Remove an element if nested too deeply to avoid mXSS */
|
|
1283
|
+
if (shadowNode.__depth >= MAX_NESTING_DEPTH) {
|
|
1284
|
+
_forceRemove(shadowNode);
|
|
1285
|
+
}
|
|
1258
1286
|
|
|
1259
1287
|
/* Deep shadow DOM detected */
|
|
1260
1288
|
if (shadowNode.content instanceof DocumentFragment) {
|
|
1289
|
+
shadowNode.content.__depth = shadowNode.__depth;
|
|
1261
1290
|
_sanitizeShadowDOM(shadowNode.content);
|
|
1262
1291
|
}
|
|
1263
1292
|
|
|
@@ -1373,9 +1402,29 @@ function createDOMPurify() {
|
|
|
1373
1402
|
if (_sanitizeElements(currentNode)) {
|
|
1374
1403
|
continue;
|
|
1375
1404
|
}
|
|
1405
|
+
const parentNode = getParentNode(currentNode);
|
|
1406
|
+
|
|
1407
|
+
/* Set the nesting depth of an element */
|
|
1408
|
+
if (currentNode.nodeType === 1) {
|
|
1409
|
+
if (parentNode && parentNode.__depth) {
|
|
1410
|
+
/*
|
|
1411
|
+
We want the depth of the node in the original tree, which can
|
|
1412
|
+
change when it's removed from its parent.
|
|
1413
|
+
*/
|
|
1414
|
+
currentNode.__depth = (currentNode.__removalCount || 0) + parentNode.__depth + 1;
|
|
1415
|
+
} else {
|
|
1416
|
+
currentNode.__depth = 1;
|
|
1417
|
+
}
|
|
1418
|
+
}
|
|
1419
|
+
|
|
1420
|
+
/* Remove an element if nested too deeply to avoid mXSS */
|
|
1421
|
+
if (currentNode.__depth >= MAX_NESTING_DEPTH) {
|
|
1422
|
+
_forceRemove(currentNode);
|
|
1423
|
+
}
|
|
1376
1424
|
|
|
1377
1425
|
/* Shadow DOM detected, sanitize it */
|
|
1378
1426
|
if (currentNode.content instanceof DocumentFragment) {
|
|
1427
|
+
currentNode.content.__depth = currentNode.__depth;
|
|
1379
1428
|
_sanitizeShadowDOM(currentNode.content);
|
|
1380
1429
|
}
|
|
1381
1430
|
|