dompurify 3.3.1 → 3.3.3

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.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 */
1
+ /*! @license DOMPurify 3.3.3 | (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.3/LICENSE */
2
2
 
3
3
  import { TrustedTypePolicy, TrustedHTML, TrustedTypesWindow } from 'trusted-types/lib/index.js';
4
4
 
@@ -1,4 +1,4 @@
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 */
1
+ /*! @license DOMPurify 3.3.3 | (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.3/LICENSE */
2
2
 
3
3
  const {
4
4
  entries,
@@ -305,7 +305,7 @@ const _createHooksMap = function _createHooksMap() {
305
305
  function createDOMPurify() {
306
306
  let window = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : getGlobal();
307
307
  const DOMPurify = root => createDOMPurify(root);
308
- DOMPurify.version = '3.3.1';
308
+ DOMPurify.version = '3.3.3';
309
309
  DOMPurify.removed = [];
310
310
  if (!window || !window.document || window.document.nodeType !== NODE_TYPE.document || !window.Element) {
311
311
  // Not running in a browser, provide a factory function
@@ -600,7 +600,7 @@ function createDOMPurify() {
600
600
  /* Parse profile info */
601
601
  if (USE_PROFILES) {
602
602
  ALLOWED_TAGS = addToSet({}, text);
603
- ALLOWED_ATTR = [];
603
+ ALLOWED_ATTR = create(null);
604
604
  if (USE_PROFILES.html === true) {
605
605
  addToSet(ALLOWED_TAGS, html$1);
606
606
  addToSet(ALLOWED_ATTR, html);
@@ -621,6 +621,13 @@ function createDOMPurify() {
621
621
  addToSet(ALLOWED_ATTR, xml);
622
622
  }
623
623
  }
624
+ /* Prevent function-based ADD_ATTR / ADD_TAGS from leaking across calls */
625
+ if (!objectHasOwnProperty(cfg, 'ADD_TAGS')) {
626
+ EXTRA_ELEMENT_HANDLING.tagCheck = null;
627
+ }
628
+ if (!objectHasOwnProperty(cfg, 'ADD_ATTR')) {
629
+ EXTRA_ELEMENT_HANDLING.attributeCheck = null;
630
+ }
624
631
  /* Merge configuration parameters */
625
632
  if (cfg.ADD_TAGS) {
626
633
  if (typeof cfg.ADD_TAGS === 'function') {
@@ -1018,6 +1025,10 @@ function createDOMPurify() {
1018
1025
  */
1019
1026
  // eslint-disable-next-line complexity
1020
1027
  const _isValidAttribute = function _isValidAttribute(lcTag, lcName, value) {
1028
+ /* FORBID_ATTR must always win, even if ADD_ATTR predicate would allow it */
1029
+ if (FORBID_ATTR[lcName]) {
1030
+ return false;
1031
+ }
1021
1032
  /* Make sure attribute cannot clobber */
1022
1033
  if (SANITIZE_DOM && (lcName === 'id' || lcName === 'name') && (value in document || value in formElement)) {
1023
1034
  return false;
@@ -1110,7 +1121,7 @@ function createDOMPurify() {
1110
1121
  value = SANITIZE_NAMED_PROPS_PREFIX + value;
1111
1122
  }
1112
1123
  /* Work around a security issue with comments inside attributes */
1113
- if (SAFE_FOR_XML && regExpTest(/((--!?|])>)|<\/(style|title|textarea)/i, value)) {
1124
+ if (SAFE_FOR_XML && regExpTest(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i, value)) {
1114
1125
  _removeAttribute(name, currentNode);
1115
1126
  continue;
1116
1127
  }