dompurify 3.1.5 → 3.1.6

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 3.1.5 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.1.5/LICENSE */
1
+ /*! @license DOMPurify 3.1.6 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.1.6/LICENSE */
2
2
 
3
3
  (function (global, factory) {
4
4
  typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
@@ -215,11 +215,9 @@
215
215
  const ARIA_ATTR = seal(/^aria-[\-\w]+$/); // eslint-disable-line no-useless-escape
216
216
  const IS_ALLOWED_URI = seal(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i // eslint-disable-line no-useless-escape
217
217
  );
218
-
219
218
  const IS_SCRIPT_OR_DATA = seal(/^(?:\w+script|data):/i);
220
219
  const ATTR_WHITESPACE = seal(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g // eslint-disable-line no-control-regex
221
220
  );
222
-
223
221
  const DOCTYPE_NAME = seal(/^html$/i);
224
222
  const CUSTOM_ELEMENT = seal(/^[a-z][.\w]*(-[.\w]+)+$/i);
225
223
 
@@ -254,7 +252,6 @@
254
252
  documentFragment: 11,
255
253
  notation: 12 // Deprecated
256
254
  };
257
-
258
255
  const getGlobal = function getGlobal() {
259
256
  return typeof window === 'undefined' ? null : window;
260
257
  };
@@ -306,7 +303,7 @@
306
303
  * Version label, exposed for easier checks
307
304
  * if DOMPurify is up to date or not
308
305
  */
309
- DOMPurify.version = '3.1.5';
306
+ DOMPurify.version = '3.1.6';
310
307
 
311
308
  /**
312
309
  * Array of elements that DOMPurify removed during sanitation.
@@ -337,6 +334,7 @@
337
334
  } = window;
338
335
  const ElementPrototype = Element.prototype;
339
336
  const cloneNode = lookupGetter(ElementPrototype, 'cloneNode');
337
+ const remove = lookupGetter(ElementPrototype, 'remove');
340
338
  const getNextSibling = lookupGetter(ElementPrototype, 'nextSibling');
341
339
  const getChildNodes = lookupGetter(ElementPrototype, 'childNodes');
342
340
  const getParentNode = lookupGetter(ElementPrototype, 'parentNode');
@@ -837,9 +835,9 @@
837
835
  });
838
836
  try {
839
837
  // eslint-disable-next-line unicorn/prefer-dom-node-remove
840
- node.parentNode.removeChild(node);
838
+ getParentNode(node).removeChild(node);
841
839
  } catch (_) {
842
- node.remove();
840
+ remove(node);
843
841
  }
844
842
  };
845
843
 
@@ -1016,7 +1014,7 @@
1016
1014
  return true;
1017
1015
  }
1018
1016
 
1019
- /* Remove any ocurrence of processing instructions */
1017
+ /* Remove any occurrence of processing instructions */
1020
1018
  if (currentNode.nodeType === NODE_TYPE.progressingInstruction) {
1021
1019
  _forceRemove(currentNode);
1022
1020
  return true;
@@ -1185,6 +1183,13 @@
1185
1183
  hookEvent.forceKeepAttr = undefined; // Allows developers to see this is a property they can set
1186
1184
  _executeHook('uponSanitizeAttribute', currentNode, hookEvent);
1187
1185
  value = hookEvent.attrValue;
1186
+
1187
+ /* Work around a security issue with comments inside attributes */
1188
+ if (SAFE_FOR_XML && regExpTest(/((--!?|])>)|<\/(style|title)/i, value)) {
1189
+ _removeAttribute(name, currentNode);
1190
+ continue;
1191
+ }
1192
+
1188
1193
  /* Did the hooks approve of the attribute? */
1189
1194
  if (hookEvent.forceKeepAttr) {
1190
1195
  continue;
@@ -1204,12 +1209,6 @@
1204
1209
  continue;
1205
1210
  }
1206
1211
 
1207
- /* Work around a security issue with comments inside attributes */
1208
- if (SAFE_FOR_XML && regExpTest(/((--!?|])>)|<\/(style|title)/i, value)) {
1209
- _removeAttribute(name, currentNode);
1210
- continue;
1211
- }
1212
-
1213
1212
  /* Sanitize attribute content to be template-safe */
1214
1213
  if (SAFE_FOR_TEMPLATES) {
1215
1214
  arrayForEach([MUSTACHE_EXPR, ERB_EXPR, TMPLIT_EXPR], expr => {