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.es.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 _typeof(obj) {
4
4
  "@babel/helpers - typeof";
@@ -110,6 +110,7 @@ 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);
113
114
  function unapply(func) {
114
115
  return function (thisArg) {
115
116
  for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
@@ -281,7 +282,7 @@ function createDOMPurify() {
281
282
  * Version label, exposed for easier checks
282
283
  * if DOMPurify is up to date or not
283
284
  */
284
- DOMPurify.version = '2.5.2';
285
+ DOMPurify.version = '2.5.3';
285
286
 
286
287
  /**
287
288
  * Array of elements that DOMPurify removed during sanitation.
@@ -1063,7 +1064,7 @@ function createDOMPurify() {
1063
1064
  // eslint-disable-next-line complexity
1064
1065
  var _isValidAttribute = function _isValidAttribute(lcTag, lcName, value) {
1065
1066
  /* Make sure attribute cannot clobber */
1066
- if (SANITIZE_DOM && (lcName === 'id' || lcName === 'name') && (value in document || value in formElement)) {
1067
+ if (SANITIZE_DOM && (lcName === 'id' || lcName === 'name') && (value in document || value in formElement || value === '__depth' || value === '__removalCount')) {
1067
1068
  return false;
1068
1069
  }
1069
1070
 
@@ -1165,6 +1166,12 @@ function createDOMPurify() {
1165
1166
  continue;
1166
1167
  }
1167
1168
 
1169
+ /* Work around a security issue with comments inside attributes */
1170
+ if (SAFE_FOR_XML && regExpTest(/((--!?|])>)|<\/(style|title)/i, value)) {
1171
+ _removeAttribute(name, currentNode);
1172
+ continue;
1173
+ }
1174
+
1168
1175
  /* Sanitize attribute content to be template-safe */
1169
1176
  if (SAFE_FOR_TEMPLATES) {
1170
1177
  value = stringReplace(value, MUSTACHE_EXPR$1, ' ');
@@ -1215,7 +1222,11 @@ function createDOMPurify() {
1215
1222
  /* Fallback to setAttribute() for browser-unrecognized namespaces e.g. "x-schema". */
1216
1223
  currentNode.setAttribute(name, value);
1217
1224
  }
1218
- arrayPop(DOMPurify.removed);
1225
+ if (_isClobbered(currentNode)) {
1226
+ _forceRemove(currentNode);
1227
+ } else {
1228
+ arrayPop(DOMPurify.removed);
1229
+ }
1219
1230
  } catch (_) {}
1220
1231
  }
1221
1232
 
@@ -1257,8 +1268,11 @@ function createDOMPurify() {
1257
1268
  }
1258
1269
  }
1259
1270
 
1260
- /* Remove an element if nested too deeply to avoid mXSS */
1261
- if (shadowNode.__depth >= MAX_NESTING_DEPTH) {
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)) {
1262
1276
  _forceRemove(shadowNode);
1263
1277
  }
1264
1278
 
@@ -1409,8 +1423,11 @@ function createDOMPurify() {
1409
1423
  }
1410
1424
  }
1411
1425
 
1412
- /* Remove an element if nested too deeply to avoid mXSS */
1413
- if (currentNode.__depth >= MAX_NESTING_DEPTH) {
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)) {
1414
1431
  _forceRemove(currentNode);
1415
1432
  }
1416
1433