@inboxsdk/core 2.1.29 → 2.1.30

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/inboxsdk.js CHANGED
@@ -785,6 +785,36 @@ const get = function get(map, key) {
785
785
 
786
786
  /***/ }),
787
787
 
788
+ /***/ 9865:
789
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
790
+
791
+ "use strict";
792
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
793
+ /* harmony export */ "Z": () => (/* binding */ htmlToText)
794
+ /* harmony export */ });
795
+ /* harmony import */ var dompurify__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(7856);
796
+ /* harmony import */ var dompurify__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(dompurify__WEBPACK_IMPORTED_MODULE_0__);
797
+
798
+ const escapeHTMLPolicy = globalThis.trustedTypes?.createPolicy('inboxSdkEscapePolicy', {
799
+ createHTML: string => (0,dompurify__WEBPACK_IMPORTED_MODULE_0__.sanitize)(string)
800
+ }) ?? {
801
+ createHTML(string) {
802
+ return (0,dompurify__WEBPACK_IMPORTED_MODULE_0__.sanitize)(string);
803
+ }
804
+ };
805
+
806
+ /**
807
+ * Quick function for converting HTML with entities into text without
808
+ * introducing an XSS vulnerability.
809
+ */
810
+ function htmlToText(html) {
811
+ const div = document.createElement('div');
812
+ div.innerHTML = escapeHTMLPolicy.createHTML(html);
813
+ return div.textContent;
814
+ }
815
+
816
+ /***/ }),
817
+
788
818
  /***/ 3567:
789
819
  /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
790
820
 
@@ -814,7 +844,7 @@ function isElementVisible(el) {
814
844
 
815
845
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment -- SDK_VERSION is injected by webpack
816
846
  ///@ts-ignore
817
- const BUILD_VERSION = "2.1.29-1707947517546-0a2f60e3e3450a0e";
847
+ const BUILD_VERSION = "2.1.30-1708002196801-3d13f4ec423fe68f";
818
848
  if (false) {}
819
849
 
820
850
  /***/ }),
@@ -1776,7 +1806,8 @@ const GmailElementGetter = {
1776
1806
  /* harmony import */ var lodash_last__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(lodash_last__WEBPACK_IMPORTED_MODULE_1__);
1777
1807
  /* harmony import */ var transducers_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(1095);
1778
1808
  /* harmony import */ var transducers_js__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(transducers_js__WEBPACK_IMPORTED_MODULE_2__);
1779
- /* harmony import */ var _common_assert__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(9817);
1809
+ /* harmony import */ var _common_html_to_text__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(9865);
1810
+ /* harmony import */ var _common_assert__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(9817);
1780
1811
 
1781
1812
 
1782
1813
 
@@ -10529,7 +10560,7 @@ options.insert = htmlElement => {
10529
10560
  htmlElement.setAttribute('data-inboxsdk-version',
10530
10561
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment -- this is injected by webpack
10531
10562
  ///@ts-ignore
10532
- "2.1.29-1707947517546-0a2f60e3e3450a0e");
10563
+ "2.1.30-1708002196801-3d13f4ec423fe68f");
10533
10564
  document.head.append(htmlElement);
10534
10565
  };
10535
10566
  options.domAPI = (styleDomAPI_default());
@@ -11671,7 +11702,7 @@ if (!globalThis.__InboxSDKImpLoader) {
11671
11702
  await onready;
11672
11703
  const {
11673
11704
  makePlatformImplementation
11674
- } = await Promise.resolve(/* import() eager */).then(__webpack_require__.bind(__webpack_require__, 6801));
11705
+ } = await Promise.resolve(/* import() eager */).then(__webpack_require__.bind(__webpack_require__, 9046));
11675
11706
  return makePlatformImplementation(appId, opts, {
11676
11707
  piMainStarted,
11677
11708
  piLoadStarted,
@@ -12366,7 +12397,7 @@ function _updateNavMenu(members, newRouteViewDriver) {
12366
12397
 
12367
12398
  /***/ }),
12368
12399
 
12369
- /***/ 6801:
12400
+ /***/ 9046:
12370
12401
  /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
12371
12402
 
12372
12403
  "use strict";
@@ -19241,7 +19272,7 @@ options.insert = htmlElement => {
19241
19272
  htmlElement.setAttribute('data-inboxsdk-version',
19242
19273
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment -- this is injected by webpack
19243
19274
  ///@ts-ignore
19244
- "2.1.29-1707947517546-0a2f60e3e3450a0e");
19275
+ "2.1.30-1708002196801-3d13f4ec423fe68f");
19245
19276
  document.head.append(htmlElement);
19246
19277
  };
19247
19278
  options.domAPI = (styleDomAPI_default());
@@ -20112,14 +20143,8 @@ function encodeDraftUrlId(syncThreadId, syncMessageId) {
20112
20143
  }
20113
20144
  // EXTERNAL MODULE: ./src/platform-implementation-js/driver-common/getOriginalMessagePage.ts
20114
20145
  var getOriginalMessagePage = __webpack_require__(8102);
20115
- ;// CONCATENATED MODULE: ./src/common/html-to-text.ts
20116
- // Quick function for converting HTML with entities into text without
20117
- // introducing an XSS vulnerability.
20118
- function htmlToText(html) {
20119
- const div = document.createElement('div');
20120
- div.innerHTML = html.replace(/<[^>]*>?/g, '');
20121
- return div.textContent;
20122
- }
20146
+ // EXTERNAL MODULE: ./src/common/html-to-text.ts
20147
+ var html_to_text = __webpack_require__(9865);
20123
20148
  ;// CONCATENATED MODULE: ./src/platform-implementation-js/dom-driver/gmail/gmail-driver/get-rfc-message-id-for-gmail-message-id.ts
20124
20149
 
20125
20150
 
@@ -20131,7 +20156,7 @@ async function getRfcMessageIdForGmailMessageId(driver, gmailMessageId) {
20131
20156
  if (!match) {
20132
20157
  throw new Error("Failed to find rfc id for gmail thread id. Message may not exist in user's account.");
20133
20158
  }
20134
- return htmlToText(match[1]);
20159
+ return (0,html_to_text/* default */.Z)(match[1]);
20135
20160
  }
20136
20161
  ;// CONCATENATED MODULE: ./src/platform-implementation-js/dom-driver/gmail/gmail-driver/open-draft-by-message-id.ts
20137
20162
 
@@ -37757,6 +37782,1522 @@ var __WEBPACK_AMD_DEFINE_RESULT__;;(function (globalScope) {
37757
37782
  })(this);
37758
37783
 
37759
37784
 
