dompurify 2.5.0 → 2.5.1
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 +2 -2
- package/dist/purify.cjs.js +47 -4
- package/dist/purify.cjs.js.map +1 -1
- package/dist/purify.es.js +47 -4
- package/dist/purify.es.js.map +1 -1
- package/dist/purify.js +47 -4
- 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.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @license DOMPurify 2.5.
|
|
1
|
+
/*! @license DOMPurify 2.5.1 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/2.5.1/LICENSE */
|
|
2
2
|
|
|
3
3
|
(function (global, factory) {
|
|
4
4
|
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
|
|
@@ -287,7 +287,7 @@
|
|
|
287
287
|
* Version label, exposed for easier checks
|
|
288
288
|
* if DOMPurify is up to date or not
|
|
289
289
|
*/
|
|
290
|
-
DOMPurify.version = '2.5.
|
|
290
|
+
DOMPurify.version = '2.5.1';
|
|
291
291
|
|
|
292
292
|
/**
|
|
293
293
|
* Array of elements that DOMPurify removed during sanitation.
|
|
@@ -513,6 +513,9 @@
|
|
|
513
513
|
/* Keep a reference to config to pass to hooks */
|
|
514
514
|
var CONFIG = null;
|
|
515
515
|
|
|
516
|
+
/* Specify the maximum element nesting depth to prevent mXSS */
|
|
517
|
+
var MAX_NESTING_DEPTH = 255;
|
|
518
|
+
|
|
516
519
|
/* Ideally, do not touch anything below this line */
|
|
517
520
|
/* ______________________________________________ */
|
|
518
521
|
|
|
@@ -907,7 +910,7 @@
|
|
|
907
910
|
* @return {Boolean} true if clobbered, false if safe
|
|
908
911
|
*/
|
|
909
912
|
var _isClobbered = function _isClobbered(elm) {
|
|
910
|
-
return elm instanceof HTMLFormElement && (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');
|
|
913
|
+
return elm instanceof HTMLFormElement && (typeof elm.__depth !== 'undefined' && typeof elm.__depth !== 'number' || 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');
|
|
911
914
|
};
|
|
912
915
|
|
|
913
916
|
/**
|
|
@@ -1013,7 +1016,9 @@
|
|
|
1013
1016
|
if (childNodes && parentNode) {
|
|
1014
1017
|
var childCount = childNodes.length;
|
|
1015
1018
|
for (var i = childCount - 1; i >= 0; --i) {
|
|
1016
|
-
|
|
1019
|
+
var childClone = cloneNode(childNodes[i], true);
|
|
1020
|
+
childClone.__removalCount = (currentNode.__removalCount || 0) + 1;
|
|
1021
|
+
parentNode.insertBefore(childClone, getNextSibling(currentNode));
|
|
1017
1022
|
}
|
|
1018
1023
|
}
|
|
1019
1024
|
}
|
|
@@ -1244,8 +1249,27 @@
|
|
|
1244
1249
|
continue;
|
|
1245
1250
|
}
|
|
1246
1251
|
|
|
1252
|
+
/* Set the nesting depth of an element */
|
|
1253
|
+
if (shadowNode.nodeType === 1) {
|
|
1254
|
+
if (shadowNode.parentNode && shadowNode.parentNode.__depth) {
|
|
1255
|
+
/*
|
|
1256
|
+
We want the depth of the node in the original tree, which can
|
|
1257
|
+
change when it's removed from its parent.
|
|
1258
|
+
*/
|
|
1259
|
+
shadowNode.__depth = (shadowNode.__removalCount || 0) + shadowNode.parentNode.__depth + 1;
|
|
1260
|
+
} else {
|
|
1261
|
+
shadowNode.__depth = 1;
|
|
1262
|
+
}
|
|
1263
|
+
}
|
|
1264
|
+
|
|
1265
|
+
/* Remove an element if nested too deeply to avoid mXSS */
|
|
1266
|
+
if (shadowNode.__depth >= MAX_NESTING_DEPTH) {
|
|
1267
|
+
_forceRemove(shadowNode);
|
|
1268
|
+
}
|
|
1269
|
+
|
|
1247
1270
|
/* Deep shadow DOM detected */
|
|
1248
1271
|
if (shadowNode.content instanceof DocumentFragment) {
|
|
1272
|
+
shadowNode.content.__depth = shadowNode.__depth;
|
|
1249
1273
|
_sanitizeShadowDOM(shadowNode.content);
|
|
1250
1274
|
}
|
|
1251
1275
|
|
|
@@ -1376,8 +1400,27 @@
|
|
|
1376
1400
|
continue;
|
|
1377
1401
|
}
|
|
1378
1402
|
|
|
1403
|
+
/* Set the nesting depth of an element */
|
|
1404
|
+
if (currentNode.nodeType === 1) {
|
|
1405
|
+
if (currentNode.parentNode && currentNode.parentNode.__depth) {
|
|
1406
|
+
/*
|
|
1407
|
+
We want the depth of the node in the original tree, which can
|
|
1408
|
+
change when it's removed from its parent.
|
|
1409
|
+
*/
|
|
1410
|
+
currentNode.__depth = (currentNode.__removalCount || 0) + currentNode.parentNode.__depth + 1;
|
|
1411
|
+
} else {
|
|
1412
|
+
currentNode.__depth = 1;
|
|
1413
|
+
}
|
|
1414
|
+
}
|
|
1415
|
+
|
|
1416
|
+
/* Remove an element if nested too deeply to avoid mXSS */
|
|
1417
|
+
if (currentNode.__depth >= MAX_NESTING_DEPTH) {
|
|
1418
|
+
_forceRemove(currentNode);
|
|
1419
|
+
}
|
|
1420
|
+
|
|
1379
1421
|
/* Shadow DOM detected, sanitize it */
|
|
1380
1422
|
if (currentNode.content instanceof DocumentFragment) {
|
|
1423
|
+
currentNode.content.__depth = currentNode.__depth;
|
|
1381
1424
|
_sanitizeShadowDOM(currentNode.content);
|
|
1382
1425
|
}
|
|
1383
1426
|
|