dompurify 3.3.0 → 3.3.2

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/dist/purify.js CHANGED
@@ -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.2 | (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.2/LICENSE */
2
2
 
3
3
  (function (global, factory) {
4
4
  typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
@@ -311,7 +311,7 @@
311
311
  function createDOMPurify() {
312
312
  let window = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : getGlobal();
313
313
  const DOMPurify = root => createDOMPurify(root);
314
- DOMPurify.version = '3.3.0';
314
+ DOMPurify.version = '3.3.2';
315
315
  DOMPurify.removed = [];
316
316
  if (!window || !window.document || window.document.nodeType !== NODE_TYPE.document || !window.Element) {
317
317
  // Not running in a browser, provide a factory function
@@ -606,7 +606,7 @@
606
606
  /* Parse profile info */
607
607
  if (USE_PROFILES) {
608
608
  ALLOWED_TAGS = addToSet({}, text);
609
- ALLOWED_ATTR = [];
609
+ ALLOWED_ATTR = create(null);
610
610
  if (USE_PROFILES.html === true) {
611
611
  addToSet(ALLOWED_TAGS, html$1);
612
612
  addToSet(ALLOWED_ATTR, html);
@@ -627,6 +627,13 @@
627
627
  addToSet(ALLOWED_ATTR, xml);
628
628
  }
629
629
  }
630
+ /* Prevent function-based ADD_ATTR / ADD_TAGS from leaking across calls */
631
+ if (!objectHasOwnProperty(cfg, 'ADD_TAGS')) {
632
+ EXTRA_ELEMENT_HANDLING.tagCheck = null;
633
+ }
634
+ if (!objectHasOwnProperty(cfg, 'ADD_ATTR')) {
635
+ EXTRA_ELEMENT_HANDLING.attributeCheck = null;
636
+ }
630
637
  /* Merge configuration parameters */
631
638
  if (cfg.ADD_TAGS) {
632
639
  if (typeof cfg.ADD_TAGS === 'function') {
@@ -657,6 +664,12 @@
657
664
  }
658
665
  addToSet(FORBID_CONTENTS, cfg.FORBID_CONTENTS, transformCaseFunc);
659
666
  }
667
+ if (cfg.ADD_FORBID_CONTENTS) {
668
+ if (FORBID_CONTENTS === DEFAULT_FORBID_CONTENTS) {
669
+ FORBID_CONTENTS = clone(FORBID_CONTENTS);
670
+ }
671
+ addToSet(FORBID_CONTENTS, cfg.ADD_FORBID_CONTENTS, transformCaseFunc);
672
+ }
660
673
  /* Add #text in case KEEP_CONTENT is set to true */
661
674
  if (KEEP_CONTENT) {
662
675
  ALLOWED_TAGS['#text'] = true;
@@ -1018,6 +1031,10 @@
1018
1031
  */
1019
1032
  // eslint-disable-next-line complexity
1020
1033
  const _isValidAttribute = function _isValidAttribute(lcTag, lcName, value) {
1034
+ /* FORBID_ATTR must always win, even if ADD_ATTR predicate would allow it */
1035
+ if (FORBID_ATTR[lcName]) {
1036
+ return false;
1037
+ }
1021
1038
  /* Make sure attribute cannot clobber */
1022
1039
  if (SANITIZE_DOM && (lcName === 'id' || lcName === 'name') && (value in document || value in formElement)) {
1023
1040
  return false;
@@ -1110,7 +1127,7 @@
1110
1127
  value = SANITIZE_NAMED_PROPS_PREFIX + value;
1111
1128
  }
1112
1129
  /* Work around a security issue with comments inside attributes */
1113
- if (SAFE_FOR_XML && regExpTest(/((--!?|])>)|<\/(style|title|textarea)/i, value)) {
1130
+ if (SAFE_FOR_XML && regExpTest(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i, value)) {
1114
1131
  _removeAttribute(name, currentNode);
1115
1132
  continue;
1116
1133
  }