dompurify 2.5.4 → 2.5.5

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/dist/purify.js CHANGED
@@ -1,4 +1,4 @@
1
- /*! @license DOMPurify 2.5.4 | (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.4/LICENSE */
1
+ /*! @license DOMPurify 2.5.5 | (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.5/LICENSE */
2
2
 
3
3
  (function (global, factory) {
4
4
  typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
@@ -116,10 +116,6 @@
116
116
  var stringTrim = unapply(String.prototype.trim);
117
117
  var regExpTest = unapply(RegExp.prototype.test);
118
118
  var typeErrorCreate = unconstruct(TypeError);
119
- function numberIsNaN(x) {
120
- // eslint-disable-next-line unicorn/prefer-number-properties
121
- return typeof x === 'number' && isNaN(x);
122
- }
123
119
  function unapply(func) {
124
120
  return function (thisArg) {
125
121
  for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
@@ -291,7 +287,7 @@
291
287
  * Version label, exposed for easier checks
292
288
  * if DOMPurify is up to date or not
293
289
  */
294
- DOMPurify.version = '2.5.4';
290
+ DOMPurify.version = '2.5.5';
295
291
 
296
292
  /**
297
293
  * Array of elements that DOMPurify removed during sanitation.
@@ -517,9 +513,6 @@
517
513
  /* Keep a reference to config to pass to hooks */
518
514
  var CONFIG = null;
519
515
 
520
- /* Specify the maximum element nesting depth to prevent mXSS */
521
- var MAX_NESTING_DEPTH = 255;
522
-
523
516
  /* Ideally, do not touch anything below this line */
524
517
  /* ______________________________________________ */
525
518
 
@@ -914,7 +907,7 @@
914
907
  * @return {Boolean} true if clobbered, false if safe
915
908
  */
916
909
  var _isClobbered = function _isClobbered(elm) {
917
- 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');
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');
918
911
  };
919
912
 
920
913
  /**
@@ -1073,7 +1066,7 @@
1073
1066
  // eslint-disable-next-line complexity
1074
1067
  var _isValidAttribute = function _isValidAttribute(lcTag, lcName, value) {
1075
1068
  /* Make sure attribute cannot clobber */
1076
- if (SANITIZE_DOM && (lcName === 'id' || lcName === 'name') && (value in document || value in formElement || value === '__depth' || value === '__removalCount')) {
1069
+ if (SANITIZE_DOM && (lcName === 'id' || lcName === 'name') && (value in document || value in formElement)) {
1077
1070
  return false;
1078
1071
  }
1079
1072
 
@@ -1262,32 +1255,9 @@
1262
1255
  if (_sanitizeElements(shadowNode)) {
1263
1256
  continue;
1264
1257
  }
1265
- var parentNode = getParentNode(shadowNode);
1266
-
1267
- /* Set the nesting depth of an element */
1268
- if (shadowNode.nodeType === 1) {
1269
- if (parentNode && parentNode.__depth) {
1270
- /*
1271
- We want the depth of the node in the original tree, which can
1272
- change when it's removed from its parent.
1273
- */
1274
- shadowNode.__depth = (shadowNode.__removalCount || 0) + parentNode.__depth + 1;
1275
- } else {
1276
- shadowNode.__depth = 1;
1277
- }
1278
- }
1279
-
1280
- /*
1281
- * Remove an element if nested too deeply to avoid mXSS
1282
- * or if the __depth might have been tampered with
1283
- */
1284
- if (shadowNode.__depth >= MAX_NESTING_DEPTH || numberIsNaN(shadowNode.__depth)) {
1285
- _forceRemove(shadowNode);
1286
- }
1287
1258
 
1288
1259
  /* Deep shadow DOM detected */
1289
1260
  if (shadowNode.content instanceof DocumentFragment) {
1290
- shadowNode.content.__depth = shadowNode.__depth;
1291
1261
  _sanitizeShadowDOM(shadowNode.content);
1292
1262
  }
1293
1263
 
@@ -1417,32 +1387,9 @@
1417
1387
  if (_sanitizeElements(currentNode)) {
1418
1388
  continue;
1419
1389
  }
1420
- var parentNode = getParentNode(currentNode);
1421
-
1422
- /* Set the nesting depth of an element */
1423
- if (currentNode.nodeType === 1) {
1424
- if (parentNode && parentNode.__depth) {
1425
- /*
1426
- We want the depth of the node in the original tree, which can
1427
- change when it's removed from its parent.
1428
- */
1429
- currentNode.__depth = (currentNode.__removalCount || 0) + parentNode.__depth + 1;
1430
- } else {
1431
- currentNode.__depth = 1;
1432
- }
1433
- }
1434
-
1435
- /*
1436
- * Remove an element if nested too deeply to avoid mXSS
1437
- * or if the __depth might have been tampered with
1438
- */
1439
- if (currentNode.__depth >= MAX_NESTING_DEPTH || numberIsNaN(currentNode.__depth)) {
1440
- _forceRemove(currentNode);
1441
- }
1442
1390
 
1443
1391
  /* Shadow DOM detected, sanitize it */
1444
1392
  if (currentNode.content instanceof DocumentFragment) {
1445
- currentNode.content.__depth = currentNode.__depth;
1446
1393
  _sanitizeShadowDOM(currentNode.content);
1447
1394
  }
1448
1395