dompurify 2.5.2 → 2.5.3

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.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 */
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 */
2
2
 
3
3
  (function (global, factory) {
4
4
  typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
@@ -116,6 +116,7 @@
116
116
  var stringTrim = unapply(String.prototype.trim);
117
117
  var regExpTest = unapply(RegExp.prototype.test);
118
118
  var typeErrorCreate = unconstruct(TypeError);
119
+ var numberIsNaN = unapply(Number.isNaN);
119
120
  function unapply(func) {
120
121
  return function (thisArg) {
121
122
  for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
@@ -287,7 +288,7 @@
287
288
  * Version label, exposed for easier checks
288
289
  * if DOMPurify is up to date or not
289
290
  */
290
- DOMPurify.version = '2.5.2';
291
+ DOMPurify.version = '2.5.3';
291
292
 
292
293
  /**
293
294
  * Array of elements that DOMPurify removed during sanitation.
@@ -1069,7 +1070,7 @@
1069
1070
  // eslint-disable-next-line complexity
1070
1071
  var _isValidAttribute = function _isValidAttribute(lcTag, lcName, value) {
1071
1072
  /* Make sure attribute cannot clobber */
1072
- if (SANITIZE_DOM && (lcName === 'id' || lcName === 'name') && (value in document || value in formElement)) {
1073
+ if (SANITIZE_DOM && (lcName === 'id' || lcName === 'name') && (value in document || value in formElement || value === '__depth' || value === '__removalCount')) {
1073
1074
  return false;
1074
1075
  }
1075
1076
 
@@ -1171,6 +1172,12 @@
1171
1172
  continue;
1172
1173
  }
1173
1174
 
1175
+ /* Work around a security issue with comments inside attributes */
1176
+ if (SAFE_FOR_XML && regExpTest(/((--!?|])>)|<\/(style|title)/i, value)) {
1177
+ _removeAttribute(name, currentNode);
1178
+ continue;
1179
+ }
1180
+
1174
1181
  /* Sanitize attribute content to be template-safe */
1175
1182
  if (SAFE_FOR_TEMPLATES) {
1176
1183
  value = stringReplace(value, MUSTACHE_EXPR$1, ' ');
@@ -1221,7 +1228,11 @@
1221
1228
  /* Fallback to setAttribute() for browser-unrecognized namespaces e.g. "x-schema". */
1222
1229
  currentNode.setAttribute(name, value);
1223
1230
  }
1224
- arrayPop(DOMPurify.removed);
1231
+ if (_isClobbered(currentNode)) {
1232
+ _forceRemove(currentNode);
1233
+ } else {
1234
+ arrayPop(DOMPurify.removed);
1235
+ }
1225
1236
  } catch (_) {}
1226
1237
  }
1227
1238
 
@@ -1263,8 +1274,11 @@
1263
1274
  }
1264
1275
  }
1265
1276
 
1266
- /* Remove an element if nested too deeply to avoid mXSS */
1267
- if (shadowNode.__depth >= MAX_NESTING_DEPTH) {
1277
+ /*
1278
+ * Remove an element if nested too deeply to avoid mXSS
1279
+ * or if the __depth might have been tampered with
1280
+ */
1281
+ if (shadowNode.__depth >= MAX_NESTING_DEPTH || numberIsNaN(shadowNode.__depth)) {
1268
1282
  _forceRemove(shadowNode);
1269
1283
  }
1270
1284
 
@@ -1415,8 +1429,11 @@
1415
1429
  }
1416
1430
  }
1417
1431
 
1418
- /* Remove an element if nested too deeply to avoid mXSS */
1419
- if (currentNode.__depth >= MAX_NESTING_DEPTH) {
1432
+ /*
1433
+ * Remove an element if nested too deeply to avoid mXSS
1434
+ * or if the __depth might have been tampered with
1435
+ */
1436
+ if (currentNode.__depth >= MAX_NESTING_DEPTH || numberIsNaN(currentNode.__depth)) {
1420
1437
  _forceRemove(currentNode);
1421
1438
  }
1422
1439