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.
@@ -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
  const {
4
4
  entries,
@@ -209,11 +209,9 @@ const DATA_ATTR = seal(/^data-[\-\w.\u00B7-\uFFFF]/); // eslint-disable-line no-
209
209
  const ARIA_ATTR = seal(/^aria-[\-\w]+$/); // eslint-disable-line no-useless-escape
210
210
  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
211
211
  );
212
-
213
212
  const IS_SCRIPT_OR_DATA = seal(/^(?:\w+script|data):/i);
214
213
  const ATTR_WHITESPACE = seal(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g // eslint-disable-line no-control-regex
215
214
  );
216
-
217
215
  const DOCTYPE_NAME = seal(/^html$/i);
218
216
  const CUSTOM_ELEMENT = seal(/^[a-z][.\w]*(-[.\w]+)+$/i);
219
217
 
@@ -248,7 +246,6 @@ const NODE_TYPE = {
248
246
  documentFragment: 11,
249
247
  notation: 12 // Deprecated
250
248
  };
251
-
252
249
  const getGlobal = function getGlobal() {
253
250
  return typeof window === 'undefined' ? null : window;
254
251
  };
@@ -300,7 +297,7 @@ function createDOMPurify() {
300
297
  * Version label, exposed for easier checks
301
298
  * if DOMPurify is up to date or not
302
299
  */
303
- DOMPurify.version = '3.1.5';
300
+ DOMPurify.version = '3.1.6';
304
301
 
305
302
  /**
306
303
  * Array of elements that DOMPurify removed during sanitation.
@@ -331,6 +328,7 @@ function createDOMPurify() {
331
328
  } = window;
332
329
  const ElementPrototype = Element.prototype;
333
330
  const cloneNode = lookupGetter(ElementPrototype, 'cloneNode');
331
+ const remove = lookupGetter(ElementPrototype, 'remove');
334
332
  const getNextSibling = lookupGetter(ElementPrototype, 'nextSibling');
335
333
  const getChildNodes = lookupGetter(ElementPrototype, 'childNodes');
336
334
  const getParentNode = lookupGetter(ElementPrototype, 'parentNode');
@@ -831,9 +829,9 @@ function createDOMPurify() {
831
829
  });
832
830
  try {
833
831
  // eslint-disable-next-line unicorn/prefer-dom-node-remove
834
- node.parentNode.removeChild(node);
832
+ getParentNode(node).removeChild(node);
835
833
  } catch (_) {
836
- node.remove();
834
+ remove(node);
837
835
  }
838
836
  };
839
837
 
@@ -1010,7 +1008,7 @@ function createDOMPurify() {
1010
1008
  return true;
1011
1009
  }
1012
1010
 
1013
- /* Remove any ocurrence of processing instructions */
1011
+ /* Remove any occurrence of processing instructions */
1014
1012
  if (currentNode.nodeType === NODE_TYPE.progressingInstruction) {
1015
1013
  _forceRemove(currentNode);
1016
1014
  return true;
@@ -1179,6 +1177,13 @@ function createDOMPurify() {
1179
1177
  hookEvent.forceKeepAttr = undefined; // Allows developers to see this is a property they can set
1180
1178
  _executeHook('uponSanitizeAttribute', currentNode, hookEvent);
1181
1179
  value = hookEvent.attrValue;
1180
+
1181
+ /* Work around a security issue with comments inside attributes */
1182
+ if (SAFE_FOR_XML && regExpTest(/((--!?|])>)|<\/(style|title)/i, value)) {
1183
+ _removeAttribute(name, currentNode);
1184
+ continue;
1185
+ }
1186
+
1182
1187
  /* Did the hooks approve of the attribute? */
1183
1188
  if (hookEvent.forceKeepAttr) {
1184
1189
  continue;
@@ -1198,12 +1203,6 @@ function createDOMPurify() {
1198
1203
  continue;
1199
1204
  }
1200
1205
 
1201
- /* Work around a security issue with comments inside attributes */
1202
- if (SAFE_FOR_XML && regExpTest(/((--!?|])>)|<\/(style|title)/i, value)) {
1203
- _removeAttribute(name, currentNode);
1204
- continue;
1205
- }
1206
-
1207
1206
  /* Sanitize attribute content to be template-safe */
1208
1207
  if (SAFE_FOR_TEMPLATES) {
1209
1208
  arrayForEach([MUSTACHE_EXPR, ERB_EXPR, TMPLIT_EXPR], expr => {