dompurify 2.5.0 → 2.5.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 +2 -2
- package/dist/purify.cjs.js +50 -5
- package/dist/purify.cjs.js.map +1 -1
- package/dist/purify.es.js +50 -5
- package/dist/purify.es.js.map +1 -1
- package/dist/purify.js +50 -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.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @license DOMPurify 2.5.
|
|
1
|
+
/*! @license DOMPurify 2.5.2 | (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.2/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.2';
|
|
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
|
|
|
@@ -674,7 +677,7 @@
|
|
|
674
677
|
CONFIG = cfg;
|
|
675
678
|
};
|
|
676
679
|
var MATHML_TEXT_INTEGRATION_POINTS = addToSet({}, ['mi', 'mo', 'mn', 'ms', 'mtext']);
|
|
677
|
-
var HTML_INTEGRATION_POINTS = addToSet({}, ['foreignobject', '
|
|
680
|
+
var HTML_INTEGRATION_POINTS = addToSet({}, ['foreignobject', 'annotation-xml']);
|
|
678
681
|
|
|
679
682
|
// Certain elements are allowed in both SVG and HTML
|
|
680
683
|
// namespace. We need to specify them explicitly
|
|
@@ -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
|
}
|
|
@@ -1243,9 +1248,29 @@
|
|
|
1243
1248
|
if (_sanitizeElements(shadowNode)) {
|
|
1244
1249
|
continue;
|
|
1245
1250
|
}
|
|
1251
|
+
var parentNode = getParentNode(shadowNode);
|
|
1252
|
+
|
|
1253
|
+
/* Set the nesting depth of an element */
|
|
1254
|
+
if (shadowNode.nodeType === 1) {
|
|
1255
|
+
if (parentNode && parentNode.__depth) {
|
|
1256
|
+
/*
|
|
1257
|
+
We want the depth of the node in the original tree, which can
|
|
1258
|
+
change when it's removed from its parent.
|
|
1259
|
+
*/
|
|
1260
|
+
shadowNode.__depth = (shadowNode.__removalCount || 0) + parentNode.__depth + 1;
|
|
1261
|
+
} else {
|
|
1262
|
+
shadowNode.__depth = 1;
|
|
1263
|
+
}
|
|
1264
|
+
}
|
|
1265
|
+
|
|
1266
|
+
/* Remove an element if nested too deeply to avoid mXSS */
|
|
1267
|
+
if (shadowNode.__depth >= MAX_NESTING_DEPTH) {
|
|
1268
|
+
_forceRemove(shadowNode);
|
|
1269
|
+
}
|
|
1246
1270
|
|
|
1247
1271
|
/* Deep shadow DOM detected */
|
|
1248
1272
|
if (shadowNode.content instanceof DocumentFragment) {
|
|
1273
|
+
shadowNode.content.__depth = shadowNode.__depth;
|
|
1249
1274
|
_sanitizeShadowDOM(shadowNode.content);
|
|
1250
1275
|
}
|
|
1251
1276
|
|
|
@@ -1375,9 +1400,29 @@
|
|
|
1375
1400
|
if (_sanitizeElements(currentNode)) {
|
|
1376
1401
|
continue;
|
|
1377
1402
|
}
|
|
1403
|
+
var parentNode = getParentNode(currentNode);
|
|
1404
|
+
|
|
1405
|
+
/* Set the nesting depth of an element */
|
|
1406
|
+
if (currentNode.nodeType === 1) {
|
|
1407
|
+
if (parentNode && parentNode.__depth) {
|
|
1408
|
+
/*
|
|
1409
|
+
We want the depth of the node in the original tree, which can
|
|
1410
|
+
change when it's removed from its parent.
|
|
1411
|
+
*/
|
|
1412
|
+
currentNode.__depth = (currentNode.__removalCount || 0) + parentNode.__depth + 1;
|
|
1413
|
+
} else {
|
|
1414
|
+
currentNode.__depth = 1;
|
|
1415
|
+
}
|
|
1416
|
+
}
|
|
1417
|
+
|
|
1418
|
+
/* Remove an element if nested too deeply to avoid mXSS */
|
|
1419
|
+
if (currentNode.__depth >= MAX_NESTING_DEPTH) {
|
|
1420
|
+
_forceRemove(currentNode);
|
|
1421
|
+
}
|
|
1378
1422
|
|
|
1379
1423
|
/* Shadow DOM detected, sanitize it */
|
|
1380
1424
|
if (currentNode.content instanceof DocumentFragment) {
|
|
1425
|
+
currentNode.content.__depth = currentNode.__depth;
|
|
1381
1426
|
_sanitizeShadowDOM(currentNode.content);
|
|
1382
1427
|
}
|
|
1383
1428
|
|