dompurify 2.5.3 → 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.es.js CHANGED
@@ -1,4 +1,4 @@
1
- /*! @license DOMPurify 2.5.3 | (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.3/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 _typeof(obj) {
4
4
  "@babel/helpers - typeof";
@@ -110,7 +110,6 @@ var stringIndexOf = unapply(String.prototype.indexOf);
110
110
  var stringTrim = unapply(String.prototype.trim);
111
111
  var regExpTest = unapply(RegExp.prototype.test);
112
112
  var typeErrorCreate = unconstruct(TypeError);
113
- var numberIsNaN = unapply(Number.isNaN);
114
113
  function unapply(func) {
115
114
  return function (thisArg) {
116
115
  for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
@@ -282,7 +281,7 @@ function createDOMPurify() {
282
281
  * Version label, exposed for easier checks
283
282
  * if DOMPurify is up to date or not
284
283
  */
285
- DOMPurify.version = '2.5.3';
284
+ DOMPurify.version = '2.5.5';
286
285
 
287
286
  /**
288
287
  * Array of elements that DOMPurify removed during sanitation.
@@ -508,9 +507,6 @@ function createDOMPurify() {
508
507
  /* Keep a reference to config to pass to hooks */
509
508
  var CONFIG = null;
510
509
 
511
- /* Specify the maximum element nesting depth to prevent mXSS */
512
- var MAX_NESTING_DEPTH = 255;
513
-
514
510
  /* Ideally, do not touch anything below this line */
515
511
  /* ______________________________________________ */
516
512
 
@@ -905,7 +901,7 @@ function createDOMPurify() {
905
901
  * @return {Boolean} true if clobbered, false if safe
906
902
  */
907
903
  var _isClobbered = function _isClobbered(elm) {
908
- 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');
904
+ 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');
909
905
  };
910
906
 
911
907
  /**
@@ -1064,7 +1060,7 @@ function createDOMPurify() {
1064
1060
  // eslint-disable-next-line complexity
1065
1061
  var _isValidAttribute = function _isValidAttribute(lcTag, lcName, value) {
1066
1062
  /* Make sure attribute cannot clobber */
1067
- if (SANITIZE_DOM && (lcName === 'id' || lcName === 'name') && (value in document || value in formElement || value === '__depth' || value === '__removalCount')) {
1063
+ if (SANITIZE_DOM && (lcName === 'id' || lcName === 'name') && (value in document || value in formElement)) {
1068
1064
  return false;
1069
1065
  }
1070
1066
 
@@ -1253,32 +1249,9 @@ function createDOMPurify() {
1253
1249
  if (_sanitizeElements(shadowNode)) {
1254
1250
  continue;
1255
1251
  }
1256
- var parentNode = getParentNode(shadowNode);
1257
-
1258
- /* Set the nesting depth of an element */
1259
- if (shadowNode.nodeType === 1) {
1260
- if (parentNode && parentNode.__depth) {
1261
- /*
1262
- We want the depth of the node in the original tree, which can
1263
- change when it's removed from its parent.
1264
- */
1265
- shadowNode.__depth = (shadowNode.__removalCount || 0) + parentNode.__depth + 1;
1266
- } else {
1267
- shadowNode.__depth = 1;
1268
- }
1269
- }
1270
-
1271
- /*
1272
- * Remove an element if nested too deeply to avoid mXSS
1273
- * or if the __depth might have been tampered with
1274
- */
1275
- if (shadowNode.__depth >= MAX_NESTING_DEPTH || numberIsNaN(shadowNode.__depth)) {
1276
- _forceRemove(shadowNode);
1277
- }
1278
1252
 
1279
1253
  /* Deep shadow DOM detected */
1280
1254
  if (shadowNode.content instanceof DocumentFragment) {
1281
- shadowNode.content.__depth = shadowNode.__depth;
1282
1255
  _sanitizeShadowDOM(shadowNode.content);
1283
1256
  }
1284
1257
 
@@ -1408,32 +1381,9 @@ function createDOMPurify() {
1408
1381
  if (_sanitizeElements(currentNode)) {
1409
1382
  continue;
1410
1383
  }
1411
- var parentNode = getParentNode(currentNode);
1412
-
1413
- /* Set the nesting depth of an element */
1414
- if (currentNode.nodeType === 1) {
1415
- if (parentNode && parentNode.__depth) {
1416
- /*
1417
- We want the depth of the node in the original tree, which can
1418
- change when it's removed from its parent.
1419
- */
1420
- currentNode.__depth = (currentNode.__removalCount || 0) + parentNode.__depth + 1;
1421
- } else {
1422
- currentNode.__depth = 1;
1423
- }
1424
- }
1425
-
1426
- /*
1427
- * Remove an element if nested too deeply to avoid mXSS
1428
- * or if the __depth might have been tampered with
1429
- */
1430
- if (currentNode.__depth >= MAX_NESTING_DEPTH || numberIsNaN(currentNode.__depth)) {
1431
- _forceRemove(currentNode);
1432
- }
1433
1384
 
1434
1385
  /* Shadow DOM detected, sanitize it */
1435
1386
  if (currentNode.content instanceof DocumentFragment) {
1436
- currentNode.content.__depth = currentNode.__depth;
1437
1387
  _sanitizeShadowDOM(currentNode.content);
1438
1388
  }
1439
1389