dompurify 3.3.0 → 3.3.1

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
@@ -4,7 +4,7 @@
4
4
 
5
5
  DOMPurify is a DOM-only, super-fast, uber-tolerant XSS sanitizer for HTML, MathML and SVG.
6
6
 
7
- 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 **v3.3.0**.
7
+ 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 **v3.3.1**.
8
8
 
9
9
  DOMPurify is written in JavaScript and works in all modern browsers (Safari (10+), Opera (15+), Edge, Firefox and Chrome - as well as almost anything else using Blink, Gecko or WebKit). It doesn't break on MSIE or other legacy browsers. It simply does nothing.
10
10
 
@@ -368,6 +368,9 @@ const clean = DOMPurify.sanitize(dirty, {FORCE_BODY: true});
368
368
  // remove all <a> elements under <p> elements that are removed
369
369
  const clean = DOMPurify.sanitize(dirty, {FORBID_CONTENTS: ['a'], FORBID_TAGS: ['p']});
370
370
 
371
+ // extend the default FORBID_CONTENTS list to also remove <a> elements under <p> elements
372
+ const clean = DOMPurify.sanitize(dirty, {ADD_FORBID_CONTENTS: ['a'], FORBID_TAGS: ['p']});
373
+
371
374
  // change the parser type so sanitized data is treated as XML and not as HTML, which is the default
372
375
  const clean = DOMPurify.sanitize(dirty, {PARSER_MEDIA_TYPE: 'application/xhtml+xml'});
373
376
  ```
@@ -1,6 +1,6 @@
1
- /*! @license DOMPurify 3.3.0 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.3.0/LICENSE */
1
+ /*! @license DOMPurify 3.3.1 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.3.1/LICENSE */
2
2
 
3
- import { TrustedTypePolicy, TrustedHTML, TrustedTypesWindow } from 'trusted-types/lib';
3
+ import { TrustedTypePolicy, TrustedHTML, TrustedTypesWindow } from 'trusted-types/lib/index.js';
4
4
 
5
5
  /**
6
6
  * Configuration to control DOMPurify behavior.
@@ -94,6 +94,10 @@ interface Config {
94
94
  * Add child elements to be removed when their parent is removed.
95
95
  */
96
96
  FORBID_CONTENTS?: string[] | undefined;
97
+ /**
98
+ * Extend the existing or default array of forbidden content elements.
99
+ */
100
+ ADD_FORBID_CONTENTS?: string[] | undefined;
97
101
  /**
98
102
  * Add elements to block-list.
99
103
  */
@@ -1,4 +1,4 @@
1
- /*! @license DOMPurify 3.3.0 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.3.0/LICENSE */
1
+ /*! @license DOMPurify 3.3.1 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.3.1/LICENSE */
2
2
 
3
3
  'use strict';
4
4
 
@@ -307,7 +307,7 @@ const _createHooksMap = function _createHooksMap() {
307
307
  function createDOMPurify() {
308
308
  let window = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : getGlobal();
309
309
  const DOMPurify = root => createDOMPurify(root);
310
- DOMPurify.version = '3.3.0';
310
+ DOMPurify.version = '3.3.1';
311
311
  DOMPurify.removed = [];
312
312
  if (!window || !window.document || window.document.nodeType !== NODE_TYPE.document || !window.Element) {
313
313
  // Not running in a browser, provide a factory function
@@ -653,6 +653,12 @@ function createDOMPurify() {
653
653
  }
654
654
  addToSet(FORBID_CONTENTS, cfg.FORBID_CONTENTS, transformCaseFunc);
655
655
  }
656
+ if (cfg.ADD_FORBID_CONTENTS) {
657
+ if (FORBID_CONTENTS === DEFAULT_FORBID_CONTENTS) {
658
+ FORBID_CONTENTS = clone(FORBID_CONTENTS);
659
+ }
660
+ addToSet(FORBID_CONTENTS, cfg.ADD_FORBID_CONTENTS, transformCaseFunc);
661
+ }
656
662
  /* Add #text in case KEEP_CONTENT is set to true */
657
663
  if (KEEP_CONTENT) {
658
664
  ALLOWED_TAGS['#text'] = true;