37785
+ /***/ }),
37786
+
37787
+ /***/ 7856:
37788
+ /***/ (function(module) {
37789
+
37790
+ /*! @license DOMPurify 3.0.8 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.0.8/LICENSE */
37791
+
37792
+ (function (global, factory) {
37793
+ true ? module.exports = factory() :
37794
+ 0;
37795
+ })(this, (function () { 'use strict';
37796
+
37797
+ const {
37798
+ entries,
37799
+ setPrototypeOf,
37800
+ isFrozen,
37801
+ getPrototypeOf,
37802
+ getOwnPropertyDescriptor
37803
+ } = Object;
37804
+ let {
37805
+ freeze,
37806
+ seal,
37807
+ create
37808
+ } = Object; // eslint-disable-line import/no-mutable-exports
37809
+ let {
37810
+ apply,
37811
+ construct
37812
+ } = typeof Reflect !== 'undefined' && Reflect;
37813
+ if (!freeze) {
37814
+ freeze = function freeze(x) {
37815
+ return x;
37816
+ };
37817
+ }
37818
+ if (!seal) {
37819
+ seal = function seal(x) {
37820
+ return x;
37821
+ };
37822
+ }
37823
+ if (!apply) {
37824
+ apply = function apply(fun, thisValue, args) {
37825
+ return fun.apply(thisValue, args);
37826
+ };
37827
+ }
37828
+ if (!construct) {
37829
+ construct = function construct(Func, args) {
37830
+ return new Func(...args);
37831
+ };
37832
+ }
37833
+ const arrayForEach = unapply(Array.prototype.forEach);
37834
+ const arrayPop = unapply(Array.prototype.pop);
37835
+ const arrayPush = unapply(Array.prototype.push);
37836
+ const stringToLowerCase = unapply(String.prototype.toLowerCase);
37837
+ const stringToString = unapply(String.prototype.toString);
37838
+ const stringMatch = unapply(String.prototype.match);
37839
+ const stringReplace = unapply(String.prototype.replace);
37840
+ const stringIndexOf = unapply(String.prototype.indexOf);
37841
+ const stringTrim = unapply(String.prototype.trim);
37842
+ const regExpTest = unapply(RegExp.prototype.test);
37843
+ const typeErrorCreate = unconstruct(TypeError);
37844
+
37845
+ /**
37846
+ * Creates a new function that calls the given function with a specified thisArg and arguments.
37847
+ *
37848
+ * @param {Function} func - The function to be wrapped and called.
37849
+ * @returns {Function} A new function that calls the given function with a specified thisArg and arguments.
37850
+ */
37851
+ function unapply(func) {
37852
+ return function (thisArg) {
37853
+ for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
37854
+ args[_key - 1] = arguments[_key];
37855
+ }
37856
+ return apply(func, thisArg, args);
37857
+ };
37858
+ }
37859
+
37860
+ /**
37861
+ * Creates a new function that constructs an instance of the given constructor function with the provided arguments.
37862
+ *
37863
+ * @param {Function} func - The constructor function to be wrapped and called.
37864
+ * @returns {Function} A new function that constructs an instance of the given constructor function with the provided arguments.
37865
+ */
37866
+ function unconstruct(func) {
37867
+ return function () {
37868
+ for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
37869
+ args[_key2] = arguments[_key2];
37870
+ }
37871
+ return construct(func, args);
37872
+ };
37873
+ }
37874
+
37875
+ /**
37876
+ * Add properties to a lookup table
37877
+ *
37878
+ * @param {Object} set - The set to which elements will be added.
37879
+ * @param {Array} array - The array containing elements to be added to the set.
37880
+ * @param {Function} transformCaseFunc - An optional function to transform the case of each element before adding to the set.
37881
+ * @returns {Object} The modified set with added elements.
37882
+ */
37883
+ function addToSet(set, array) {
37884
+ let transformCaseFunc = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : stringToLowerCase;
37885
+ if (setPrototypeOf) {
37886
+ // Make 'in' and truthy checks like Boolean(set.constructor)
37887
+ // independent of any properties defined on Object.prototype.
37888
+ // Prevent prototype setters from intercepting set as a this value.
37889
+ setPrototypeOf(set, null);
37890
+ }
37891
+ let l = array.length;
37892
+ while (l--) {
37893
+ let element = array[l];
37894
+ if (typeof element === 'string') {
37895
+ const lcElement = transformCaseFunc(element);
37896
+ if (lcElement !== element) {
37897
+ // Config presets (e.g. tags.js, attrs.js) are immutable.
37898
+ if (!isFrozen(array)) {
37899
+ array[l] = lcElement;
37900
+ }
37901
+ element = lcElement;
37902
+ }
37903
+ }
37904
+ set[element] = true;
37905
+ }
37906
+ return set;
37907
+ }
37908
+
37909
+ /**
37910
+ * Clean up an array to harden against CSPP
37911
+ *
37912
+ * @param {Array} array - The array to be cleaned.
37913
+ * @returns {Array} The cleaned version of the array
37914
+ */
37915
+ function cleanArray(array) {
37916
+ for (let index = 0; index < array.length; index++) {
37917
+ if (getOwnPropertyDescriptor(array, index) === undefined) {
37918
+ array[index] = null;
37919
+ }
37920
+ }
37921
+ return array;
37922
+ }
37923
+
37924
+ /**
37925
+ * Shallow clone an object
37926
+ *
37927
+ * @param {Object} object - The object to be cloned.
37928
+ * @returns {Object} A new object that copies the original.
37929
+ */
37930
+ function clone(object) {
37931
+ const newObject = create(null);
37932
+ for (const [property, value] of entries(object)) {
37933
+ if (getOwnPropertyDescriptor(object, property) !== undefined) {
37934
+ if (Array.isArray(value)) {
37935
+ newObject[property] = cleanArray(value);
37936
+ } else if (value && typeof value === 'object' && value.constructor === Object) {
37937
+ newObject[property] = clone(value);
37938
+ } else {
37939
+ newObject[property] = value;
37940
+ }
37941
+ }
37942
+ }
37943
+ return newObject;
37944
+ }
37945
+
37946
+ /**
37947
+ * This method automatically checks if the prop is function or getter and behaves accordingly.
37948
+ *
37949
+ * @param {Object} object - The object to look up the getter function in its prototype chain.
37950
+ * @param {String} prop - The property name for which to find the getter function.
37951
+ * @returns {Function} The getter function found in the prototype chain or a fallback function.
37952
+ */
37953
+ function lookupGetter(object, prop) {
37954
+ while (object !== null) {
37955
+ const desc = getOwnPropertyDescriptor(object, prop);
37956
+ if (desc) {
37957
+ if (desc.get) {
37958
+ return unapply(desc.get);
37959
+ }
37960
+ if (typeof desc.value === 'function') {
37961
+ return unapply(desc.value);
37962
+ }
37963
+ }
37964
+ object = getPrototypeOf(object);
37965
+ }
37966
+ function fallbackValue(element) {
37967
+ console.warn('fallback value for', element);
37968
+ return null;
37969
+ }
37970
+ return fallbackValue;
37971
+ }
37972
+
37973
+ const html$1 = freeze(['a', 'abbr', 'acronym', 'address', 'area', 'article', 'aside', 'audio', 'b', 'bdi', 'bdo', 'big', 'blink', 'blockquote', 'body', 'br', 'button', 'canvas', 'caption', 'center', 'cite', 'code', 'col', 'colgroup', 'content', 'data', 'datalist', 'dd', 'decorator', 'del', 'details', 'dfn', 'dialog', 'dir', 'div', 'dl', 'dt', 'element', 'em', 'fieldset', 'figcaption', 'figure', 'font', 'footer', 'form', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'head', 'header', 'hgroup', 'hr', 'html', 'i', 'img', 'input', 'ins', 'kbd', 'label', 'legend', 'li', 'main', 'map', 'mark', 'marquee', 'menu', 'menuitem', 'meter', 'nav', 'nobr', 'ol', 'optgroup', 'option', 'output', 'p', 'picture', 'pre', 'progress', 'q', 'rp', 'rt', 'ruby', 's', 'samp', 'section', 'select', 'shadow', 'small', 'source', 'spacer', 'span', 'strike', 'strong', 'style', 'sub', 'summary', 'sup', 'table', 'tbody', 'td', 'template', 'textarea', 'tfoot', 'th', 'thead', 'time', 'tr', 'track', 'tt', 'u', 'ul', 'var', 'video', 'wbr']);
37974
+
37975
+ // SVG
37976
+ const svg$1 = freeze(['svg', 'a', 'altglyph', 'altglyphdef', 'altglyphitem', 'animatecolor', 'animatemotion', 'animatetransform', 'circle', 'clippath', 'defs', 'desc', 'ellipse', 'filter', 'font', 'g', 'glyph', 'glyphref', 'hkern', 'image', 'line', 'lineargradient', 'marker', 'mask', 'metadata', 'mpath', 'path', 'pattern', 'polygon', 'polyline', 'radialgradient', 'rect', 'stop', 'style', 'switch', 'symbol', 'text', 'textpath', 'title', 'tref', 'tspan', 'view', 'vkern']);
37977
+ const svgFilters = freeze(['feBlend', 'feColorMatrix', 'feComponentTransfer', 'feComposite', 'feConvolveMatrix', 'feDiffuseLighting', 'feDisplacementMap', 'feDistantLight', 'feDropShadow', 'feFlood', 'feFuncA', 'feFuncB', 'feFuncG', 'feFuncR', 'feGaussianBlur', 'feImage', 'feMerge', 'feMergeNode', 'feMorphology', 'feOffset', 'fePointLight', 'feSpecularLighting', 'feSpotLight', 'feTile', 'feTurbulence']);
37978
+
37979
+ // List of SVG elements that are disallowed by default.
37980
+ // We still need to know them so that we can do namespace
37981
+ // checks properly in case one wants to add them to
37982
+ // allow-list.
37983
+ const svgDisallowed = freeze(['animate', 'color-profile', 'cursor', 'discard', 'font-face', 'font-face-format', 'font-face-name', 'font-face-src', 'font-face-uri', 'foreignobject', 'hatch', 'hatchpath', 'mesh', 'meshgradient', 'meshpatch', 'meshrow', 'missing-glyph', 'script', 'set', 'solidcolor', 'unknown', 'use']);
37984
+ const mathMl$1 = freeze(['math', 'menclose', 'merror', 'mfenced', 'mfrac', 'mglyph', 'mi', 'mlabeledtr', 'mmultiscripts', 'mn', 'mo', 'mover', 'mpadded', 'mphantom', 'mroot', 'mrow', 'ms', 'mspace', 'msqrt', 'mstyle', 'msub', 'msup', 'msubsup', 'mtable', 'mtd', 'mtext', 'mtr', 'munder', 'munderover', 'mprescripts']);
37985
+
37986
+ // Similarly to SVG, we want to know all MathML elements,
37987
+ // even those that we disallow by default.
37988
+ const mathMlDisallowed = freeze(['maction', 'maligngroup', 'malignmark', 'mlongdiv', 'mscarries', 'mscarry', 'msgroup', 'mstack', 'msline', 'msrow', 'semantics', 'annotation', 'annotation-xml', 'mprescripts', 'none']);
37989
+ const text = freeze(['#text']);
37990
+
37991
+ const html = freeze(['accept', 'action', 'align', 'alt', 'autocapitalize', 'autocomplete', 'autopictureinpicture', 'autoplay', 'background', 'bgcolor', 'border', 'capture', 'cellpadding', 'cellspacing', 'checked', 'cite', 'class', 'clear', 'color', 'cols', 'colspan', 'controls', 'controlslist', 'coords', 'crossorigin', 'datetime', 'decoding', 'default', 'dir', 'disabled', 'disablepictureinpicture', 'disableremoteplayback', 'download', 'draggable', 'enctype', 'enterkeyhint', 'face', 'for', 'headers', 'height', 'hidden', 'high', 'href', 'hreflang', 'id', 'inputmode', 'integrity', 'ismap', 'kind', 'label', 'lang', 'list', 'loading', 'loop', 'low', 'max', 'maxlength', 'media', 'method', 'min', 'minlength', 'multiple', 'muted', 'name', 'nonce', 'noshade', 'novalidate', 'nowrap', 'open', 'optimum', 'pattern', 'placeholder', 'playsinline', 'poster', 'preload', 'pubdate', 'radiogroup', 'readonly', 'rel', 'required', 'rev', 'reversed', 'role', 'rows', 'rowspan', 'spellcheck', 'scope', 'selected', 'shape', 'size', 'sizes', 'span', 'srclang', 'start', 'src', 'srcset', 'step', 'style', 'summary', 'tabindex', 'title', 'translate', 'type', 'usemap', 'valign', 'value', 'width', 'xmlns', 'slot']);
37992
+ const svg = freeze(['accent-height', 'accumulate', 'additive', 'alignment-baseline', 'ascent', 'attributename', 'attributetype', 'azimuth', 'basefrequency', 'baseline-shift', 'begin', 'bias', 'by', 'class', 'clip', 'clippathunits', 'clip-path', 'clip-rule', 'color', 'color-interpolation', 'color-interpolation-filters', 'color-profile', 'color-rendering', 'cx', 'cy', 'd', 'dx', 'dy', 'diffuseconstant', 'direction', 'display', 'divisor', 'dur', 'edgemode', 'elevation', 'end', 'fill', 'fill-opacity', 'fill-rule', 'filter', 'filterunits', 'flood-color', 'flood-opacity', 'font-family', 'font-size', 'font-size-adjust', 'font-stretch', 'font-style', 'font-variant', 'font-weight', 'fx', 'fy', 'g1', 'g2', 'glyph-name', 'glyphref', 'gradientunits', 'gradienttransform', 'height', 'href', 'id', 'image-rendering', 'in', 'in2', 'k', 'k1', 'k2', 'k3', 'k4', 'kerning', 'keypoints', 'keysplines', 'keytimes', 'lang', 'lengthadjust', 'letter-spacing', 'kernelmatrix', 'kernelunitlength', 'lighting-color', 'local', 'marker-end', 'marker-mid', 'marker-start', 'markerheight', 'markerunits', 'markerwidth', 'maskcontentunits', 'maskunits', 'max', 'mask', 'media', 'method', 'mode', 'min', 'name', 'numoctaves', 'offset', 'operator', 'opacity', 'order', 'orient', 'orientation', 'origin', 'overflow', 'paint-order', 'path', 'pathlength', 'patterncontentunits', 'patterntransform', 'patternunits', 'points', 'preservealpha', 'preserveaspectratio', 'primitiveunits', 'r', 'rx', 'ry', 'radius', 'refx', 'refy', 'repeatcount', 'repeatdur', 'restart', 'result', 'rotate', 'scale', 'seed', 'shape-rendering', 'specularconstant', 'specularexponent', 'spreadmethod', 'startoffset', 'stddeviation', 'stitchtiles', 'stop-color', 'stop-opacity', 'stroke-dasharray', 'stroke-dashoffset', 'stroke-linecap', 'stroke-linejoin', 'stroke-miterlimit', 'stroke-opacity', 'stroke', 'stroke-width', 'style', 'surfacescale', 'systemlanguage', 'tabindex', 'targetx', 'targety', 'transform', 'transform-origin', 'text-anchor', 'text-decoration', 'text-rendering', 'textlength', 'type', 'u1', 'u2', 'unicode', 'values', 'viewbox', 'visibility', 'version', 'vert-adv-y', 'vert-origin-x', 'vert-origin-y', 'width', 'word-spacing', 'wrap', 'writing-mode', 'xchannelselector', 'ychannelselector', 'x', 'x1', 'x2', 'xmlns', 'y', 'y1', 'y2', 'z', 'zoomandpan']);
37993
+ const mathMl = freeze(['accent', 'accentunder', 'align', 'bevelled', 'close', 'columnsalign', 'columnlines', 'columnspan', 'denomalign', 'depth', 'dir', 'display', 'displaystyle', 'encoding', 'fence', 'frame', 'height', 'href', 'id', 'largeop', 'length', 'linethickness', 'lspace', 'lquote', 'mathbackground', 'mathcolor', 'mathsize', 'mathvariant', 'maxsize', 'minsize', 'movablelimits', 'notation', 'numalign', 'open', 'rowalign', 'rowlines', 'rowspacing', 'rowspan', 'rspace', 'rquote', 'scriptlevel', 'scriptminsize', 'scriptsizemultiplier', 'selection', 'separator', 'separators', 'stretchy', 'subscriptshift', 'supscriptshift', 'symmetric', 'voffset', 'width', 'xmlns']);
37994
+ const xml = freeze(['xlink:href', 'xml:id', 'xlink:title', 'xml:space', 'xmlns:xlink']);
37995
+
37996
+ // eslint-disable-next-line unicorn/better-regex
37997
+ const MUSTACHE_EXPR = seal(/\{\{[\w\W]*|[\w\W]*\}\}/gm); // Specify template detection regex for SAFE_FOR_TEMPLATES mode
37998
+ const ERB_EXPR = seal(/<%[\w\W]*|[\w\W]*%>/gm);
37999
+ const TMPLIT_EXPR = seal(/\${[\w\W]*}/gm);
38000
+ const DATA_ATTR = seal(/^data-[\-\w.\u00B7-\uFFFF]/); // eslint-disable-line no-useless-escape
38001
+ const ARIA_ATTR = seal(/^aria-[\-\w]+$/); // eslint-disable-line no-useless-escape
38002
+ const IS_ALLOWED_URI = seal(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i // eslint-disable-line no-useless-escape
38003
+ );
38004
+
38005
+ const IS_SCRIPT_OR_DATA = seal(/^(?:\w+script|data):/i);
38006
+ const ATTR_WHITESPACE = seal(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g // eslint-disable-line no-control-regex
38007
+ );
38008
+
38009
+ const DOCTYPE_NAME = seal(/^html$/i);
38010
+
38011
+ var EXPRESSIONS = /*#__PURE__*/Object.freeze({
38012
+ __proto__: null,
38013
+ MUSTACHE_EXPR: MUSTACHE_EXPR,
38014
+ ERB_EXPR: ERB_EXPR,
38015
+ TMPLIT_EXPR: TMPLIT_EXPR,
38016
+ DATA_ATTR: DATA_ATTR,
38017
+ ARIA_ATTR: ARIA_ATTR,
38018
+ IS_ALLOWED_URI: IS_ALLOWED_URI,
38019
+ IS_SCRIPT_OR_DATA: IS_SCRIPT_OR_DATA,
38020
+ ATTR_WHITESPACE: ATTR_WHITESPACE,
38021
+ DOCTYPE_NAME: DOCTYPE_NAME
38022
+ });
38023
+
38024
+ const getGlobal = function getGlobal() {
38025
+ return typeof window === 'undefined' ? null : window;
38026
+ };
38027
+
38028
+ /**
38029
+ * Creates a no-op policy for internal use only.
38030
+ * Don't export this function outside this module!
38031
+ * @param {TrustedTypePolicyFactory} trustedTypes The policy factory.
38032
+ * @param {HTMLScriptElement} purifyHostElement The Script element used to load DOMPurify (to determine policy name suffix).
38033
+ * @return {TrustedTypePolicy} The policy created (or null, if Trusted Types
38034
+ * are not supported or creating the policy failed).
38035
+ */
38036
+ const _createTrustedTypesPolicy = function _createTrustedTypesPolicy(trustedTypes, purifyHostElement) {
38037
+ if (typeof trustedTypes !== 'object' || typeof trustedTypes.createPolicy !== 'function') {
38038
+ return null;
38039
+ }
38040
+
38041
+ // Allow the callers to control the unique policy name
38042
+ // by adding a data-tt-policy-suffix to the script element with the DOMPurify.
38043
+ // Policy creation with duplicate names throws in Trusted Types.
38044
+ let suffix = null;
38045
+ const ATTR_NAME = 'data-tt-policy-suffix';
38046
+ if (purifyHostElement && purifyHostElement.hasAttribute(ATTR_NAME)) {
38047
+ suffix = purifyHostElement.getAttribute(ATTR_NAME);
38048
+ }
38049
+ const policyName = 'dompurify' + (suffix ? '#' + suffix : '');
38050
+ try {
38051
+ return trustedTypes.createPolicy(policyName, {
38052
+ createHTML(html) {
38053
+ return html;
38054
+ },
38055
+ createScriptURL(scriptUrl) {
38056
+ return scriptUrl;
38057
+ }
38058
+ });
38059
+ } catch (_) {
38060
+ // Policy creation failed (most likely another DOMPurify script has
38061
+ // already run). Skip creating the policy, as this will only cause errors
38062
+ // if TT are enforced.
38063
+ console.warn('TrustedTypes policy ' + policyName + ' could not be created.');
38064
+ return null;
38065
+ }
38066
+ };
38067
+ function createDOMPurify() {
38068
+ let window = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : getGlobal();
38069
+ const DOMPurify = root => createDOMPurify(root);
38070
+
38071
+ /**
38072
+ * Version label, exposed for easier checks
38073
+ * if DOMPurify is up to date or not
38074
+ */
38075
+ DOMPurify.version = '3.0.8';
38076
+
38077
+ /**
38078
+ * Array of elements that DOMPurify removed during sanitation.
38079
+ * Empty if nothing was removed.
38080
+ */
38081
+ DOMPurify.removed = [];
38082
+ if (!window || !window.document || window.document.nodeType !== 9) {
38083
+ // Not running in a browser, provide a factory function
38084
+ // so that you can pass your own Window
38085
+ DOMPurify.isSupported = false;
38086
+ return DOMPurify;
38087
+ }
38088
+ let {
38089
+ document
38090
+ } = window;
38091
+ const originalDocument = document;
38092
+ const currentScript = originalDocument.currentScript;
38093
+ const {
38094
+ DocumentFragment,
38095
+ HTMLTemplateElement,
38096
+ Node,
38097
+ Element,
38098
+ NodeFilter,
38099
+ NamedNodeMap = window.NamedNodeMap || window.MozNamedAttrMap,
38100
+ HTMLFormElement,
38101
+ DOMParser,
38102
+ trustedTypes
38103
+ } = window;
38104
+ const ElementPrototype = Element.prototype;
38105
+ const cloneNode = lookupGetter(ElementPrototype, 'cloneNode');
38106
+ const getNextSibling = lookupGetter(ElementPrototype, 'nextSibling');
38107
+ const getChildNodes = lookupGetter(ElementPrototype, 'childNodes');
38108
+ const getParentNode = lookupGetter(ElementPrototype, 'parentNode');
38109
+
38110
+ // As per issue #47, the web-components registry is inherited by a
38111
+ // new document created via createHTMLDocument. As per the spec
38112
+ // (http://w3c.github.io/webcomponents/spec/custom/#creating-and-passing-registries)
38113
+ // a new empty registry is used when creating a template contents owner
38114
+ // document, so we use that as our parent document to ensure nothing
38115
+ // is inherited.
38116
+ if (typeof HTMLTemplateElement === 'function') {
38117
+ const template = document.createElement('template');
38118
+ if (template.content && template.content.ownerDocument) {
38119
+ document = template.content.ownerDocument;
38120
+ }
38121
+ }
38122
+ let trustedTypesPolicy;
38123
+ let emptyHTML = '';
38124
+ const {
38125
+ implementation,
38126
+ createNodeIterator,
38127
+ createDocumentFragment,
38128
+ getElementsByTagName
38129
+ } = document;
38130
+ const {
38131
+ importNode
38132
+ } = originalDocument;
38133
+ let hooks = {};
38134
+
38135
+ /**
38136
+ * Expose whether this browser supports running the full DOMPurify.
38137
+ */
38138
+ DOMPurify.isSupported = typeof entries === 'function' && typeof getParentNode === 'function' && implementation && implementation.createHTMLDocument !== undefined;
38139
+ const {
38140
+ MUSTACHE_EXPR,
38141
+ ERB_EXPR,
38142
+ TMPLIT_EXPR,
38143
+ DATA_ATTR,
38144
+ ARIA_ATTR,
38145
+ IS_SCRIPT_OR_DATA,
38146
+ ATTR_WHITESPACE
38147
+ } = EXPRESSIONS;
38148
+ let {
38149
+ IS_ALLOWED_URI: IS_ALLOWED_URI$1
38150
+ } = EXPRESSIONS;
38151
+
38152
+ /**
38153
+ * We consider the elements and attributes below to be safe. Ideally
38154
+ * don't add any new ones but feel free to remove unwanted ones.
38155
+ */
38156
+
38157
+ /* allowed element names */
38158
+ let ALLOWED_TAGS = null;
38159
+ const DEFAULT_ALLOWED_TAGS = addToSet({}, [...html$1, ...svg$1, ...svgFilters, ...mathMl$1, ...text]);
38160
+
38161
+ /* Allowed attribute names */
38162
+ let ALLOWED_ATTR = null;
38163
+ const DEFAULT_ALLOWED_ATTR = addToSet({}, [...html, ...svg, ...mathMl, ...xml]);
38164
+
38165
+ /*
38166
+ * Configure how DOMPUrify should handle custom elements and their attributes as well as customized built-in elements.
38167
+ * @property {RegExp|Function|null} tagNameCheck one of [null, regexPattern, predicate]. Default: `null` (disallow any custom elements)
38168
+ * @property {RegExp|Function|null} attributeNameCheck one of [null, regexPattern, predicate]. Default: `null` (disallow any attributes not on the allow list)
38169
+ * @property {boolean} allowCustomizedBuiltInElements allow custom elements derived from built-ins if they pass CUSTOM_ELEMENT_HANDLING.tagNameCheck. Default: `false`.
38170
+ */
38171
+ let CUSTOM_ELEMENT_HANDLING = Object.seal(create(null, {
38172
+ tagNameCheck: {
38173
+ writable: true,
38174
+ configurable: false,
38175
+ enumerable: true,
38176
+ value: null
38177
+ },
38178
+ attributeNameCheck: {
38179
+ writable: true,
38180
+ configurable: false,
38181
+ enumerable: true,
38182
+ value: null
38183
+ },
38184
+ allowCustomizedBuiltInElements: {
38185
+ writable: true,
38186
+ configurable: false,
38187
+ enumerable: true,
38188
+ value: false
38189
+ }
38190
+ }));
38191
+
38192
+ /* Explicitly forbidden tags (overrides ALLOWED_TAGS/ADD_TAGS) */
38193
+ let FORBID_TAGS = null;
38194
+
38195
+ /* Explicitly forbidden attributes (overrides ALLOWED_ATTR/ADD_ATTR) */
38196
+ let FORBID_ATTR = null;
38197
+
38198
+ /* Decide if ARIA attributes are okay */
38199
+ let ALLOW_ARIA_ATTR = true;
38200
+
38201
+ /* Decide if custom data attributes are okay */
38202
+ let ALLOW_DATA_ATTR = true;
38203
+
38204
+ /* Decide if unknown protocols are okay */
38205
+ let ALLOW_UNKNOWN_PROTOCOLS = false;
38206
+
38207
+ /* Decide if self-closing tags in attributes are allowed.
38208
+ * Usually removed due to a mXSS issue in jQuery 3.0 */
38209
+ let ALLOW_SELF_CLOSE_IN_ATTR = true;
38210
+
38211
+ /* Output should be safe for common template engines.
38212
+ * This means, DOMPurify removes data attributes, mustaches and ERB
38213
+ */
38214
+ let SAFE_FOR_TEMPLATES = false;
38215
+
38216
+ /* Decide if document with <html>... should be returned */
38217
+ let WHOLE_DOCUMENT = false;
38218
+
38219
+ /* Track whether config is already set on this instance of DOMPurify. */
38220
+ let SET_CONFIG = false;
38221
+
38222
+ /* Decide if all elements (e.g. style, script) must be children of
38223
+ * document.body. By default, browsers might move them to document.head */
38224
+ let FORCE_BODY = false;
38225
+
38226
+ /* Decide if a DOM `HTMLBodyElement` should be returned, instead of a html
38227
+ * string (or a TrustedHTML object if Trusted Types are supported).
38228
+ * If `WHOLE_DOCUMENT` is enabled a `HTMLHtmlElement` will be returned instead
38229
+ */
38230
+ let RETURN_DOM = false;
38231
+
38232
+ /* Decide if a DOM `DocumentFragment` should be returned, instead of a html
38233
+ * string (or a TrustedHTML object if Trusted Types are supported) */
38234
+ let RETURN_DOM_FRAGMENT = false;
38235
+
38236
+ /* Try to return a Trusted Type object instead of a string, return a string in
38237
+ * case Trusted Types are not supported */
38238
+ let RETURN_TRUSTED_TYPE = false;
38239
+
38240
+ /* Output should be free from DOM clobbering attacks?
38241
+ * This sanitizes markups named with colliding, clobberable built-in DOM APIs.
38242
+ */
38243
+ let SANITIZE_DOM = true;
38244
+
38245
+ /* Achieve full DOM Clobbering protection by isolating the namespace of named
38246
+ * properties and JS variables, mitigating attacks that abuse the HTML/DOM spec rules.
38247
+ *
38248
+ * HTML/DOM spec rules that enable DOM Clobbering:
38249
+ * - Named Access on Window (§7.3.3)
38250
+ * - DOM Tree Accessors (§3.1.5)
38251
+ * - Form Element Parent-Child Relations (§4.10.3)
38252
+ * - Iframe srcdoc / Nested WindowProxies (§4.8.5)
38253
+ * - HTMLCollection (§4.2.10.2)
38254
+ *
38255
+ * Namespace isolation is implemented by prefixing `id` and `name` attributes
38256
+ * with a constant string, i.e., `user-content-`
38257
+ */
38258
+ let SANITIZE_NAMED_PROPS = false;
38259
+ const SANITIZE_NAMED_PROPS_PREFIX = 'user-content-';
38260
+
38261
+ /* Keep element content when removing element? */
38262
+ let KEEP_CONTENT = true;
38263
+
38264
+ /* If a `Node` is passed to sanitize(), then performs sanitization in-place instead
38265
+ * of importing it into a new Document and returning a sanitized copy */
38266
+ let IN_PLACE = false;
38267
+
38268
+ /* Allow usage of profiles like html, svg and mathMl */
38269
+ let USE_PROFILES = {};
38270
+
38271
+ /* Tags to ignore content of when KEEP_CONTENT is true */
38272
+ let FORBID_CONTENTS = null;
38273
+ const DEFAULT_FORBID_CONTENTS = addToSet({}, ['annotation-xml', 'audio', 'colgroup', 'desc', 'foreignobject', 'head', 'iframe', 'math', 'mi', 'mn', 'mo', 'ms', 'mtext', 'noembed', 'noframes', 'noscript', 'plaintext', 'script', 'style', 'svg', 'template', 'thead', 'title', 'video', 'xmp']);
38274
+
38275
+ /* Tags that are safe for data: URIs */
38276
+ let DATA_URI_TAGS = null;
38277
+ const DEFAULT_DATA_URI_TAGS = addToSet({}, ['audio', 'video', 'img', 'source', 'image', 'track']);
38278
+
38279
+ /* Attributes safe for values like "javascript:" */
38280
+ let URI_SAFE_ATTRIBUTES = null;
38281
+ const DEFAULT_URI_SAFE_ATTRIBUTES = addToSet({}, ['alt', 'class', 'for', 'id', 'label', 'name', 'pattern', 'placeholder', 'role', 'summary', 'title', 'value', 'style', 'xmlns']);
38282
+ const MATHML_NAMESPACE = 'http://www.w3.org/1998/Math/MathML';
38283
+ const SVG_NAMESPACE = 'http://www.w3.org/2000/svg';
38284
+ const HTML_NAMESPACE = 'http://www.w3.org/1999/xhtml';
38285
+ /* Document namespace */
38286
+ let NAMESPACE = HTML_NAMESPACE;
38287
+ let IS_EMPTY_INPUT = false;
38288
+
38289
+ /* Allowed XHTML+XML namespaces */
38290
+ let ALLOWED_NAMESPACES = null;
38291
+ const DEFAULT_ALLOWED_NAMESPACES = addToSet({}, [MATHML_NAMESPACE, SVG_NAMESPACE, HTML_NAMESPACE], stringToString);
38292
+
38293
+ /* Parsing of strict XHTML documents */
38294
+ let PARSER_MEDIA_TYPE = null;
38295
+ const SUPPORTED_PARSER_MEDIA_TYPES = ['application/xhtml+xml', 'text/html'];
38296
+ const DEFAULT_PARSER_MEDIA_TYPE = 'text/html';
38297
+ let transformCaseFunc = null;
38298
+
38299
+ /* Keep a reference to config to pass to hooks */
38300
+ let CONFIG = null;
38301
+
38302
+ /* Ideally, do not touch anything below this line */
38303
+ /* ______________________________________________ */
38304
+
38305
+ const formElement = document.createElement('form');
38306
+ const isRegexOrFunction = function isRegexOrFunction(testValue) {
38307
+ return testValue instanceof RegExp || testValue instanceof Function;
38308
+ };
38309
+
38310
+ /**
38311
+ * _parseConfig
38312
+ *
38313
+ * @param {Object} cfg optional config literal
38314
+ */
38315
+ // eslint-disable-next-line complexity
38316
+ const _parseConfig = function _parseConfig() {
38317
+ let cfg = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
38318
+ if (CONFIG && CONFIG === cfg) {
38319
+ return;
38320
+ }
38321
+
38322
+ /* Shield configuration object from tampering */
38323
+ if (!cfg || typeof cfg !== 'object') {
38324
+ cfg = {};
38325
+ }
38326
+
38327
+ /* Shield configuration object from prototype pollution */
38328
+ cfg = clone(cfg);
38329
+ PARSER_MEDIA_TYPE =
38330
+ // eslint-disable-next-line unicorn/prefer-includes
38331
+ SUPPORTED_PARSER_MEDIA_TYPES.indexOf(cfg.PARSER_MEDIA_TYPE) === -1 ? DEFAULT_PARSER_MEDIA_TYPE : cfg.PARSER_MEDIA_TYPE;
38332
+
38333
+ // HTML tags and attributes are not case-sensitive, converting to lowercase. Keeping XHTML as is.
38334
+ transformCaseFunc = PARSER_MEDIA_TYPE === 'application/xhtml+xml' ? stringToString : stringToLowerCase;
38335
+
38336
+ /* Set configuration parameters */
38337
+ ALLOWED_TAGS = 'ALLOWED_TAGS' in cfg ? addToSet({}, cfg.ALLOWED_TAGS, transformCaseFunc) : DEFAULT_ALLOWED_TAGS;
38338
+ ALLOWED_ATTR = 'ALLOWED_ATTR' in cfg ? addToSet({}, cfg.ALLOWED_ATTR, transformCaseFunc) : DEFAULT_ALLOWED_ATTR;
38339
+ ALLOWED_NAMESPACES = 'ALLOWED_NAMESPACES' in cfg ? addToSet({}, cfg.ALLOWED_NAMESPACES, stringToString) : DEFAULT_ALLOWED_NAMESPACES;
38340
+ URI_SAFE_ATTRIBUTES = 'ADD_URI_SAFE_ATTR' in cfg ? addToSet(clone(DEFAULT_URI_SAFE_ATTRIBUTES),
38341
+ // eslint-disable-line indent
38342
+ cfg.ADD_URI_SAFE_ATTR,
38343
+ // eslint-disable-line indent
38344
+ transformCaseFunc // eslint-disable-line indent
38345
+ ) // eslint-disable-line indent
38346
+ : DEFAULT_URI_SAFE_ATTRIBUTES;
38347
+ DATA_URI_TAGS = 'ADD_DATA_URI_TAGS' in cfg ? addToSet(clone(DEFAULT_DATA_URI_TAGS),
38348
+ // eslint-disable-line indent
38349
+ cfg.ADD_DATA_URI_TAGS,
38350
+ // eslint-disable-line indent
38351
+ transformCaseFunc // eslint-disable-line indent
38352
+ ) // eslint-disable-line indent
38353
+ : DEFAULT_DATA_URI_TAGS;
38354
+ FORBID_CONTENTS = 'FORBID_CONTENTS' in cfg ? addToSet({}, cfg.FORBID_CONTENTS, transformCaseFunc) : DEFAULT_FORBID_CONTENTS;
38355
+ FORBID_TAGS = 'FORBID_TAGS' in cfg ? addToSet({}, cfg.FORBID_TAGS, transformCaseFunc) : {};
38356
+ FORBID_ATTR = 'FORBID_ATTR' in cfg ? addToSet({}, cfg.FORBID_ATTR, transformCaseFunc) : {};
38357
+ USE_PROFILES = 'USE_PROFILES' in cfg ? cfg.USE_PROFILES : false;
38358
+ ALLOW_ARIA_ATTR = cfg.ALLOW_ARIA_ATTR !== false; // Default true
38359
+ ALLOW_DATA_ATTR = cfg.ALLOW_DATA_ATTR !== false; // Default true
38360
+ ALLOW_UNKNOWN_PROTOCOLS = cfg.ALLOW_UNKNOWN_PROTOCOLS || false; // Default false
38361
+ ALLOW_SELF_CLOSE_IN_ATTR = cfg.ALLOW_SELF_CLOSE_IN_ATTR !== false; // Default true
38362
+ SAFE_FOR_TEMPLATES = cfg.SAFE_FOR_TEMPLATES || false; // Default false
38363
+ WHOLE_DOCUMENT = cfg.WHOLE_DOCUMENT || false; // Default false
38364
+ RETURN_DOM = cfg.RETURN_DOM || false; // Default false
38365
+ RETURN_DOM_FRAGMENT = cfg.RETURN_DOM_FRAGMENT || false; // Default false
38366
+ RETURN_TRUSTED_TYPE = cfg.RETURN_TRUSTED_TYPE || false; // Default false
38367
+ FORCE_BODY = cfg.FORCE_BODY || false; // Default false
38368
+ SANITIZE_DOM = cfg.SANITIZE_DOM !== false; // Default true
38369
+ SANITIZE_NAMED_PROPS = cfg.SANITIZE_NAMED_PROPS || false; // Default false
38370
+ KEEP_CONTENT = cfg.KEEP_CONTENT !== false; // Default true
38371
+ IN_PLACE = cfg.IN_PLACE || false; // Default false
38372
+ IS_ALLOWED_URI$1 = cfg.ALLOWED_URI_REGEXP || IS_ALLOWED_URI;
38373
+ NAMESPACE = cfg.NAMESPACE || HTML_NAMESPACE;
38374
+ CUSTOM_ELEMENT_HANDLING = cfg.CUSTOM_ELEMENT_HANDLING || {};
38375
+ if (cfg.CUSTOM_ELEMENT_HANDLING && isRegexOrFunction(cfg.CUSTOM_ELEMENT_HANDLING.tagNameCheck)) {
38376
+ CUSTOM_ELEMENT_HANDLING.tagNameCheck = cfg.CUSTOM_ELEMENT_HANDLING.tagNameCheck;
38377
+ }
38378
+ if (cfg.CUSTOM_ELEMENT_HANDLING && isRegexOrFunction(cfg.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)) {
38379
+ CUSTOM_ELEMENT_HANDLING.attributeNameCheck = cfg.CUSTOM_ELEMENT_HANDLING.attributeNameCheck;
38380
+ }
38381
+ if (cfg.CUSTOM_ELEMENT_HANDLING && typeof cfg.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements === 'boolean') {
38382
+ CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements = cfg.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements;
38383
+ }
38384
+ if (SAFE_FOR_TEMPLATES) {
38385
+ ALLOW_DATA_ATTR = false;
38386
+ }
38387
+ if (RETURN_DOM_FRAGMENT) {
38388
+ RETURN_DOM = true;
38389
+ }
38390
+
38391
+ /* Parse profile info */
38392
+ if (USE_PROFILES) {
38393
+ ALLOWED_TAGS = addToSet({}, text);
38394
+ ALLOWED_ATTR = [];
38395
+ if (USE_PROFILES.html === true) {
38396
+ addToSet(ALLOWED_TAGS, html$1);
38397
+ addToSet(ALLOWED_ATTR, html);
38398
+ }
38399
+ if (USE_PROFILES.svg === true) {
38400
+ addToSet(ALLOWED_TAGS, svg$1);
38401
+ addToSet(ALLOWED_ATTR, svg);
38402
+ addToSet(ALLOWED_ATTR, xml);
38403
+ }
38404
+ if (USE_PROFILES.svgFilters === true) {
38405
+ addToSet(ALLOWED_TAGS, svgFilters);
38406
+ addToSet(ALLOWED_ATTR, svg);
38407
+ addToSet(ALLOWED_ATTR, xml);
38408
+ }
38409
+ if (USE_PROFILES.mathMl === true) {
38410
+ addToSet(ALLOWED_TAGS, mathMl$1);
38411
+ addToSet(ALLOWED_ATTR, mathMl);
38412
+ addToSet(ALLOWED_ATTR, xml);
38413
+ }
38414
+ }
38415
+
38416
+ /* Merge configuration parameters */
38417
+ if (cfg.ADD_TAGS) {
38418
+ if (ALLOWED_TAGS === DEFAULT_ALLOWED_TAGS) {
38419
+ ALLOWED_TAGS = clone(ALLOWED_TAGS);
38420
+ }
38421
+ addToSet(ALLOWED_TAGS, cfg.ADD_TAGS, transformCaseFunc);
38422
+ }
38423
+ if (cfg.ADD_ATTR) {
38424
+ if (ALLOWED_ATTR === DEFAULT_ALLOWED_ATTR) {
38425
+ ALLOWED_ATTR = clone(ALLOWED_ATTR);
38426
+ }
38427
+ addToSet(ALLOWED_ATTR, cfg.ADD_ATTR, transformCaseFunc);
38428
+ }
38429
+ if (cfg.ADD_URI_SAFE_ATTR) {
38430
+ addToSet(URI_SAFE_ATTRIBUTES, cfg.ADD_URI_SAFE_ATTR, transformCaseFunc);
38431
+ }
38432
+ if (cfg.FORBID_CONTENTS) {
38433
+ if (FORBID_CONTENTS === DEFAULT_FORBID_CONTENTS) {
38434
+ FORBID_CONTENTS = clone(FORBID_CONTENTS);
38435
+ }
38436
+ addToSet(FORBID_CONTENTS, cfg.FORBID_CONTENTS, transformCaseFunc);
38437
+ }
38438
+
38439
+ /* Add #text in case KEEP_CONTENT is set to true */
38440
+ if (KEEP_CONTENT) {
38441
+ ALLOWED_TAGS['#text'] = true;
38442
+ }
38443
+
38444
+ /* Add html, head and body to ALLOWED_TAGS in case WHOLE_DOCUMENT is true */
38445
+ if (WHOLE_DOCUMENT) {
38446
+ addToSet(ALLOWED_TAGS, ['html', 'head', 'body']);
38447
+ }
38448
+
38449
+ /* Add tbody to ALLOWED_TAGS in case tables are permitted, see #286, #365 */
38450
+ if (ALLOWED_TAGS.table) {
38451
+ addToSet(ALLOWED_TAGS, ['tbody']);
38452
+ delete FORBID_TAGS.tbody;
38453
+ }
38454
+ if (cfg.TRUSTED_TYPES_POLICY) {
38455
+ if (typeof cfg.TRUSTED_TYPES_POLICY.createHTML !== 'function') {
38456
+ throw typeErrorCreate('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');
38457
+ }
38458
+ if (typeof cfg.TRUSTED_TYPES_POLICY.createScriptURL !== 'function') {
38459
+ throw typeErrorCreate('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');
38460
+ }
38461
+
38462
+ // Overwrite existing TrustedTypes policy.
38463
+ trustedTypesPolicy = cfg.TRUSTED_TYPES_POLICY;
38464
+
38465
+ // Sign local variables required by `sanitize`.
38466
+ emptyHTML = trustedTypesPolicy.createHTML('');
38467
+ } else {
38468
+ // Uninitialized policy, attempt to initialize the internal dompurify policy.
38469
+ if (trustedTypesPolicy === undefined) {
38470
+ trustedTypesPolicy = _createTrustedTypesPolicy(trustedTypes, currentScript);
38471
+ }
38472
+
38473
+ // If creating the internal policy succeeded sign internal variables.
38474
+ if (trustedTypesPolicy !== null && typeof emptyHTML === 'string') {
38475
+ emptyHTML = trustedTypesPolicy.createHTML('');
38476
+ }
38477
+ }
38478
+
38479
+ // Prevent further manipulation of configuration.
38480
+ // Not available in IE8, Safari 5, etc.
38481
+ if (freeze) {
38482
+ freeze(cfg);
38483
+ }
38484
+ CONFIG = cfg;
38485
+ };
38486
+ const MATHML_TEXT_INTEGRATION_POINTS = addToSet({}, ['mi', 'mo', 'mn', 'ms', 'mtext']);
38487
+ const HTML_INTEGRATION_POINTS = addToSet({}, ['foreignobject', 'desc', 'title', 'annotation-xml']);
38488
+
38489
+ // Certain elements are allowed in both SVG and HTML
38490
+ // namespace. We need to specify them explicitly
38491
+ // so that they don't get erroneously deleted from
38492
+ // HTML namespace.
38493
+ const COMMON_SVG_AND_HTML_ELEMENTS = addToSet({}, ['title', 'style', 'font', 'a', 'script']);
38494
+
38495
+ /* Keep track of all possible SVG and MathML tags
38496
+ * so that we can perform the namespace checks
38497
+ * correctly. */
38498
+ const ALL_SVG_TAGS = addToSet({}, [...svg$1, ...svgFilters, ...svgDisallowed]);
38499
+ const ALL_MATHML_TAGS = addToSet({}, [...mathMl$1, ...mathMlDisallowed]);
38500
+
38501
+ /**
38502
+ * @param {Element} element a DOM element whose namespace is being checked
38503
+ * @returns {boolean} Return false if the element has a
38504
+ * namespace that a spec-compliant parser would never
38505
+ * return. Return true otherwise.
38506
+ */
38507
+ const _checkValidNamespace = function _checkValidNamespace(element) {
38508
+ let parent = getParentNode(element);
38509
+
38510
+ // In JSDOM, if we're inside shadow DOM, then parentNode
38511
+ // can be null. We just simulate parent in this case.
38512
+ if (!parent || !parent.tagName) {
38513
+ parent = {
38514
+ namespaceURI: NAMESPACE,
38515
+ tagName: 'template'
38516
+ };
38517
+ }
38518
+ const tagName = stringToLowerCase(element.tagName);
38519
+ const parentTagName = stringToLowerCase(parent.tagName);
38520
+ if (!ALLOWED_NAMESPACES[element.namespaceURI]) {
38521
+ return false;
38522
+ }
38523
+ if (element.namespaceURI === SVG_NAMESPACE) {
38524
+ // The only way to switch from HTML namespace to SVG
38525
+ // is via <svg>. If it happens via any other tag, then
38526
+ // it should be killed.
38527
+ if (parent.namespaceURI === HTML_NAMESPACE) {
38528
+ return tagName === 'svg';
38529
+ }
38530
+
38531
+ // The only way to switch from MathML to SVG is via`
38532
+ // svg if parent is either <annotation-xml> or MathML
38533
+ // text integration points.
38534
+ if (parent.namespaceURI === MATHML_NAMESPACE) {
38535
+ return tagName === 'svg' && (parentTagName === 'annotation-xml' || MATHML_TEXT_INTEGRATION_POINTS[parentTagName]);
38536
+ }
38537
+
38538
+ // We only allow elements that are defined in SVG
38539
+ // spec. All others are disallowed in SVG namespace.
38540
+ return Boolean(ALL_SVG_TAGS[tagName]);
38541
+ }
38542
+ if (element.namespaceURI === MATHML_NAMESPACE) {
38543
+ // The only way to switch from HTML namespace to MathML
38544
+ // is via <math>. If it happens via any other tag, then
38545
+ // it should be killed.
38546
+ if (parent.namespaceURI === HTML_NAMESPACE) {
38547
+ return tagName === 'math';
38548
+ }
38549
+
38550
+ // The only way to switch from SVG to MathML is via
38551
+ // <math> and HTML integration points
38552
+ if (parent.namespaceURI === SVG_NAMESPACE) {
38553
+ return tagName === 'math' && HTML_INTEGRATION_POINTS[parentTagName];
38554
+ }
38555
+
38556
+ // We only allow elements that are defined in MathML
38557
+ // spec. All others are disallowed in MathML namespace.
38558
+ return Boolean(ALL_MATHML_TAGS[tagName]);
38559
+ }
38560
+ if (element.namespaceURI === HTML_NAMESPACE) {
38561
+ // The only way to switch from SVG to HTML is via
38562
+ // HTML integration points, and from MathML to HTML
38563
+ // is via MathML text integration points
38564
+ if (parent.namespaceURI === SVG_NAMESPACE && !HTML_INTEGRATION_POINTS[parentTagName]) {
38565
+ return false;
38566
+ }
38567
+ if (parent.namespaceURI === MATHML_NAMESPACE && !MATHML_TEXT_INTEGRATION_POINTS[parentTagName]) {
38568
+ return false;
38569
+ }
38570
+
38571
+ // We disallow tags that are specific for MathML
38572
+ // or SVG and should never appear in HTML namespace
38573
+ return !ALL_MATHML_TAGS[tagName] && (COMMON_SVG_AND_HTML_ELEMENTS[tagName] || !ALL_SVG_TAGS[tagName]);
38574
+ }
38575
+
38576
+ // For XHTML and XML documents that support custom namespaces
38577
+ if (PARSER_MEDIA_TYPE === 'application/xhtml+xml' && ALLOWED_NAMESPACES[element.namespaceURI]) {
38578
+ return true;
38579
+ }
38580
+
38581
+ // The code should never reach this place (this means
38582
+ // that the element somehow got namespace that is not
38583
+ // HTML, SVG, MathML or allowed via ALLOWED_NAMESPACES).
38584
+ // Return false just in case.
38585
+ return false;
38586
+ };
38587
+
38588
+ /**
38589
+ * _forceRemove
38590
+ *
38591
+ * @param {Node} node a DOM node
38592
+ */
38593
+ const _forceRemove = function _forceRemove(node) {
38594
+ arrayPush(DOMPurify.removed, {
38595
+ element: node
38596
+ });
38597
+ try {
38598
+ // eslint-disable-next-line unicorn/prefer-dom-node-remove
38599
+ node.parentNode.removeChild(node);
38600
+ } catch (_) {
38601
+ node.remove();
38602
+ }
38603
+ };
38604
+
38605
+ /**
38606
+ * _removeAttribute
38607
+ *
38608
+ * @param {String} name an Attribute name
38609
+ * @param {Node} node a DOM node
38610
+ */
38611
+ const _removeAttribute = function _removeAttribute(name, node) {
38612
+ try {
38613
+ arrayPush(DOMPurify.removed, {
38614
+ attribute: node.getAttributeNode(name),
38615
+ from: node
38616
+ });
38617
+ } catch (_) {
38618
+ arrayPush(DOMPurify.removed, {
38619
+ attribute: null,
38620
+ from: node
38621
+ });
38622
+ }
38623
+ node.removeAttribute(name);
38624
+
38625
+ // We void attribute values for unremovable "is"" attributes
38626
+ if (name === 'is' && !ALLOWED_ATTR[name]) {
38627
+ if (RETURN_DOM || RETURN_DOM_FRAGMENT) {
38628
+ try {
38629
+ _forceRemove(node);
38630
+ } catch (_) {}
38631
+ } else {
38632
+ try {
38633
+ node.setAttribute(name, '');
38634
+ } catch (_) {}
38635
+ }
38636
+ }
38637
+ };
38638
+
38639
+ /**
38640
+ * _initDocument
38641
+ *
38642
+ * @param {String} dirty a string of dirty markup
38643
+ * @return {Document} a DOM, filled with the dirty markup
38644
+ */
38645
+ const _initDocument = function _initDocument(dirty) {
38646
+ /* Create a HTML document */
38647
+ let doc = null;
38648
+ let leadingWhitespace = null;
38649
+ if (FORCE_BODY) {
38650
+ dirty = '<remove></remove>' + dirty;
38651
+ } else {
38652
+ /* If FORCE_BODY isn't used, leading whitespace needs to be preserved manually */
38653
+ const matches = stringMatch(dirty, /^[\r\n\t ]+/);
38654
+ leadingWhitespace = matches && matches[0];
38655
+ }
38656
+ if (PARSER_MEDIA_TYPE === 'application/xhtml+xml' && NAMESPACE === HTML_NAMESPACE) {
38657
+ // Root of XHTML doc must contain xmlns declaration (see https://www.w3.org/TR/xhtml1/normative.html#strict)
38658
+ dirty = '<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>' + dirty + '</body></html>';
38659
+ }
38660
+ const dirtyPayload = trustedTypesPolicy ? trustedTypesPolicy.createHTML(dirty) : dirty;
38661
+ /*
38662
+ * Use the DOMParser API by default, fallback later if needs be
38663
+ * DOMParser not work for svg when has multiple root element.
38664
+ */
38665
+ if (NAMESPACE === HTML_NAMESPACE) {
38666
+ try {
38667
+ doc = new DOMParser().parseFromString(dirtyPayload, PARSER_MEDIA_TYPE);
38668
+ } catch (_) {}
38669
+ }
38670
+
38671
+ /* Use createHTMLDocument in case DOMParser is not available */
38672
+ if (!doc || !doc.documentElement) {
38673
+ doc = implementation.createDocument(NAMESPACE, 'template', null);
38674
+ try {
38675
+ doc.documentElement.innerHTML = IS_EMPTY_INPUT ? emptyHTML : dirtyPayload;
38676
+ } catch (_) {
38677
+ // Syntax error if dirtyPayload is invalid xml
38678
+ }
38679
+ }
38680
+ const body = doc.body || doc.documentElement;
38681
+ if (dirty && leadingWhitespace) {
38682
+ body.insertBefore(document.createTextNode(leadingWhitespace), body.childNodes[0] || null);
38683
+ }
38684
+
38685
+ /* Work on whole document or just its body */
38686
+ if (NAMESPACE === HTML_NAMESPACE) {
38687
+ return getElementsByTagName.call(doc, WHOLE_DOCUMENT ? 'html' : 'body')[0];
38688
+ }
38689
+ return WHOLE_DOCUMENT ? doc.documentElement : body;
38690
+ };
38691
+
38692
+ /**
38693
+ * Creates a NodeIterator object that you can use to traverse filtered lists of nodes or elements in a document.
38694
+ *
38695
+ * @param {Node} root The root element or node to start traversing on.
38696
+ * @return {NodeIterator} The created NodeIterator
38697
+ */
38698
+ const _createNodeIterator = function _createNodeIterator(root) {
38699
+ return createNodeIterator.call(root.ownerDocument || root, root,
38700
+ // eslint-disable-next-line no-bitwise
38701
+ NodeFilter.SHOW_ELEMENT | NodeFilter.SHOW_COMMENT | NodeFilter.SHOW_TEXT, null);
38702
+ };
38703
+
38704
+ /**
38705
+ * _isClobbered
38706
+ *
38707
+ * @param {Node} elm element to check for clobbering attacks
38708
+ * @return {Boolean} true if clobbered, false if safe
38709
+ */
38710
+ const _isClobbered = function _isClobbered(elm) {
38711
+ return elm instanceof HTMLFormElement && (typeof elm.nodeName !== 'string' || typeof elm.textContent !== 'string' || typeof elm.removeChild !== 'function' || !(elm.attributes instanceof NamedNodeMap) || typeof elm.removeAttribute !== 'function' || typeof elm.setAttribute !== 'function' || typeof elm.namespaceURI !== 'string' || typeof elm.insertBefore !== 'function' || typeof elm.hasChildNodes !== 'function');
38712
+ };
38713
+
38714
+ /**
38715
+ * Checks whether the given object is a DOM node.
38716
+ *
38717
+ * @param {Node} object object to check whether it's a DOM node
38718
+ * @return {Boolean} true is object is a DOM node
38719
+ */
38720
+ const _isNode = function _isNode(object) {
38721
+ return typeof Node === 'function' && object instanceof Node;
38722
+ };
38723
+
38724
+ /**
38725
+ * _executeHook
38726
+ * Execute user configurable hooks
38727
+ *
38728
+ * @param {String} entryPoint Name of the hook's entry point
38729
+ * @param {Node} currentNode node to work on with the hook
38730
+ * @param {Object} data additional hook parameters
38731
+ */
38732
+ const _executeHook = function _executeHook(entryPoint, currentNode, data) {
38733
+ if (!hooks[entryPoint]) {
38734
+ return;
38735
+ }
38736
+ arrayForEach(hooks[entryPoint], hook => {
38737
+ hook.call(DOMPurify, currentNode, data, CONFIG);
38738
+ });
38739
+ };
38740
+
38741
+ /**
38742
+ * _sanitizeElements
38743
+ *
38744
+ * @protect nodeName
38745
+ * @protect textContent
38746
+ * @protect removeChild
38747
+ *
38748
+ * @param {Node} currentNode to check for permission to exist
38749
+ * @return {Boolean} true if node was killed, false if left alive
38750
+ */
38751
+ const _sanitizeElements = function _sanitizeElements(currentNode) {
38752
+ let content = null;
38753
+
38754
+ /* Execute a hook if present */
38755
+ _executeHook('beforeSanitizeElements', currentNode, null);
38756
+
38757
+ /* Check if element is clobbered or can clobber */
38758
+ if (_isClobbered(currentNode)) {
38759
+ _forceRemove(currentNode);
38760
+ return true;
38761
+ }
38762
+
38763
+ /* Now let's check the element's type and name */
38764
+ const tagName = transformCaseFunc(currentNode.nodeName);
38765
+
38766
+ /* Execute a hook if present */
38767
+ _executeHook('uponSanitizeElement', currentNode, {
38768
+ tagName,
38769
+ allowedTags: ALLOWED_TAGS
38770
+ });
38771
+
38772
+ /* Detect mXSS attempts abusing namespace confusion */
38773
+ if (currentNode.hasChildNodes() && !_isNode(currentNode.firstElementChild) && regExpTest(/<[/\w]/g, currentNode.innerHTML) && regExpTest(/<[/\w]/g, currentNode.textContent)) {
38774
+ _forceRemove(currentNode);
38775
+ return true;
38776
+ }
38777
+
38778
+ /* Remove element if anything forbids its presence */
38779
+ if (!ALLOWED_TAGS[tagName] || FORBID_TAGS[tagName]) {
38780
+ /* Check if we have a custom element to handle */
38781
+ if (!FORBID_TAGS[tagName] && _isBasicCustomElement(tagName)) {
38782
+ if (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof RegExp && regExpTest(CUSTOM_ELEMENT_HANDLING.tagNameCheck, tagName)) {
38783
+ return false;
38784
+ }
38785
+ if (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof Function && CUSTOM_ELEMENT_HANDLING.tagNameCheck(tagName)) {
38786
+ return false;
38787
+ }
38788
+ }
38789
+
38790
+ /* Keep content except for bad-listed elements */
38791
+ if (KEEP_CONTENT && !FORBID_CONTENTS[tagName]) {
38792
+ const parentNode = getParentNode(currentNode) || currentNode.parentNode;
38793
+ const childNodes = getChildNodes(currentNode) || currentNode.childNodes;
38794
+ if (childNodes && parentNode) {
38795
+ const childCount = childNodes.length;
38796
+ for (let i = childCount - 1; i >= 0; --i) {
38797
+ parentNode.insertBefore(cloneNode(childNodes[i], true), getNextSibling(currentNode));
38798
+ }
38799
+ }
38800
+ }
38801
+ _forceRemove(currentNode);
38802
+ return true;
38803
+ }
38804
+
38805
+ /* Check whether element has a valid namespace */
38806
+ if (currentNode instanceof Element && !_checkValidNamespace(currentNode)) {
38807
+ _forceRemove(currentNode);
38808
+ return true;
38809
+ }
38810
+
38811
+ /* Make sure that older browsers don't get fallback-tag mXSS */
38812
+ if ((tagName === 'noscript' || tagName === 'noembed' || tagName === 'noframes') && regExpTest(/<\/no(script|embed|frames)/i, currentNode.innerHTML)) {
38813
+ _forceRemove(currentNode);
38814
+ return true;
38815
+ }
38816
+
38817
+ /* Sanitize element content to be template-safe */
38818
+ if (SAFE_FOR_TEMPLATES && currentNode.nodeType === 3) {
38819
+ /* Get the element's text content */
38820
+ content = currentNode.textContent;
38821
+ arrayForEach([MUSTACHE_EXPR, ERB_EXPR, TMPLIT_EXPR], expr => {
38822
+ content = stringReplace(content, expr, ' ');
38823
+ });
38824
+ if (currentNode.textContent !== content) {
38825
+ arrayPush(DOMPurify.removed, {
38826
+ element: currentNode.cloneNode()
38827
+ });
38828
+ currentNode.textContent = content;
38829
+ }
38830
+ }
38831
+
38832
+ /* Execute a hook if present */
38833
+ _executeHook('afterSanitizeElements', currentNode, null);
38834
+ return false;
38835
+ };
38836
+
38837
+ /**
38838
+ * _isValidAttribute
38839
+ *
38840
+ * @param {string} lcTag Lowercase tag name of containing element.
38841
+ * @param {string} lcName Lowercase attribute name.
38842
+ * @param {string} value Attribute value.
38843
+ * @return {Boolean} Returns true if `value` is valid, otherwise false.
38844
+ */
38845
+ // eslint-disable-next-line complexity
38846
+ const _isValidAttribute = function _isValidAttribute(lcTag, lcName, value) {
38847
+ /* Make sure attribute cannot clobber */
38848
+ if (SANITIZE_DOM && (lcName === 'id' || lcName === 'name') && (value in document || value in formElement)) {
38849
+ return false;
38850
+ }
38851
+
38852
+ /* Allow valid data-* attributes: At least one character after "-"
38853
+ (https://html.spec.whatwg.org/multipage/dom.html#embedding-custom-non-visible-data-with-the-data-*-attributes)
38854
+ XML-compatible (https://html.spec.whatwg.org/multipage/infrastructure.html#xml-compatible and http://www.w3.org/TR/xml/#d0e804)
38855
+ We don't need to check the value; it's always URI safe. */
38856
+ if (ALLOW_DATA_ATTR && !FORBID_ATTR[lcName] && regExpTest(DATA_ATTR, lcName)) ; else if (ALLOW_ARIA_ATTR && regExpTest(ARIA_ATTR, lcName)) ; else if (!ALLOWED_ATTR[lcName] || FORBID_ATTR[lcName]) {
38857
+ if (
38858
+ // First condition does a very basic check if a) it's basically a valid custom element tagname AND
38859
+ // b) if the tagName passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.tagNameCheck
38860
+ // and c) if the attribute name passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.attributeNameCheck
38861
+ _isBasicCustomElement(lcTag) && (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof RegExp && regExpTest(CUSTOM_ELEMENT_HANDLING.tagNameCheck, lcTag) || CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof Function && CUSTOM_ELEMENT_HANDLING.tagNameCheck(lcTag)) && (CUSTOM_ELEMENT_HANDLING.attributeNameCheck instanceof RegExp && regExpTest(CUSTOM_ELEMENT_HANDLING.attributeNameCheck, lcName) || CUSTOM_ELEMENT_HANDLING.attributeNameCheck instanceof Function && CUSTOM_ELEMENT_HANDLING.attributeNameCheck(lcName)) ||
38862
+ // Alternative, second condition checks if it's an `is`-attribute, AND
38863
+ // the value passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.tagNameCheck
38864
+ lcName === 'is' && CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements && (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof RegExp && regExpTest(CUSTOM_ELEMENT_HANDLING.tagNameCheck, value) || CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof Function && CUSTOM_ELEMENT_HANDLING.tagNameCheck(value))) ; else {
38865
+ return false;
38866
+ }
38867
+ /* Check value is safe. First, is attr inert? If so, is safe */
38868
+ } else if (URI_SAFE_ATTRIBUTES[lcName]) ; else if (regExpTest(IS_ALLOWED_URI$1, stringReplace(value, ATTR_WHITESPACE, ''))) ; else if ((lcName === 'src' || lcName === 'xlink:href' || lcName === 'href') && lcTag !== 'script' && stringIndexOf(value, 'data:') === 0 && DATA_URI_TAGS[lcTag]) ; else if (ALLOW_UNKNOWN_PROTOCOLS && !regExpTest(IS_SCRIPT_OR_DATA, stringReplace(value, ATTR_WHITESPACE, ''))) ; else if (value) {
38869
+ return false;
38870
+ } else ;
38871
+ return true;
38872
+ };
38873
+
38874
+ /**
38875
+ * _isBasicCustomElement
38876
+ * checks if at least one dash is included in tagName, and it's not the first char
38877
+ * for more sophisticated checking see https://github.com/sindresorhus/validate-element-name
38878
+ *
38879
+ * @param {string} tagName name of the tag of the node to sanitize
38880
+ * @returns {boolean} Returns true if the tag name meets the basic criteria for a custom element, otherwise false.
38881
+ */
38882
+ const _isBasicCustomElement = function _isBasicCustomElement(tagName) {
38883
+ return tagName.indexOf('-') > 0;
38884
+ };
38885
+
38886
+ /**
38887
+ * _sanitizeAttributes
38888
+ *
38889
+ * @protect attributes
38890
+ * @protect nodeName
38891
+ * @protect removeAttribute
38892
+ * @protect setAttribute
38893
+ *
38894
+ * @param {Node} currentNode to sanitize
38895
+ */
38896
+ const _sanitizeAttributes = function _sanitizeAttributes(currentNode) {
38897
+ /* Execute a hook if present */
38898
+ _executeHook('beforeSanitizeAttributes', currentNode, null);
38899
+ const {
38900
+ attributes
38901
+ } = currentNode;
38902
+
38903
+ /* Check if we have attributes; if not we might have a text node */
38904
+ if (!attributes) {
38905
+ return;
38906
+ }
38907
+ const hookEvent = {
38908
+ attrName: '',
38909
+ attrValue: '',
38910
+ keepAttr: true,
38911
+ allowedAttributes: ALLOWED_ATTR
38912
+ };
38913
+ let l = attributes.length;
38914
+
38915
+ /* Go backwards over all attributes; safely remove bad ones */
38916
+ while (l--) {
38917
+ const attr = attributes[l];
38918
+ const {
38919
+ name,
38920
+ namespaceURI,
38921
+ value: attrValue
38922
+ } = attr;
38923
+ const lcName = transformCaseFunc(name);
38924
+ let value = name === 'value' ? attrValue : stringTrim(attrValue);
38925
+
38926
+ /* Execute a hook if present */
38927
+ hookEvent.attrName = lcName;
38928
+ hookEvent.attrValue = value;
38929
+ hookEvent.keepAttr = true;
38930
+ hookEvent.forceKeepAttr = undefined; // Allows developers to see this is a property they can set
38931
+ _executeHook('uponSanitizeAttribute', currentNode, hookEvent);
38932
+ value = hookEvent.attrValue;
38933
+ /* Did the hooks approve of the attribute? */
38934
+ if (hookEvent.forceKeepAttr) {
38935
+ continue;
38936
+ }
38937
+
38938
+ /* Remove attribute */
38939
+ _removeAttribute(name, currentNode);
38940
+
38941
+ /* Did the hooks approve of the attribute? */
38942
+ if (!hookEvent.keepAttr) {
38943
+ continue;
38944
+ }
38945
+
38946
+ /* Work around a security issue in jQuery 3.0 */
38947
+ if (!ALLOW_SELF_CLOSE_IN_ATTR && regExpTest(/\/>/i, value)) {
38948
+ _removeAttribute(name, currentNode);
38949
+ continue;
38950
+ }
38951
+
38952
+ /* Sanitize attribute content to be template-safe */
38953
+ if (SAFE_FOR_TEMPLATES) {
38954
+ arrayForEach([MUSTACHE_EXPR, ERB_EXPR, TMPLIT_EXPR], expr => {
38955
+ value = stringReplace(value, expr, ' ');
38956
+ });
38957
+ }
38958
+
38959
+ /* Is `value` valid for this attribute? */
38960
+ const lcTag = transformCaseFunc(currentNode.nodeName);
38961
+ if (!_isValidAttribute(lcTag, lcName, value)) {
38962
+ continue;
38963
+ }
38964
+
38965
+ /* Full DOM Clobbering protection via namespace isolation,
38966
+ * Prefix id and name attributes with `user-content-`
38967
+ */
38968
+ if (SANITIZE_NAMED_PROPS && (lcName === 'id' || lcName === 'name')) {
38969
+ // Remove the attribute with this value
38970
+ _removeAttribute(name, currentNode);
38971
+
38972
+ // Prefix the value and later re-create the attribute with the sanitized value
38973
+ value = SANITIZE_NAMED_PROPS_PREFIX + value;
38974
+ }
38975
+
38976
+ /* Handle attributes that require Trusted Types */
38977
+ if (trustedTypesPolicy && typeof trustedTypes === 'object' && typeof trustedTypes.getAttributeType === 'function') {
38978
+ if (namespaceURI) ; else {
38979
+ switch (trustedTypes.getAttributeType(lcTag, lcName)) {
38980
+ case 'TrustedHTML':
38981
+ {
38982
+ value = trustedTypesPolicy.createHTML(value);
38983
+ break;
38984
+ }
38985
+ case 'TrustedScriptURL':
38986
+ {
38987
+ value = trustedTypesPolicy.createScriptURL(value);
38988
+ break;
38989
+ }
38990
+ }
38991
+ }
38992
+ }
38993
+
38994
+ /* Handle invalid data-* attribute set by try-catching it */
38995
+ try {
38996
+ if (namespaceURI) {
38997
+ currentNode.setAttributeNS(namespaceURI, name, value);
38998
+ } else {
38999
+ /* Fallback to setAttribute() for browser-unrecognized namespaces e.g. "x-schema". */
39000
+ currentNode.setAttribute(name, value);
39001
+ }
39002
+ arrayPop(DOMPurify.removed);
39003
+ } catch (_) {}
39004
+ }
39005
+
39006
+ /* Execute a hook if present */
39007
+ _executeHook('afterSanitizeAttributes', currentNode, null);
39008
+ };
39009
+
39010
+ /**
39011
+ * _sanitizeShadowDOM
39012
+ *
39013
+ * @param {DocumentFragment} fragment to iterate over recursively
39014
+ */
39015
+ const _sanitizeShadowDOM = function _sanitizeShadowDOM(fragment) {
39016
+ let shadowNode = null;
39017
+ const shadowIterator = _createNodeIterator(fragment);
39018
+
39019
+ /* Execute a hook if present */
39020
+ _executeHook('beforeSanitizeShadowDOM', fragment, null);
39021
+ while (shadowNode = shadowIterator.nextNode()) {
39022
+ /* Execute a hook if present */
39023
+ _executeHook('uponSanitizeShadowNode', shadowNode, null);
39024
+
39025
+ /* Sanitize tags and elements */
39026
+ if (_sanitizeElements(shadowNode)) {
39027
+ continue;
39028
+ }
39029
+
39030
+ /* Deep shadow DOM detected */
39031
+ if (shadowNode.content instanceof DocumentFragment) {
39032
+ _sanitizeShadowDOM(shadowNode.content);
39033
+ }
39034
+
39035
+ /* Check attributes, sanitize if necessary */
39036
+ _sanitizeAttributes(shadowNode);
39037
+ }
39038
+
39039
+ /* Execute a hook if present */
39040
+ _executeHook('afterSanitizeShadowDOM', fragment, null);
39041
+ };
39042
+
39043
+ /**
39044
+ * Sanitize
39045
+ * Public method providing core sanitation functionality
39046
+ *
39047
+ * @param {String|Node} dirty string or DOM node
39048
+ * @param {Object} cfg object
39049
+ */
39050
+ // eslint-disable-next-line complexity
39051
+ DOMPurify.sanitize = function (dirty) {
39052
+ let cfg = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
39053
+ let body = null;
39054
+ let importedNode = null;
39055
+ let currentNode = null;
39056
+ let returnNode = null;
39057
+ /* Make sure we have a string to sanitize.
39058
+ DO NOT return early, as this will return the wrong type if
39059
+ the user has requested a DOM object rather than a string */
39060
+ IS_EMPTY_INPUT = !dirty;
39061
+ if (IS_EMPTY_INPUT) {
39062
+ dirty = '<!-->';
39063
+ }
39064
+
39065
+ /* Stringify, in case dirty is an object */
39066
+ if (typeof dirty !== 'string' && !_isNode(dirty)) {
39067
+ if (typeof dirty.toString === 'function') {
39068
+ dirty = dirty.toString();
39069
+ if (typeof dirty !== 'string') {
39070
+ throw typeErrorCreate('dirty is not a string, aborting');
39071
+ }
39072
+ } else {
39073
+ throw typeErrorCreate('toString is not a function');
39074
+ }
39075
+ }
39076
+
39077
+ /* Return dirty HTML if DOMPurify cannot run */
39078
+ if (!DOMPurify.isSupported) {
39079
+ return dirty;
39080
+ }
39081
+
39082
+ /* Assign config vars */
39083
+ if (!SET_CONFIG) {
39084
+ _parseConfig(cfg);
39085
+ }
39086
+
39087
+ /* Clean up removed elements */
39088
+ DOMPurify.removed = [];
39089
+
39090
+ /* Check if dirty is correctly typed for IN_PLACE */
39091
+ if (typeof dirty === 'string') {
39092
+ IN_PLACE = false;
39093
+ }
39094
+ if (IN_PLACE) {
39095
+ /* Do some early pre-sanitization to avoid unsafe root nodes */
39096
+ if (dirty.nodeName) {
39097
+ const tagName = transformCaseFunc(dirty.nodeName);
39098
+ if (!ALLOWED_TAGS[tagName] || FORBID_TAGS[tagName]) {
39099
+ throw typeErrorCreate('root node is forbidden and cannot be sanitized in-place');
39100
+ }
39101
+ }
39102
+ } else if (dirty instanceof Node) {
39103
+ /* If dirty is a DOM element, append to an empty document to avoid
39104
+ elements being stripped by the parser */
39105
+ body = _initDocument('<!---->');
39106
+ importedNode = body.ownerDocument.importNode(dirty, true);
39107
+ if (importedNode.nodeType === 1 && importedNode.nodeName === 'BODY') {
39108
+ /* Node is already a body, use as is */
39109
+ body = importedNode;
39110
+ } else if (importedNode.nodeName === 'HTML') {
39111
+ body = importedNode;
39112
+ } else {
39113
+ // eslint-disable-next-line unicorn/prefer-dom-node-append
39114
+ body.appendChild(importedNode);
39115
+ }
39116
+ } else {
39117
+ /* Exit directly if we have nothing to do */
39118
+ if (!RETURN_DOM && !SAFE_FOR_TEMPLATES && !WHOLE_DOCUMENT &&
39119
+ // eslint-disable-next-line unicorn/prefer-includes
39120
+ dirty.indexOf('<') === -1) {
39121
+ return trustedTypesPolicy && RETURN_TRUSTED_TYPE ? trustedTypesPolicy.createHTML(dirty) : dirty;
39122
+ }
39123
+
39124
+ /* Initialize the document to work on */
39125
+ body = _initDocument(dirty);
39126
+
39127
+ /* Check we have a DOM node from the data */
39128
+ if (!body) {
39129
+ return RETURN_DOM ? null : RETURN_TRUSTED_TYPE ? emptyHTML : '';
39130
+ }
39131
+ }
39132
+
39133
+ /* Remove first element node (ours) if FORCE_BODY is set */
39134
+ if (body && FORCE_BODY) {
39135
+ _forceRemove(body.firstChild);
39136
+ }
39137
+
39138
+ /* Get node iterator */
39139
+ const nodeIterator = _createNodeIterator(IN_PLACE ? dirty : body);
39140
+
39141
+ /* Now start iterating over the created document */
39142
+ while (currentNode = nodeIterator.nextNode()) {
39143
+ /* Sanitize tags and elements */
39144
+ if (_sanitizeElements(currentNode)) {
39145
+ continue;
39146
+ }
39147
+
39148
+ /* Shadow DOM detected, sanitize it */
39149
+ if (currentNode.content instanceof DocumentFragment) {
39150
+ _sanitizeShadowDOM(currentNode.content);
39151
+ }
39152
+
39153
+ /* Check attributes, sanitize if necessary */
39154
+ _sanitizeAttributes(currentNode);
39155
+ }
39156
+
39157
+ /* If we sanitized `dirty` in-place, return it. */
39158
+ if (IN_PLACE) {
39159
+ return dirty;
39160
+ }
39161
+
39162
+ /* Return sanitized string or DOM */
39163
+ if (RETURN_DOM) {
39164
+ if (RETURN_DOM_FRAGMENT) {
39165
+ returnNode = createDocumentFragment.call(body.ownerDocument);
39166
+ while (body.firstChild) {
39167
+ // eslint-disable-next-line unicorn/prefer-dom-node-append
39168
+ returnNode.appendChild(body.firstChild);
39169
+ }
39170
+ } else {
39171
+ returnNode = body;
39172
+ }
39173
+ if (ALLOWED_ATTR.shadowroot || ALLOWED_ATTR.shadowrootmode) {
39174
+ /*
39175
+ AdoptNode() is not used because internal state is not reset
39176
+ (e.g. the past names map of a HTMLFormElement), this is safe
39177
+ in theory but we would rather not risk another attack vector.
39178
+ The state that is cloned by importNode() is explicitly defined
39179
+ by the specs.
39180
+ */
39181
+ returnNode = importNode.call(originalDocument, returnNode, true);
39182
+ }
39183
+ return returnNode;
39184
+ }
39185
+ let serializedHTML = WHOLE_DOCUMENT ? body.outerHTML : body.innerHTML;
39186
+
39187
+ /* Serialize doctype if allowed */
39188
+ if (WHOLE_DOCUMENT && ALLOWED_TAGS['!doctype'] && body.ownerDocument && body.ownerDocument.doctype && body.ownerDocument.doctype.name && regExpTest(DOCTYPE_NAME, body.ownerDocument.doctype.name)) {
39189
+ serializedHTML = '<!DOCTYPE ' + body.ownerDocument.doctype.name + '>\n' + serializedHTML;
39190
+ }
39191
+
39192
+ /* Sanitize final string template-safe */
39193
+ if (SAFE_FOR_TEMPLATES) {
39194
+ arrayForEach([MUSTACHE_EXPR, ERB_EXPR, TMPLIT_EXPR], expr => {
39195
+ serializedHTML = stringReplace(serializedHTML, expr, ' ');
39196
+ });
39197
+ }
39198
+ return trustedTypesPolicy && RETURN_TRUSTED_TYPE ? trustedTypesPolicy.createHTML(serializedHTML) : serializedHTML;
39199
+ };
39200
+
39201
+ /**
39202
+ * Public method to set the configuration once
39203
+ * setConfig
39204
+ *
39205
+ * @param {Object} cfg configuration object
39206
+ */
39207
+ DOMPurify.setConfig = function () {
39208
+ let cfg = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
39209
+ _parseConfig(cfg);
39210
+ SET_CONFIG = true;
39211
+ };
39212
+
39213
+ /**
39214
+ * Public method to remove the configuration
39215
+ * clearConfig
39216
+ *
39217
+ */
39218
+ DOMPurify.clearConfig = function () {
39219
+ CONFIG = null;
39220
+ SET_CONFIG = false;
39221
+ };
39222
+
39223
+ /**
39224
+ * Public method to check if an attribute value is valid.
39225
+ * Uses last set config, if any. Otherwise, uses config defaults.
39226
+ * isValidAttribute
39227
+ *
39228
+ * @param {String} tag Tag name of containing element.
39229
+ * @param {String} attr Attribute name.
39230
+ * @param {String} value Attribute value.
39231
+ * @return {Boolean} Returns true if `value` is valid. Otherwise, returns false.
39232
+ */
39233
+ DOMPurify.isValidAttribute = function (tag, attr, value) {
39234
+ /* Initialize shared config vars if necessary. */
39235
+ if (!CONFIG) {
39236
+ _parseConfig({});
39237
+ }
39238
+ const lcTag = transformCaseFunc(tag);
39239
+ const lcName = transformCaseFunc(attr);
39240
+ return _isValidAttribute(lcTag, lcName, value);
39241
+ };
39242
+
39243
+ /**
39244
+ * AddHook
39245
+ * Public method to add DOMPurify hooks
39246
+ *
39247
+ * @param {String} entryPoint entry point for the hook to add
39248
+ * @param {Function} hookFunction function to execute
39249
+ */
39250
+ DOMPurify.addHook = function (entryPoint, hookFunction) {
39251
+ if (typeof hookFunction !== 'function') {
39252
+ return;
39253
+ }
39254
+ hooks[entryPoint] = hooks[entryPoint] || [];
39255
+ arrayPush(hooks[entryPoint], hookFunction);
39256
+ };
39257
+
39258
+ /**
39259
+ * RemoveHook
39260
+ * Public method to remove a DOMPurify hook at a given entryPoint
39261
+ * (pops it from the stack of hooks if more are present)
39262
+ *
39263
+ * @param {String} entryPoint entry point for the hook to remove
39264
+ * @return {Function} removed(popped) hook
39265
+ */
39266
+ DOMPurify.removeHook = function (entryPoint) {
39267
+ if (hooks[entryPoint]) {
39268
+ return arrayPop(hooks[entryPoint]);
39269
+ }
39270
+ };
39271
+
39272
+ /**
39273
+ * RemoveHooks
39274
+ * Public method to remove all DOMPurify hooks at a given entryPoint
39275
+ *
39276
+ * @param {String} entryPoint entry point for the hooks to remove
39277
+ */
39278
+ DOMPurify.removeHooks = function (entryPoint) {
39279
+ if (hooks[entryPoint]) {
39280
+ hooks[entryPoint] = [];
39281
+ }
39282
+ };
39283
+
39284
+ /**
39285
+ * RemoveAllHooks
39286
+ * Public method to remove all DOMPurify hooks
39287
+ */
39288
+ DOMPurify.removeAllHooks = function () {
39289
+ hooks = {};
39290
+ };
39291
+ return DOMPurify;
39292
+ }
39293
+ var purify = createDOMPurify();
39294
+
39295
+ return purify;
39296
+
39297
+ }));
39298
+ //# sourceMappingURL=purify.js.map
39299
+
39300
+
37760
39301
  /***/ }),
37761
39302
 
37762
39303
  /***/ 3462: