dompurify 2.4.7 → 2.4.9

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/README.md CHANGED
@@ -10,7 +10,7 @@ It's also very simple to use and get started with. DOMPurify was [started in Feb
10
10
 
11
11
  DOMPurify is written in JavaScript and works in all modern browsers (Safari (10+), Opera (15+), Internet Explorer (10+), Edge, Firefox and Chrome - as well as almost anything else using Blink or WebKit). It doesn't break on MSIE6 or other legacy browsers. It either uses [a fall-back](#what-about-older-browsers-like-msie8) or simply does nothing.
12
12
 
13
- **Note that DOMPurify v2.4.7 is the latest version supporting MSIE. For important security updates compatible with MSIE, please use the 2.x branch.**
13
+ **Note that DOMPurify v2.4.9 is the latest version supporting MSIE. For important security updates compatible with MSIE, please use the 2.x branch.**
14
14
 
15
15
  Our automated tests cover [19 different browsers](https://github.com/cure53/DOMPurify/blob/main/test/karma.custom-launchers.config.js#L5) right now, more to come. We also cover Node.js v14.x, v16.x, v17.x and v18.x, running DOMPurify on [jsdom](https://github.com/jsdom/jsdom). Older Node versions are known to work as well, but hey... no guarantees.
16
16
 
@@ -1,4 +1,4 @@
1
- /*! @license DOMPurify 2.4.7 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/2.4.7/LICENSE */
1
+ /*! @license DOMPurify 2.4.9 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/2.4.9/LICENSE */
2
2
 
3
3
  'use strict';
4
4
 
@@ -265,6 +265,7 @@ var IS_SCRIPT_OR_DATA = seal(/^(?:\w+script|data):/i);
265
265
  var ATTR_WHITESPACE = seal(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g // eslint-disable-line no-control-regex
266
266
  );
267
267
  var DOCTYPE_NAME = seal(/^html$/i);
268
+ var CUSTOM_ELEMENT = seal(/^[a-z][.\w]*(-[.\w]+)+$/i);
268
269
 
269
270
  var getGlobal = function getGlobal() {
270
271
  return typeof window === 'undefined' ? null : window;
@@ -326,7 +327,7 @@ function createDOMPurify() {
326
327
  */
327
328
 
328
329
 
329
- DOMPurify.version = '2.4.7';
330
+ DOMPurify.version = '2.4.9';
330
331
  /**
331
332
  * Array of elements that DOMPurify removed during sanitation.
332
333
  * Empty if nothing was removed.
@@ -399,7 +400,8 @@ function createDOMPurify() {
399
400
  DATA_ATTR$1 = DATA_ATTR,
400
401
  ARIA_ATTR$1 = ARIA_ATTR,
401
402
  IS_SCRIPT_OR_DATA$1 = IS_SCRIPT_OR_DATA,
402
- ATTR_WHITESPACE$1 = ATTR_WHITESPACE;
403
+ ATTR_WHITESPACE$1 = ATTR_WHITESPACE,
404
+ CUSTOM_ELEMENT$1 = CUSTOM_ELEMENT;
403
405
  var IS_ALLOWED_URI$1 = IS_ALLOWED_URI;
404
406
  /**
405
407
  * We consider the elements and attributes below to be safe. Ideally
@@ -987,7 +989,7 @@ function createDOMPurify() {
987
989
 
988
990
  var _createIterator = function _createIterator(root) {
989
991
  return createNodeIterator.call(root.ownerDocument || root, root, // eslint-disable-next-line no-bitwise
990
- NodeFilter.SHOW_ELEMENT | NodeFilter.SHOW_COMMENT | NodeFilter.SHOW_TEXT, null, false);
992
+ NodeFilter.SHOW_ELEMENT | NodeFilter.SHOW_COMMENT | NodeFilter.SHOW_TEXT | NodeFilter.SHOW_PROCESSING_INSTRUCTION | NodeFilter.SHOW_CDATA_SECTION, null, false);
991
993
  };
992
994
  /**
993
995
  * _isClobbered
@@ -1089,6 +1091,14 @@ function createDOMPurify() {
1089
1091
 
1090
1092
  return true;
1091
1093
  }
1094
+ /* Remove any ocurrence of processing instructions */
1095
+
1096
+
1097
+ if (currentNode.nodeType === 7) {
1098
+ _forceRemove(currentNode);
1099
+
1100
+ return true;
1101
+ }
1092
1102
  /* Remove element if anything forbids its presence */
1093
1103
 
1094
1104
 
@@ -1206,7 +1216,7 @@ function createDOMPurify() {
1206
1216
 
1207
1217
 
1208
1218
  var _basicCustomElementTest = function _basicCustomElementTest(tagName) {
1209
- return tagName.indexOf('-') > 0;
1219
+ return tagName !== 'annotation-xml' && stringMatch(tagName, CUSTOM_ELEMENT$1);
1210
1220
  };
1211
1221
  /**
1212
1222
  * _sanitizeAttributes