dompurify 2.0.14 → 2.1.0

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
@@ -6,11 +6,11 @@
6
6
 
7
7
  DOMPurify is a DOM-only, super-fast, uber-tolerant XSS sanitizer for HTML, MathML and SVG.
8
8
 
9
- It's also very simple to use and get started with. DOMPurify was [started in February 2014](https://github.com/cure53/DOMPurify/commit/a630922616927373485e0e787ab19e73e3691b2b) and, meanwhile, has reached version 2.0.14.
9
+ It's also very simple to use and get started with. DOMPurify was [started in February 2014](https://github.com/cure53/DOMPurify/commit/a630922616927373485e0e787ab19e73e3691b2b) and, meanwhile, has reached version 2.1.0.
10
10
 
11
11
  DOMPurify is written in JavaScript and works in all modern browsers (Safari, 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
- Our automated tests cover [26 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 v12.0.0 and v13.0.0, running DOMPurify on [jsdom](https://github.com/tmpvar/jsdom). Older Node.js versions are known to work as well.
13
+ Our automated tests cover [15 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 v12.0.0 and v13.0.0, running DOMPurify on [jsdom](https://github.com/tmpvar/jsdom). Older Node.js versions are known to work as well.
14
14
 
15
15
  DOMPurify is written by security people who have vast background in web attacks and XSS. Fear not. For more details please also read about our [Security Goals & Threat Model](https://github.com/cure53/DOMPurify/wiki/Security-Goals-&-Threat-Model). Please, read it. Like, really.
16
16
 
@@ -40,7 +40,7 @@ Afterwards you can sanitize strings by executing the following code:
40
40
  var clean = DOMPurify.sanitize(dirty);
41
41
  ```
42
42
 
43
- The resulting HTML can be written into a DOM element using `innerHTML` or the DOM using `document.write()`. That is fully up to you. But keep in mind, if you use the sanitized HTML with jQuery's very insecure `elm.html()` method, then the `SAFE_FOR_JQUERY` flag has to be set to make sure it's safe! Other than that, all is fine.
43
+ The resulting HTML can be written into a DOM element using `innerHTML` or the DOM using `document.write()`. That is fully up to you.
44
44
 
45
45
  ### Is there any foot-gun potential?
46
46
 
@@ -115,7 +115,7 @@ DOMPurify.sanitize('<UL><li><A HREF=//google.com>click</UL>'); // becomes <ul><l
115
115
 
116
116
  ## What is supported?
117
117
 
118
- DOMPurify currently supports HTML5, SVG and MathML. DOMPurify per default allows CSS, HTML custom data attributes. DOMPurify also supports the Shadow DOM - and sanitizes DOM templates recursively. DOMPurify also allows you to sanitize HTML for being used with the jQuery `$()` and `elm.html()` methods but requires the `SAFE_FOR_JQUERY` flag for that - see below.
118
+ DOMPurify currently supports HTML5, SVG and MathML. DOMPurify per default allows CSS, HTML custom data attributes. DOMPurify also supports the Shadow DOM - and sanitizes DOM templates recursively. DOMPurify also allows you to sanitize HTML for being used with the jQuery `$()` and `elm.html()` API without any known problems.
119
119
 
120
120
  ## What about older browsers like MSIE8?
121
121
 
@@ -137,8 +137,9 @@ When `DOMPurify.sanitize` is used in an environment where the Trusted Types API
137
137
  Yes. The included default configuration values are pretty good already - but you can of course override them. Check out the [`/demos`](https://github.com/cure53/DOMPurify/tree/main/demos) folder to see a bunch of examples on how you can [customize DOMPurify](https://github.com/cure53/DOMPurify/tree/main/demos#what-is-this).
138
138
 
139
139
  ```js
140
- // make output safe for usage in jQuery's $()/html() method (default is false)
141
- var clean = DOMPurify.sanitize(dirty, {SAFE_FOR_JQUERY: true});
140
+ /**
141
+ * General settings
142
+ */
142
143
 
143
144
  // strip {{ ... }} and <% ... %> to make output safe for template systems
144
145
  // be careful please, this mode is not recommended for production usage.
@@ -146,48 +147,63 @@ var clean = DOMPurify.sanitize(dirty, {SAFE_FOR_JQUERY: true});
146
147
  // only use this mode if there is really no alternative.
147
148
  var clean = DOMPurify.sanitize(dirty, {SAFE_FOR_TEMPLATES: true});
148
149
 
149
- // allow only <b>
150
+ /**
151
+ * Control our allow-lists and block-lists
152
+ */
153
+ // allow only <b> elements, very strict
150
154
  var clean = DOMPurify.sanitize(dirty, {ALLOWED_TAGS: ['b']});
151
155
 
152
- // allow only <b> and <q> with style attributes (for whatever reason)
156
+ // allow only <b> and <q> with style attributes
153
157
  var clean = DOMPurify.sanitize(dirty, {ALLOWED_TAGS: ['b', 'q'], ALLOWED_ATTR: ['style']});
154
158
 
155
159
  // allow all safe HTML elements but neither SVG nor MathML
156
160
  var clean = DOMPurify.sanitize(dirty, {USE_PROFILES: {html: true}});
157
161
 
158
- // allow all safe SVG elements and SVG Filters
162
+ // allow all safe SVG elements and SVG Filters, no HTML or MathML
159
163
  var clean = DOMPurify.sanitize(dirty, {USE_PROFILES: {svg: true, svgFilters: true}});
160
164
 
161
- // allow all safe MathML elements and SVG
165
+ // allow all safe MathML elements and SVG, but no SVG Filters
162
166
  var clean = DOMPurify.sanitize(dirty, {USE_PROFILES: {mathMl: true, svg: true}});
163
167
 
164
- // leave all as it is but forbid <style>
168
+ // leave all safe HTML as it is and add <style> elements to block-list
165
169
  var clean = DOMPurify.sanitize(dirty, {FORBID_TAGS: ['style']});
166
170
 
167
- // leave all as it is but forbid style attributes
171
+ // leave all safe HTML as it is and add style attributes to block-list
168
172
  var clean = DOMPurify.sanitize(dirty, {FORBID_ATTR: ['style']});
169
173
 
170
- // extend the existing array of allowed tags
174
+ // extend the existing array of allowed tags and add <my-tag> to allow-list
171
175
  var clean = DOMPurify.sanitize(dirty, {ADD_TAGS: ['my-tag']});
172
176
 
173
- // extend the existing array of attributes
177
+ // extend the existing array of allowed attributes and add my-attr to allow-list
174
178
  var clean = DOMPurify.sanitize(dirty, {ADD_ATTR: ['my-attr']});
175
179
 
176
- // extend the existing array of tags that can use Data URIs
180
+ // prohibit HTML5 data attributes, leave other safe HTML as is (default is true)
181
+ var clean = DOMPurify.sanitize(dirty, {ALLOW_DATA_ATTR: false});
182
+
183
+ /**
184
+ * Control behavior relating to URI values
185
+ */
186
+ // extend the existing array of elements that can use Data URIs
177
187
  var clean = DOMPurify.sanitize(dirty, {ADD_DATA_URI_TAGS: ['a', 'area']});
178
188
 
179
- // prohibit HTML5 data attributes (default is true)
180
- var clean = DOMPurify.sanitize(dirty, {ALLOW_DATA_ATTR: false});
189
+ // extend the existing array of elements that are safe for URI-like values (be careful, XSS risk)
190
+ var clean = DOMPurify.sanitize(dirty, {ADD_URI_SAFE_ATTR: ['my-attr']});
181
191
 
182
- // allow external protocol handlers in URL attributes (default is false)
192
+ /**
193
+ * Control permitted attribute values
194
+ */
195
+ // allow external protocol handlers in URL attributes (default is false, be careful, XSS risk)
183
196
  // by default only http, https, ftp, ftps, tel, mailto, callto, cid and xmpp are allowed.
184
197
  var clean = DOMPurify.sanitize(dirty, {ALLOW_UNKNOWN_PROTOCOLS: true});
185
198
 
186
- // allow specific protocols handlers in URL attributes (default is false)
199
+ // allow specific protocols handlers in URL attributes via regex (default is false, be careful, XSS risk)
187
200
  // by default only http, https, ftp, ftps, tel, mailto, callto, cid and xmpp are allowed.
188
201
  // Default RegExp: /^(?:(?:(?:f|ht)tps?|mailto|tel|callto|cid|xmpp):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i;
189
202
  var clean = DOMPurify.sanitize(dirty, {ALLOWED_URI_REGEXP: /^(?:(?:(?:f|ht)tps?|mailto|tel|callto|cid|xmpp|xxx):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i;});
190
203
 
204
+ /**
205
+ * Influence the return-type
206
+ */
191
207
  // return a DOM HTMLBodyElement instead of an HTML string (default is false)
192
208
  var clean = DOMPurify.sanitize(dirty, {RETURN_DOM: true});
193
209
 
@@ -204,18 +220,24 @@ document.body.appendChild(clean);
204
220
  // use the RETURN_TRUSTED_TYPE flag to turn on Trusted Types support if available
205
221
  var clean = DOMPurify.sanitize(dirty, {RETURN_TRUSTED_TYPE: true}); // will return a TrustedHTML object instead of a string if possible
206
222
 
223
+ /**
224
+ * Influence how we sanitize
225
+ */
207
226
  // return entire document including <html> tags (default is false)
208
227
  var clean = DOMPurify.sanitize(dirty, {WHOLE_DOCUMENT: true});
209
228
 
210
- // disable DOM Clobbering protection on output (default is true, handle with care!)
229
+ // disable DOM Clobbering protection on output (default is true, handle with care, minor XSS risks here)
211
230
  var clean = DOMPurify.sanitize(dirty, {SANITIZE_DOM: false});
212
231
 
213
- // keep an element's content when the element is removed (default is true)
232
+ // keep an element's content when the element is removed (default is true, careful, minor XSS risks here)
214
233
  var clean = DOMPurify.sanitize(dirty, {KEEP_CONTENT: false});
215
234
 
216
235
  // glue elements like style, script or others to document.body and prevent unintuitive browser behavior in several edge-cases (default is false)
217
236
  var clean = DOMPurify.sanitize(dirty, {FORCE_BODY: true});
218
237
 
238
+ /**
239
+ * Influence where we sanitize
240
+ */
219
241
  // use the IN_PLACE mode to sanitize a node "in place", which is much faster depending on how you use DOMPurify
220
242
  var dirty = document.createElement('a');
221
243
  dirty.setAttribute('href', 'javascript:alert(1)');
@@ -304,7 +326,7 @@ Feature releases will not be announced to this list.
304
326
 
305
327
  Many people helped and help DOMPurify become what it is and need to be acknowledged here!
306
328
 
307
- [oreoshake 💸](https://github.com/oreoshake), [dcramer 💸](https://github.com/dcramer),[tdeekens ❤️](https://github.com/tdeekens), [neilj](https://github.com/neilj), [fhemberger](https://github.com/fhemberger), [Joris-van-der-Wel](https://github.com/Joris-van-der-Wel), [ydaniv](https://github.com/ydaniv), [filedescriptor](https://github.com/filedescriptor), [ConradIrwin](https://github.com/ConradIrwin), [gibson042](https://github.com/gibson042), [choumx](https://github.com/choumx), [0xSobky](https://github.com/0xSobky), [styfle](https://github.com/styfle), [koto](https://github.com/koto), [tlau88](https://github.com/tlau88), [strugee](https://github.com/strugee), [oparoz](https://github.com/oparoz), [mathiasbynens](https://github.com/mathiasbynens), [edg2s](https://github.com/edg2s), [dnkolegov](https://github.com/dnkolegov), [dhardtke](https://github.com/dhardtke), [wirehead](https://github.com/wirehead), [thorn0](https://github.com/thorn0), [styu](https://github.com/styu), [mozfreddyb](https://github.com/mozfreddyb), [mikesamuel](https://github.com/mikesamuel), [jorangreef](https://github.com/jorangreef), [jimmyhchan](https://github.com/jimmyhchan), [jameydeorio](https://github.com/jameydeorio), [jameskraus](https://github.com/jameskraus), [hyderali](https://github.com/hyderali), [hansottowirtz](https://github.com/hansottowirtz), [hackvertor](https://github.com/hackvertor), [freddyb](https://github.com/freddyb), [flavorjones](https://github.com/flavorjones), [djfarrelly](https://github.com/djfarrelly), [devd](https://github.com/devd), [camerondunford](https://github.com/camerondunford), [buu700](https://github.com/buu700), [buildog](https://github.com/buildog), [alabiaga](https://github.com/alabiaga), [Vector919](https://github.com/Vector919), [Robbert](https://github.com/Robbert), [GreLI](https://github.com/GreLI), [FuzzySockets](https://github.com/FuzzySockets), [ArtemBernatskyy](https://github.com/ArtemBernatskyy), [@garethheyes](https://twitter.com/garethheyes), [@filedescriptor](https://twitter.com/filedescriptor), [@shafigullin](https://twitter.com/shafigullin), [@mmrupp](https://twitter.com/mmrupp), [@irsdl](https://twitter.com/irsdl),[ShikariSenpai](https://github.com/ShikariSenpai), [ansjdnakjdnajkd](https://github.com/ansjdnakjdnajkd), [@asutherland](https://twitter.com/asutherland), [@mathias](https://twitter.com/mathias), [@cgvwzq](https://twitter.com/cgvwzq), [@robbertatwork](https://twitter.com/robbertatwork), [@giutro](https://twitter.com/giutro) and especially [@masatokinugawa](https://twitter.com/masatokinugawa)
329
+ [oreoshake 💸](https://github.com/oreoshake), [dcramer 💸](https://github.com/dcramer),[tdeekens ❤️](https://github.com/tdeekens), [peernohell ❤️](https://github.com/peernohell), [neilj](https://github.com/neilj), [fhemberger](https://github.com/fhemberger), [Joris-van-der-Wel](https://github.com/Joris-van-der-Wel), [ydaniv](https://github.com/ydaniv), [filedescriptor](https://github.com/filedescriptor), [ConradIrwin](https://github.com/ConradIrwin), [gibson042](https://github.com/gibson042), [choumx](https://github.com/choumx), [0xSobky](https://github.com/0xSobky), [styfle](https://github.com/styfle), [koto](https://github.com/koto), [tlau88](https://github.com/tlau88), [strugee](https://github.com/strugee), [oparoz](https://github.com/oparoz), [mathiasbynens](https://github.com/mathiasbynens), [edg2s](https://github.com/edg2s), [dnkolegov](https://github.com/dnkolegov), [dhardtke](https://github.com/dhardtke), [wirehead](https://github.com/wirehead), [thorn0](https://github.com/thorn0), [styu](https://github.com/styu), [mozfreddyb](https://github.com/mozfreddyb), [mikesamuel](https://github.com/mikesamuel), [jorangreef](https://github.com/jorangreef), [jimmyhchan](https://github.com/jimmyhchan), [jameydeorio](https://github.com/jameydeorio), [jameskraus](https://github.com/jameskraus), [hyderali](https://github.com/hyderali), [hansottowirtz](https://github.com/hansottowirtz), [hackvertor](https://github.com/hackvertor), [freddyb](https://github.com/freddyb), [flavorjones](https://github.com/flavorjones), [djfarrelly](https://github.com/djfarrelly), [devd](https://github.com/devd), [camerondunford](https://github.com/camerondunford), [buu700](https://github.com/buu700), [buildog](https://github.com/buildog), [alabiaga](https://github.com/alabiaga), [Vector919](https://github.com/Vector919), [Robbert](https://github.com/Robbert), [GreLI](https://github.com/GreLI), [FuzzySockets](https://github.com/FuzzySockets), [ArtemBernatskyy](https://github.com/ArtemBernatskyy), [@garethheyes](https://twitter.com/garethheyes), [@filedescriptor](https://twitter.com/filedescriptor), [@shafigullin](https://twitter.com/shafigullin), [@mmrupp](https://twitter.com/mmrupp), [@irsdl](https://twitter.com/irsdl),[ShikariSenpai](https://github.com/ShikariSenpai), [ansjdnakjdnajkd](https://github.com/ansjdnakjdnajkd), [@asutherland](https://twitter.com/asutherland), [@mathias](https://twitter.com/mathias), [@cgvwzq](https://twitter.com/cgvwzq), [@robbertatwork](https://twitter.com/robbertatwork), [@giutro](https://twitter.com/giutro) and especially [@masatokinugawa](https://twitter.com/masatokinugawa)
308
330
 
309
331
  ## Testing powered by
310
332
  <a target="_blank" href="https://www.browserstack.com/"><img width="200" src="https://www.browserstack.com/images/layout/browserstack-logo-600x315.png"></a><br>
@@ -6,8 +6,7 @@ function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr
6
6
 
7
7
  var hasOwnProperty = Object.hasOwnProperty,
8
8
  setPrototypeOf = Object.setPrototypeOf,
9
- isFrozen = Object.isFrozen,
10
- objectKeys = Object.keys;
9
+ isFrozen = Object.isFrozen;
11
10
  var freeze = Object.freeze,
12
11
  seal = Object.seal,
13
12
  create = Object.create; // eslint-disable-line import/no-mutable-exports
@@ -42,7 +41,6 @@ if (!construct) {
42
41
 
43
42
  var arrayForEach = unapply(Array.prototype.forEach);
44
43
  var arrayIndexOf = unapply(Array.prototype.indexOf);
45
- var arrayJoin = unapply(Array.prototype.join);
46
44
  var arrayPop = unapply(Array.prototype.pop);
47
45
  var arrayPush = unapply(Array.prototype.push);
48
46
  var arraySlice = unapply(Array.prototype.slice);
@@ -54,7 +52,6 @@ var stringIndexOf = unapply(String.prototype.indexOf);
54
52
  var stringTrim = unapply(String.prototype.trim);
55
53
 
56
54
  var regExpTest = unapply(RegExp.prototype.test);
57
- var regExpCreate = unconstruct(RegExp);
58
55
 
59
56
  var typeErrorCreate = unconstruct(TypeError);
60
57
 
@@ -149,7 +146,7 @@ var ARIA_ATTR = seal(/^aria-[\-\w]+$/); // eslint-disable-line no-useless-escape
149
146
  var IS_ALLOWED_URI = seal(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|cid|xmpp):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i // eslint-disable-line no-useless-escape
150
147
  );
151
148
  var IS_SCRIPT_OR_DATA = seal(/^(?:\w+script|data):/i);
152
- var ATTR_WHITESPACE = seal(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205f\u3000]/g // eslint-disable-line no-control-regex
149
+ var ATTR_WHITESPACE = seal(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g // eslint-disable-line no-control-regex
153
150
  );
154
151
 
155
152
  var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
@@ -210,7 +207,7 @@ function createDOMPurify() {
210
207
  * Version label, exposed for easier checks
211
208
  * if DOMPurify is up to date or not
212
209
  */
213
- DOMPurify.version = '2.0.14';
210
+ DOMPurify.version = '2.1.0';
214
211
 
215
212
  /**
216
213
  * Array of elements that DOMPurify removed during sanitation.
@@ -266,7 +263,10 @@ function createDOMPurify() {
266
263
  var importNode = originalDocument.importNode;
267
264
 
268
265
 
269
- var documentMode = clone(document).documentMode ? document.documentMode : {};
266
+ var documentMode = {};
267
+ try {
268
+ documentMode = clone(document).documentMode ? document.documentMode : {};
269
+ } catch (_) {}
270
270
 
271
271
  var hooks = {};
272
272
 
@@ -312,9 +312,6 @@ function createDOMPurify() {
312
312
  /* Decide if unknown protocols are okay */
313
313
  var ALLOW_UNKNOWN_PROTOCOLS = false;
314
314
 
315
- /* Output should be safe for jQuery's $() factory? */
316
- var SAFE_FOR_JQUERY = false;
317
-
318
315
  /* Output should be safe for common template engines.
319
316
  * This means, DOMPurify removes data attributes, mustaches and ERB
320
317
  */
@@ -346,7 +343,7 @@ function createDOMPurify() {
346
343
  * DOMPurify. */
347
344
  var RETURN_DOM_IMPORT = false;
348
345
 
349
- /* Try to return a Trusted Type object instead of a string, retrun a string in
346
+ /* Try to return a Trusted Type object instead of a string, return a string in
350
347
  * case Trusted Types are not supported */
351
348
  var RETURN_TRUSTED_TYPE = false;
352
349
 
@@ -412,7 +409,6 @@ function createDOMPurify() {
412
409
  ALLOW_ARIA_ATTR = cfg.ALLOW_ARIA_ATTR !== false; // Default true
413
410
  ALLOW_DATA_ATTR = cfg.ALLOW_DATA_ATTR !== false; // Default true
414
411
  ALLOW_UNKNOWN_PROTOCOLS = cfg.ALLOW_UNKNOWN_PROTOCOLS || false; // Default false
415
- SAFE_FOR_JQUERY = cfg.SAFE_FOR_JQUERY || false; // Default false
416
412
  SAFE_FOR_TEMPLATES = cfg.SAFE_FOR_TEMPLATES || false; // Default false
417
413
  WHOLE_DOCUMENT = cfg.WHOLE_DOCUMENT || false; // Default false
418
414
  RETURN_DOM = cfg.RETURN_DOM || false; // Default false
@@ -514,7 +510,6 @@ function createDOMPurify() {
514
510
  var _forceRemove = function _forceRemove(node) {
515
511
  arrayPush(DOMPurify.removed, { element: node });
516
512
  try {
517
- // eslint-disable-next-line unicorn/prefer-node-remove
518
513
  node.parentNode.removeChild(node);
519
514
  } catch (_) {
520
515
  node.outerHTML = emptyHTML;
@@ -671,7 +666,6 @@ function createDOMPurify() {
671
666
  * @param {Node} currentNode to check for permission to exist
672
667
  * @return {Boolean} true if node was killed, false if left alive
673
668
  */
674
- // eslint-disable-next-line complexity
675
669
  var _sanitizeElements = function _sanitizeElements(currentNode) {
676
670
  var content = void 0;
677
671
 
@@ -699,8 +693,8 @@ function createDOMPurify() {
699
693
  allowedTags: ALLOWED_TAGS
700
694
  });
701
695
 
702
- /* Take care of an mXSS pattern using p, br inside svg, math */
703
- if ((tagName === 'svg' || tagName === 'math') && currentNode.querySelectorAll('p, br').length !== 0) {
696
+ /* Detect mXSS attempts abusing namespace confusion */
697
+ if (!_isNode(currentNode.firstElementChild) && (!_isNode(currentNode.content) || !_isNode(currentNode.content.firstElementChild)) && regExpTest(/<[!/\w]/g, currentNode.innerHTML) && regExpTest(/<[!/\w]/g, currentNode.textContent)) {
704
698
  _forceRemove(currentNode);
705
699
  return true;
706
700
  }
@@ -720,26 +714,11 @@ function createDOMPurify() {
720
714
  }
721
715
 
722
716
  /* Remove in case a noscript/noembed XSS is suspected */
723
- if (tagName === 'noscript' && regExpTest(/<\/noscript/i, currentNode.innerHTML)) {
724
- _forceRemove(currentNode);
725
- return true;
726
- }
727
-
728
- if (tagName === 'noembed' && regExpTest(/<\/noembed/i, currentNode.innerHTML)) {
717
+ if ((tagName === 'noscript' || tagName === 'noembed') && regExpTest(/<\/no(script|embed)/i, currentNode.innerHTML)) {
729
718
  _forceRemove(currentNode);
730
719
  return true;
731
720
  }
732
721
 
733
- /* Convert markup to cover jQuery behavior */
734
- if (SAFE_FOR_JQUERY && !currentNode.firstElementChild && (!currentNode.content || !currentNode.content.firstElementChild) && regExpTest(/</g, currentNode.textContent)) {
735
- arrayPush(DOMPurify.removed, { element: currentNode.cloneNode() });
736
- if (currentNode.innerHTML) {
737
- currentNode.innerHTML = stringReplace(currentNode.innerHTML, /</g, '&lt;');
738
- } else {
739
- currentNode.innerHTML = stringReplace(currentNode.textContent, /</g, '&lt;');
740
- }
741
- }
742
-
743
722
  /* Sanitize element content to be template-safe */
744
723
  if (SAFE_FOR_TEMPLATES && currentNode.nodeType === 3) {
745
724
  /* Get the element's text content */
@@ -798,7 +777,6 @@ function createDOMPurify() {
798
777
  *
799
778
  * @param {Node} currentNode to sanitize
800
779
  */
801
- // eslint-disable-next-line complexity
802
780
  var _sanitizeAttributes = function _sanitizeAttributes(currentNode) {
803
781
  var attr = void 0;
804
782
  var value = void 0;
@@ -880,13 +858,7 @@ function createDOMPurify() {
880
858
  }
881
859
 
882
860
  /* Work around a security issue in jQuery 3.0 */
883
- if (SAFE_FOR_JQUERY && regExpTest(/\/>/i, value)) {
884
- _removeAttribute(name, currentNode);
885
- continue;
886
- }
887
-
888
- /* Take care of an mXSS pattern using namespace switches */
889
- if (regExpTest(/svg|math/i, currentNode.namespaceURI) && regExpTest(regExpCreate('</(' + arrayJoin(objectKeys(FORBID_CONTENTS), '|') + ')', 'i'), value)) {
861
+ if (regExpTest(/\/>/i, value)) {
890
862
  _removeAttribute(name, currentNode);
891
863
  continue;
892
864
  }