@inboxsdk/core 2.1.33 → 2.1.35

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.
Files changed (25) hide show
  1. package/inboxsdk.js +146 -1580
  2. package/package.json +1 -1
  3. package/pageWorld.js +45 -1530
  4. package/src/common/html-to-text.d.ts +10 -22
  5. package/src/common/html-to-text.d.ts.map +1 -1
  6. package/src/common/removeHtmlTags.d.ts +25 -0
  7. package/src/common/removeHtmlTags.d.ts.map +1 -0
  8. package/src/inboxsdk-js/header.d.ts +1 -0
  9. package/src/inboxsdk-js/header.d.ts.map +1 -1
  10. package/src/injected-js/main.d.ts +1 -1
  11. package/src/injected-js/main.d.ts.map +1 -1
  12. package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/track-gmail-styles.d.ts +4 -1
  13. package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/track-gmail-styles.d.ts.map +1 -1
  14. package/src/platform-implementation-js/dom-driver/gmail/gmail-driver.d.ts +13 -0
  15. package/src/platform-implementation-js/dom-driver/gmail/gmail-driver.d.ts.map +1 -1
  16. package/src/platform-implementation-js/dom-driver/gmail/gmail-element-getter.d.ts +1 -0
  17. package/src/platform-implementation-js/dom-driver/gmail/gmail-element-getter.d.ts.map +1 -1
  18. package/src/platform-implementation-js/dom-driver/gmail/views/gmail-app-sidebar-view/primary/add-to-icon-area.d.ts +1 -0
  19. package/src/platform-implementation-js/dom-driver/gmail/views/gmail-app-sidebar-view/primary/add-to-icon-area.d.ts.map +1 -1
  20. package/src/platform-implementation-js/dom-driver/gmail/views/gmail-collapsible-section-view.d.ts +1 -1
  21. package/src/platform-implementation-js/dom-driver/gmail/views/gmail-collapsible-section-view.d.ts.map +1 -1
  22. package/src/platform-implementation-js/dom-driver/gmail/views/gmail-thread-row-view.d.ts +9 -8
  23. package/src/platform-implementation-js/dom-driver/gmail/views/gmail-thread-row-view.d.ts.map +1 -1
  24. package/src/platform-implementation-js/namespaces/global.d.ts +7 -1
  25. package/src/platform-implementation-js/namespaces/global.d.ts.map +1 -1
package/pageWorld.js CHANGED
@@ -235,31 +235,62 @@ function assert(condition, message) {
235
235
 
236
236
  /***/ }),
237
237
 
238
- /***/ 9865:
238
+ /***/ 7954:
239
239
  /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
240
240
 
241
241
  "use strict";
242
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
243
- /* harmony export */ "Z": () => (/* binding */ htmlToText)
244
- /* harmony export */ });
245
- /* harmony import */ var dompurify__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(7856);
246
- /* harmony import */ var dompurify__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(dompurify__WEBPACK_IMPORTED_MODULE_0__);
247
242
 
248
- const escapeHTMLPolicy = globalThis.trustedTypes?.createPolicy('inboxSdkEscapePolicy', {
249
- createHTML: string => (0,dompurify__WEBPACK_IMPORTED_MODULE_0__.sanitize)(string)
243
+ // EXPORTS
244
+ __webpack_require__.d(__webpack_exports__, {
245
+ "Z": () => (/* binding */ htmlToText)
246
+ });
247
+
248
+ ;// CONCATENATED MODULE: ./src/common/removeHtmlTags.ts
249
+ /**
250
+ * This function removes all HTML tags from a string.
251
+ * The resulting string may still contain HTML entities and not be suitable to display as plain text.
252
+ *
253
+ * This function's output will never contain `<` and therefore will never contain any HTML
254
+ * tags, so it's safe to use this on arbitrary input and assign the result to an element's
255
+ * innerHTML property.
256
+ *
257
+ * @see Use [htmlToText](./html-to-text.ts) instead if you want to convert HTML to
258
+ * unformatted text to display.
259
+ */
260
+ function removeHtmlTags(html) {
261
+ return html.replace(/<[^>]*>?/g, '');
262
+ }
263
+
264
+ /**
265
+ * This policy object is used to strip HTML tags from a string.
266
+ */
267
+ const removeHtmlTagsPolicy = globalThis.trustedTypes?.createPolicy('inboxSdk__removeHtmlTagsPolicy', {
268
+ createHTML(string) {
269
+ return removeHtmlTags(string);
270
+ }
250
271
  }) ?? {
251
272
  createHTML(string) {
252
- return (0,dompurify__WEBPACK_IMPORTED_MODULE_0__.sanitize)(string);
273
+ return removeHtmlTags(string);
253
274
  }
254
275
  };
276
+ ;// CONCATENATED MODULE: ./src/common/html-to-text.ts
277
+
255
278
 
256
279
  /**
257
- * Quick function for converting HTML with entities into text without
258
- * introducing an XSS vulnerability.
280
+ * Converts HTML to unformatted plain text.
281
+ * Works by stripping all HTML tags and converting entities to symbols.
282
+ * Safe to use on arbitrary input.
283
+ *
284
+ * Converts text like `String with <b>html</b> &amp; entities &lt;&gt;` to
285
+ * `String with html & entities <>`.
286
+ *
287
+ * This is *not* for creating "safe HTML" from user input to assign to
288
+ * an element's innerHTML. The result of this function should not be treated
289
+ * as HTML.
259
290
  */
260
291
  function htmlToText(html) {
261
292
  const div = document.createElement('div');
262
- div.innerHTML = escapeHTMLPolicy.createHTML(html);
293
+ div.innerHTML = removeHtmlTagsPolicy.createHTML(html);
263
294
  return div.textContent;
264
295
  }
265
296
 
@@ -277,7 +308,7 @@ function htmlToText(html) {
277
308
  /* harmony import */ var auto_html__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(5408);
278
309
  /* harmony import */ var auto_html__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(auto_html__WEBPACK_IMPORTED_MODULE_3__);
279
310
  /* harmony import */ var ud__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(1010);
280
- /* harmony import */ var _common_html_to_text__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(9865);
311
+ /* harmony import */ var _common_html_to_text__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(7954);
281
312
  /* harmony import */ var _platform_implementation_js_dom_driver_gmail_gmail_response_processor__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(6139);
282
313
  /* module decorator */ module = __webpack_require__.hmd(module);
283
314
 
@@ -3744,7 +3775,7 @@ function xhrHelper() {
3744
3775
  /* harmony import */ var lodash_last__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(lodash_last__WEBPACK_IMPORTED_MODULE_1__);
3745
3776
  /* harmony import */ var transducers_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(1095);
3746
3777
  /* harmony import */ var transducers_js__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(transducers_js__WEBPACK_IMPORTED_MODULE_2__);
3747
- /* harmony import */ var _common_html_to_text__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(9865);
3778
+ /* harmony import */ var _common_html_to_text__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(7954);
3748
3779
  /* harmony import */ var _common_assert__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(9817);
3749
3780
 
3750
3781
 
@@ -7386,1522 +7417,6 @@ module.exports = exports.default;
7386
7417
  module.exports["default"] = exports.default;
7387
7418
  //# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uL3NyYy9pbmRleC5qcyJdLCJuYW1lcyI6WyJwcm90byIsImdsb2JhbCIsIkVsZW1lbnQiLCJwcm90b3R5cGUiLCJ2ZW5kb3IiLCJjbG9zZXN0IiwiZWxlbWVudCIsInNlbGVjdG9yIiwiY2FsbCIsInBhcmVudCIsInBhcmVudE5vZGUiLCJkb2N1bWVudCJdLCJtYXBwaW5ncyI6Ijs7Ozs7QUFFQTs7OztBQUVBLElBQU1BLEtBQUssR0FBR0MsTUFBTSxDQUFDQyxPQUFQLElBQWtCRCxNQUFNLENBQUNDLE9BQVAsQ0FBZUMsU0FBL0M7QUFDQSxJQUFNQyxNQUFNLEdBQUdKLEtBQUssSUFBSUEsS0FBSyxDQUFDSyxPQUE5Qjs7QUFFZSxTQUFTQSxPQUFULENBQWlCQyxPQUFqQixFQUF1Q0MsUUFBdkMsRUFBNkU7QUFDMUYsTUFBSUgsTUFBSixFQUFZLE9BQU9BLE1BQU0sQ0FBQ0ksSUFBUCxDQUFZRixPQUFaLEVBQXFCQyxRQUFyQixDQUFQO0FBQ1osTUFBSUUsTUFBTSxHQUFHSCxPQUFiOztBQUNBLEtBQUc7QUFDRCxRQUFJLGdDQUFRRyxNQUFSLEVBQWdCRixRQUFoQixDQUFKLEVBQStCLE9BQU9FLE1BQVA7QUFDL0JBLElBQUFBLE1BQU0sR0FBR0EsTUFBTSxDQUFDQyxVQUFoQjtBQUNELEdBSEQsUUFHU0QsTUFBTSxJQUFJQSxNQUFNLEtBQUtSLE1BQU0sQ0FBQ1UsUUFIckM7O0FBSUEsU0FBTyxJQUFQO0FBQ0QiLCJzb3VyY2VzQ29udGVudCI6WyIvKiBAZmxvdyAqL1xuXG5pbXBvcnQgbWF0Y2hlcyBmcm9tICdtYXRjaGVzLXNlbGVjdG9yLW5nJztcblxuY29uc3QgcHJvdG8gPSBnbG9iYWwuRWxlbWVudCAmJiBnbG9iYWwuRWxlbWVudC5wcm90b3R5cGU7XG5jb25zdCB2ZW5kb3IgPSBwcm90byAmJiBwcm90by5jbG9zZXN0O1xuXG5leHBvcnQgZGVmYXVsdCBmdW5jdGlvbiBjbG9zZXN0KGVsZW1lbnQ6IEhUTUxFbGVtZW50LCBzZWxlY3Rvcjogc3RyaW5nKTogSFRNTEVsZW1lbnQgfCBudWxsIHtcbiAgaWYgKHZlbmRvcikgcmV0dXJuIHZlbmRvci5jYWxsKGVsZW1lbnQsIHNlbGVjdG9yKTtcbiAgbGV0IHBhcmVudCA9IGVsZW1lbnQ7XG4gIGRvIHtcbiAgICBpZiAobWF0Y2hlcyhwYXJlbnQsIHNlbGVjdG9yKSkgcmV0dXJuIHBhcmVudDtcbiAgICBwYXJlbnQgPSBwYXJlbnQucGFyZW50Tm9kZTtcbiAgfSB3aGlsZSAocGFyZW50ICYmIHBhcmVudCAhPT0gZ2xvYmFsLmRvY3VtZW50KTtcbiAgcmV0dXJuIG51bGw7XG59XG4iXX0=
7388
7419
 
7389
- /***/ }),
7390
-
7391
- /***/ 7856:
7392
- /***/ (function(module) {
7393
-
7394
- /*! @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 */
7395
-
7396
- (function (global, factory) {
7397
- true ? module.exports = factory() :
7398
- 0;
7399
- })(this, (function () { 'use strict';
7400
-
7401
- const {
7402
- entries,
7403
- setPrototypeOf,
7404
- isFrozen,
7405
- getPrototypeOf,
7406
- getOwnPropertyDescriptor
7407
- } = Object;
7408
- let {
7409
- freeze,
7410
- seal,
7411
- create
7412
- } = Object; // eslint-disable-line import/no-mutable-exports
7413
- let {
7414
- apply,
7415
- construct
7416
- } = typeof Reflect !== 'undefined' && Reflect;
7417
- if (!freeze) {
7418
- freeze = function freeze(x) {
7419
- return x;
7420
- };
7421
- }
7422
- if (!seal) {
7423
- seal = function seal(x) {
7424
- return x;
7425
- };
7426
- }
7427
- if (!apply) {
7428
- apply = function apply(fun, thisValue, args) {
7429
- return fun.apply(thisValue, args);
7430
- };
7431
- }
7432
- if (!construct) {
7433
- construct = function construct(Func, args) {
7434
- return new Func(...args);
7435
- };
7436
- }
7437
- const arrayForEach = unapply(Array.prototype.forEach);
7438
- const arrayPop = unapply(Array.prototype.pop);
7439
- const arrayPush = unapply(Array.prototype.push);
7440
- const stringToLowerCase = unapply(String.prototype.toLowerCase);
7441
- const stringToString = unapply(String.prototype.toString);
7442
- const stringMatch = unapply(String.prototype.match);
7443
- const stringReplace = unapply(String.prototype.replace);
7444
- const stringIndexOf = unapply(String.prototype.indexOf);
7445
- const stringTrim = unapply(String.prototype.trim);
7446
- const regExpTest = unapply(RegExp.prototype.test);
7447
- const typeErrorCreate = unconstruct(TypeError);
7448
-
7449
- /**
7450
- * Creates a new function that calls the given function with a specified thisArg and arguments.
7451
- *
7452
- * @param {Function} func - The function to be wrapped and called.
7453
- * @returns {Function} A new function that calls the given function with a specified thisArg and arguments.
7454
- */
7455
- function unapply(func) {
7456
- return function (thisArg) {
7457
- for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
7458
- args[_key - 1] = arguments[_key];
7459
- }
7460
- return apply(func, thisArg, args);
7461
- };
7462
- }
7463
-
7464
- /**
7465
- * Creates a new function that constructs an instance of the given constructor function with the provided arguments.
7466
- *
7467
- * @param {Function} func - The constructor function to be wrapped and called.
7468
- * @returns {Function} A new function that constructs an instance of the given constructor function with the provided arguments.
7469
- */
7470
- function unconstruct(func) {
7471
- return function () {
7472
- for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
7473
- args[_key2] = arguments[_key2];
7474
- }
7475
- return construct(func, args);
7476
- };
7477
- }
7478
-
7479
- /**
7480
- * Add properties to a lookup table
7481
- *
7482
- * @param {Object} set - The set to which elements will be added.
7483
- * @param {Array} array - The array containing elements to be added to the set.
7484
- * @param {Function} transformCaseFunc - An optional function to transform the case of each element before adding to the set.
7485
- * @returns {Object} The modified set with added elements.
7486
- */
7487
- function addToSet(set, array) {
7488
- let transformCaseFunc = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : stringToLowerCase;
7489
- if (setPrototypeOf) {
7490
- // Make 'in' and truthy checks like Boolean(set.constructor)
7491
- // independent of any properties defined on Object.prototype.
7492
- // Prevent prototype setters from intercepting set as a this value.
7493
- setPrototypeOf(set, null);
7494
- }
7495
- let l = array.length;
7496
- while (l--) {
7497
- let element = array[l];
7498
- if (typeof element === 'string') {
7499
- const lcElement = transformCaseFunc(element);
7500
- if (lcElement !== element) {
7501
- // Config presets (e.g. tags.js, attrs.js) are immutable.
7502
- if (!isFrozen(array)) {
7503
- array[l] = lcElement;
7504
- }
7505
- element = lcElement;
7506
- }
7507
- }
7508
- set[element] = true;
7509
- }
7510
- return set;
7511
- }
7512
-
7513
- /**
7514
- * Clean up an array to harden against CSPP
7515
- *
7516
- * @param {Array} array - The array to be cleaned.
7517
- * @returns {Array} The cleaned version of the array
7518
- */
7519
- function cleanArray(array) {
7520
- for (let index = 0; index < array.length; index++) {
7521
- if (getOwnPropertyDescriptor(array, index) === undefined) {
7522
- array[index] = null;
7523
- }
7524
- }
7525
- return array;
7526
- }
7527
-
7528
- /**
7529
- * Shallow clone an object
7530
- *
7531
- * @param {Object} object - The object to be cloned.
7532
- * @returns {Object} A new object that copies the original.
7533
- */
7534
- function clone(object) {
7535
- const newObject = create(null);
7536
- for (const [property, value] of entries(object)) {
7537
- if (getOwnPropertyDescriptor(object, property) !== undefined) {
7538
- if (Array.isArray(value)) {
7539
- newObject[property] = cleanArray(value);
7540
- } else if (value && typeof value === 'object' && value.constructor === Object) {
7541
- newObject[property] = clone(value);
7542
- } else {
7543
- newObject[property] = value;
7544
- }
7545
- }
7546
- }
7547
- return newObject;
7548
- }
7549
-
7550
- /**
7551
- * This method automatically checks if the prop is function or getter and behaves accordingly.
7552
- *
7553
- * @param {Object} object - The object to look up the getter function in its prototype chain.
7554
- * @param {String} prop - The property name for which to find the getter function.
7555
- * @returns {Function} The getter function found in the prototype chain or a fallback function.
7556
- */
7557
- function lookupGetter(object, prop) {
7558
- while (object !== null) {
7559
- const desc = getOwnPropertyDescriptor(object, prop);
7560
- if (desc) {
7561
- if (desc.get) {
7562
- return unapply(desc.get);
7563
- }
7564
- if (typeof desc.value === 'function') {
7565
- return unapply(desc.value);
7566
- }
7567
- }
7568
- object = getPrototypeOf(object);
7569
- }
7570
- function fallbackValue(element) {
7571
- console.warn('fallback value for', element);
7572
- return null;
7573
- }
7574
- return fallbackValue;
7575
- }
7576
-
7577
- 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']);
7578
-
7579
- // SVG
7580
- 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']);
7581
- 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']);
7582
-
7583
- // List of SVG elements that are disallowed by default.
7584
- // We still need to know them so that we can do namespace
7585
- // checks properly in case one wants to add them to
7586
- // allow-list.
7587
- 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']);
7588
- 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']);
7589
-
7590
- // Similarly to SVG, we want to know all MathML elements,
7591
- // even those that we disallow by default.
7592
- const mathMlDisallowed = freeze(['maction', 'maligngroup', 'malignmark', 'mlongdiv', 'mscarries', 'mscarry', 'msgroup', 'mstack', 'msline', 'msrow', 'semantics', 'annotation', 'annotation-xml', 'mprescripts', 'none']);
7593
- const text = freeze(['#text']);
7594
-
7595
- 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']);
7596
- 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']);
7597
- 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']);
7598
- const xml = freeze(['xlink:href', 'xml:id', 'xlink:title', 'xml:space', 'xmlns:xlink']);
7599
-
7600
- // eslint-disable-next-line unicorn/better-regex
7601
- const MUSTACHE_EXPR = seal(/\{\{[\w\W]*|[\w\W]*\}\}/gm); // Specify template detection regex for SAFE_FOR_TEMPLATES mode
7602
- const ERB_EXPR = seal(/<%[\w\W]*|[\w\W]*%>/gm);
7603
- const TMPLIT_EXPR = seal(/\${[\w\W]*}/gm);
7604
- const DATA_ATTR = seal(/^data-[\-\w.\u00B7-\uFFFF]/); // eslint-disable-line no-useless-escape
7605
- const ARIA_ATTR = seal(/^aria-[\-\w]+$/); // eslint-disable-line no-useless-escape
7606
- 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
7607
- );
7608
-
7609
- const IS_SCRIPT_OR_DATA = seal(/^(?:\w+script|data):/i);
7610
- const ATTR_WHITESPACE = seal(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g // eslint-disable-line no-control-regex
7611
- );
7612
-
7613
- const DOCTYPE_NAME = seal(/^html$/i);
7614
-
7615
- var EXPRESSIONS = /*#__PURE__*/Object.freeze({
7616
- __proto__: null,
7617
- MUSTACHE_EXPR: MUSTACHE_EXPR,
7618
- ERB_EXPR: ERB_EXPR,
7619
- TMPLIT_EXPR: TMPLIT_EXPR,
7620
- DATA_ATTR: DATA_ATTR,
7621
- ARIA_ATTR: ARIA_ATTR,
7622
- IS_ALLOWED_URI: IS_ALLOWED_URI,
7623
- IS_SCRIPT_OR_DATA: IS_SCRIPT_OR_DATA,
7624
- ATTR_WHITESPACE: ATTR_WHITESPACE,
7625
- DOCTYPE_NAME: DOCTYPE_NAME
7626
- });
7627
-
7628
- const getGlobal = function getGlobal() {
7629
- return typeof window === 'undefined' ? null : window;
7630
- };
7631
-
7632
- /**
7633
- * Creates a no-op policy for internal use only.
7634
- * Don't export this function outside this module!
7635
- * @param {TrustedTypePolicyFactory} trustedTypes The policy factory.
7636
- * @param {HTMLScriptElement} purifyHostElement The Script element used to load DOMPurify (to determine policy name suffix).
7637
- * @return {TrustedTypePolicy} The policy created (or null, if Trusted Types
7638
- * are not supported or creating the policy failed).
7639
- */
7640
- const _createTrustedTypesPolicy = function _createTrustedTypesPolicy(trustedTypes, purifyHostElement) {
7641
- if (typeof trustedTypes !== 'object' || typeof trustedTypes.createPolicy !== 'function') {
7642
- return null;
7643
- }
7644
-
7645
- // Allow the callers to control the unique policy name
7646
- // by adding a data-tt-policy-suffix to the script element with the DOMPurify.
7647
- // Policy creation with duplicate names throws in Trusted Types.
7648
- let suffix = null;
7649
- const ATTR_NAME = 'data-tt-policy-suffix';
7650
- if (purifyHostElement && purifyHostElement.hasAttribute(ATTR_NAME)) {
7651
- suffix = purifyHostElement.getAttribute(ATTR_NAME);
7652
- }
7653
- const policyName = 'dompurify' + (suffix ? '#' + suffix : '');
7654
- try {
7655
- return trustedTypes.createPolicy(policyName, {
7656
- createHTML(html) {
7657
- return html;
7658
- },
7659
- createScriptURL(scriptUrl) {
7660
- return scriptUrl;
7661
- }
7662
- });
7663
- } catch (_) {
7664
- // Policy creation failed (most likely another DOMPurify script has
7665
- // already run). Skip creating the policy, as this will only cause errors
7666
- // if TT are enforced.
7667
- console.warn('TrustedTypes policy ' + policyName + ' could not be created.');
7668
- return null;
7669
- }
7670
- };
7671
- function createDOMPurify() {
7672
- let window = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : getGlobal();
7673
- const DOMPurify = root => createDOMPurify(root);
7674
-
7675
- /**
7676
- * Version label, exposed for easier checks
7677
- * if DOMPurify is up to date or not
7678
- */
7679
- DOMPurify.version = '3.0.8';
7680
-
7681
- /**
7682
- * Array of elements that DOMPurify removed during sanitation.
7683
- * Empty if nothing was removed.
7684
- */
7685
- DOMPurify.removed = [];
7686
- if (!window || !window.document || window.document.nodeType !== 9) {
7687
- // Not running in a browser, provide a factory function
7688
- // so that you can pass your own Window
7689
- DOMPurify.isSupported = false;
7690
- return DOMPurify;
7691
- }
7692
- let {
7693
- document
7694
- } = window;
7695
- const originalDocument = document;
7696
- const currentScript = originalDocument.currentScript;
7697
- const {
7698
- DocumentFragment,
7699
- HTMLTemplateElement,
7700
- Node,
7701
- Element,
7702
- NodeFilter,
7703
- NamedNodeMap = window.NamedNodeMap || window.MozNamedAttrMap,
7704
- HTMLFormElement,
7705
- DOMParser,
7706
- trustedTypes
7707
- } = window;
7708
- const ElementPrototype = Element.prototype;
7709
- const cloneNode = lookupGetter(ElementPrototype, 'cloneNode');
7710
- const getNextSibling = lookupGetter(ElementPrototype, 'nextSibling');
7711
- const getChildNodes = lookupGetter(ElementPrototype, 'childNodes');
7712
- const getParentNode = lookupGetter(ElementPrototype, 'parentNode');
7713
-
7714
- // As per issue #47, the web-components registry is inherited by a
7715
- // new document created via createHTMLDocument. As per the spec
7716
- // (http://w3c.github.io/webcomponents/spec/custom/#creating-and-passing-registries)
7717
- // a new empty registry is used when creating a template contents owner
7718
- // document, so we use that as our parent document to ensure nothing
7719
- // is inherited.
7720
- if (typeof HTMLTemplateElement === 'function') {
7721
- const template = document.createElement('template');
7722
- if (template.content && template.content.ownerDocument) {
7723
- document = template.content.ownerDocument;
7724
- }
7725
- }
7726
- let trustedTypesPolicy;
7727
- let emptyHTML = '';
7728
- const {
7729
- implementation,
7730
- createNodeIterator,
7731
- createDocumentFragment,
7732
- getElementsByTagName
7733
- } = document;
7734
- const {
7735
- importNode
7736
- } = originalDocument;
7737
- let hooks = {};
7738
-
7739
- /**
7740
- * Expose whether this browser supports running the full DOMPurify.
7741
- */
7742
- DOMPurify.isSupported = typeof entries === 'function' && typeof getParentNode === 'function' && implementation && implementation.createHTMLDocument !== undefined;
7743
- const {
7744
- MUSTACHE_EXPR,
7745
- ERB_EXPR,
7746
- TMPLIT_EXPR,
7747
- DATA_ATTR,
7748
- ARIA_ATTR,
7749
- IS_SCRIPT_OR_DATA,
7750
- ATTR_WHITESPACE
7751
- } = EXPRESSIONS;
7752
- let {
7753
- IS_ALLOWED_URI: IS_ALLOWED_URI$1
7754
- } = EXPRESSIONS;
7755
-
7756
- /**
7757
- * We consider the elements and attributes below to be safe. Ideally
7758
- * don't add any new ones but feel free to remove unwanted ones.
7759
- */
7760
-
7761
- /* allowed element names */
7762
- let ALLOWED_TAGS = null;
7763
- const DEFAULT_ALLOWED_TAGS = addToSet({}, [...html$1, ...svg$1, ...svgFilters, ...mathMl$1, ...text]);
7764
-
7765
- /* Allowed attribute names */
7766
- let ALLOWED_ATTR = null;
7767
- const DEFAULT_ALLOWED_ATTR = addToSet({}, [...html, ...svg, ...mathMl, ...xml]);
7768
-
7769
- /*
7770
- * Configure how DOMPUrify should handle custom elements and their attributes as well as customized built-in elements.
7771
- * @property {RegExp|Function|null} tagNameCheck one of [null, regexPattern, predicate]. Default: `null` (disallow any custom elements)
7772
- * @property {RegExp|Function|null} attributeNameCheck one of [null, regexPattern, predicate]. Default: `null` (disallow any attributes not on the allow list)
7773
- * @property {boolean} allowCustomizedBuiltInElements allow custom elements derived from built-ins if they pass CUSTOM_ELEMENT_HANDLING.tagNameCheck. Default: `false`.
7774
- */
7775
- let CUSTOM_ELEMENT_HANDLING = Object.seal(create(null, {
7776
- tagNameCheck: {
7777
- writable: true,
7778
- configurable: false,
7779
- enumerable: true,
7780
- value: null
7781
- },
7782
- attributeNameCheck: {
7783
- writable: true,
7784
- configurable: false,
7785
- enumerable: true,
7786
- value: null
7787
- },
7788
- allowCustomizedBuiltInElements: {
7789
- writable: true,
7790
- configurable: false,
7791
- enumerable: true,
7792
- value: false
7793
- }
7794
- }));
7795
-
7796
- /* Explicitly forbidden tags (overrides ALLOWED_TAGS/ADD_TAGS) */
7797
- let FORBID_TAGS = null;
7798
-
7799
- /* Explicitly forbidden attributes (overrides ALLOWED_ATTR/ADD_ATTR) */
7800
- let FORBID_ATTR = null;
7801
-
7802
- /* Decide if ARIA attributes are okay */
7803
- let ALLOW_ARIA_ATTR = true;
7804
-
7805
- /* Decide if custom data attributes are okay */
7806
- let ALLOW_DATA_ATTR = true;
7807
-
7808
- /* Decide if unknown protocols are okay */
7809
- let ALLOW_UNKNOWN_PROTOCOLS = false;
7810
-
7811
- /* Decide if self-closing tags in attributes are allowed.
7812
- * Usually removed due to a mXSS issue in jQuery 3.0 */
7813
- let ALLOW_SELF_CLOSE_IN_ATTR = true;
7814
-
7815
- /* Output should be safe for common template engines.
7816
- * This means, DOMPurify removes data attributes, mustaches and ERB
7817
- */
7818
- let SAFE_FOR_TEMPLATES = false;
7819
-
7820
- /* Decide if document with <html>... should be returned */
7821
- let WHOLE_DOCUMENT = false;
7822
-
7823
- /* Track whether config is already set on this instance of DOMPurify. */
7824
- let SET_CONFIG = false;
7825
-
7826
- /* Decide if all elements (e.g. style, script) must be children of
7827
- * document.body. By default, browsers might move them to document.head */
7828
- let FORCE_BODY = false;
7829
-
7830
- /* Decide if a DOM `HTMLBodyElement` should be returned, instead of a html
7831
- * string (or a TrustedHTML object if Trusted Types are supported).
7832
- * If `WHOLE_DOCUMENT` is enabled a `HTMLHtmlElement` will be returned instead
7833
- */
7834
- let RETURN_DOM = false;
7835
-
7836
- /* Decide if a DOM `DocumentFragment` should be returned, instead of a html
7837
- * string (or a TrustedHTML object if Trusted Types are supported) */
7838
- let RETURN_DOM_FRAGMENT = false;
7839
-
7840
- /* Try to return a Trusted Type object instead of a string, return a string in
7841
- * case Trusted Types are not supported */
7842
- let RETURN_TRUSTED_TYPE = false;
7843
-
7844
- /* Output should be free from DOM clobbering attacks?
7845
- * This sanitizes markups named with colliding, clobberable built-in DOM APIs.
7846
- */
7847
- let SANITIZE_DOM = true;
7848
-
7849
- /* Achieve full DOM Clobbering protection by isolating the namespace of named
7850
- * properties and JS variables, mitigating attacks that abuse the HTML/DOM spec rules.
7851
- *
7852
- * HTML/DOM spec rules that enable DOM Clobbering:
7853
- * - Named Access on Window (§7.3.3)
7854
- * - DOM Tree Accessors (§3.1.5)
7855
- * - Form Element Parent-Child Relations (§4.10.3)
7856
- * - Iframe srcdoc / Nested WindowProxies (§4.8.5)
7857
- * - HTMLCollection (§4.2.10.2)
7858
- *
7859
- * Namespace isolation is implemented by prefixing `id` and `name` attributes
7860
- * with a constant string, i.e., `user-content-`
7861
- */
7862
- let SANITIZE_NAMED_PROPS = false;
7863
- const SANITIZE_NAMED_PROPS_PREFIX = 'user-content-';
7864
-
7865
- /* Keep element content when removing element? */
7866
- let KEEP_CONTENT = true;
7867
-
7868
- /* If a `Node` is passed to sanitize(), then performs sanitization in-place instead
7869
- * of importing it into a new Document and returning a sanitized copy */
7870
- let IN_PLACE = false;
7871
-
7872
- /* Allow usage of profiles like html, svg and mathMl */
7873
- let USE_PROFILES = {};
7874
-
7875
- /* Tags to ignore content of when KEEP_CONTENT is true */
7876
- let FORBID_CONTENTS = null;
7877
- 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']);
7878
-
7879
- /* Tags that are safe for data: URIs */
7880
- let DATA_URI_TAGS = null;
7881
- const DEFAULT_DATA_URI_TAGS = addToSet({}, ['audio', 'video', 'img', 'source', 'image', 'track']);
7882
-
7883
- /* Attributes safe for values like "javascript:" */
7884
- let URI_SAFE_ATTRIBUTES = null;
7885
- const DEFAULT_URI_SAFE_ATTRIBUTES = addToSet({}, ['alt', 'class', 'for', 'id', 'label', 'name', 'pattern', 'placeholder', 'role', 'summary', 'title', 'value', 'style', 'xmlns']);
7886
- const MATHML_NAMESPACE = 'http://www.w3.org/1998/Math/MathML';
7887
- const SVG_NAMESPACE = 'http://www.w3.org/2000/svg';
7888
- const HTML_NAMESPACE = 'http://www.w3.org/1999/xhtml';
7889
- /* Document namespace */
7890
- let NAMESPACE = HTML_NAMESPACE;
7891
- let IS_EMPTY_INPUT = false;
7892
-
7893
- /* Allowed XHTML+XML namespaces */
7894
- let ALLOWED_NAMESPACES = null;
7895
- const DEFAULT_ALLOWED_NAMESPACES = addToSet({}, [MATHML_NAMESPACE, SVG_NAMESPACE, HTML_NAMESPACE], stringToString);
7896
-
7897
- /* Parsing of strict XHTML documents */
7898
- let PARSER_MEDIA_TYPE = null;
7899
- const SUPPORTED_PARSER_MEDIA_TYPES = ['application/xhtml+xml', 'text/html'];
7900
- const DEFAULT_PARSER_MEDIA_TYPE = 'text/html';
7901
- let transformCaseFunc = null;
7902
-
7903
- /* Keep a reference to config to pass to hooks */
7904
- let CONFIG = null;
7905
-
7906
- /* Ideally, do not touch anything below this line */
7907
- /* ______________________________________________ */
7908
-
7909
- const formElement = document.createElement('form');
7910
- const isRegexOrFunction = function isRegexOrFunction(testValue) {
7911
- return testValue instanceof RegExp || testValue instanceof Function;
7912
- };
7913
-
7914
- /**
7915
- * _parseConfig
7916
- *
7917
- * @param {Object} cfg optional config literal
7918
- */
7919
- // eslint-disable-next-line complexity
7920
- const _parseConfig = function _parseConfig() {
7921
- let cfg = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
7922
- if (CONFIG && CONFIG === cfg) {
7923
- return;
7924
- }
7925
-
7926
- /* Shield configuration object from tampering */
7927
- if (!cfg || typeof cfg !== 'object') {
7928
- cfg = {};
7929
- }
7930
-
7931
- /* Shield configuration object from prototype pollution */
7932
- cfg = clone(cfg);
7933
- PARSER_MEDIA_TYPE =
7934
- // eslint-disable-next-line unicorn/prefer-includes
7935
- SUPPORTED_PARSER_MEDIA_TYPES.indexOf(cfg.PARSER_MEDIA_TYPE) === -1 ? DEFAULT_PARSER_MEDIA_TYPE : cfg.PARSER_MEDIA_TYPE;
7936
-
7937
- // HTML tags and attributes are not case-sensitive, converting to lowercase. Keeping XHTML as is.
7938
- transformCaseFunc = PARSER_MEDIA_TYPE === 'application/xhtml+xml' ? stringToString : stringToLowerCase;
7939
-
7940
- /* Set configuration parameters */
7941
- ALLOWED_TAGS = 'ALLOWED_TAGS' in cfg ? addToSet({}, cfg.ALLOWED_TAGS, transformCaseFunc) : DEFAULT_ALLOWED_TAGS;
7942
- ALLOWED_ATTR = 'ALLOWED_ATTR' in cfg ? addToSet({}, cfg.ALLOWED_ATTR, transformCaseFunc) : DEFAULT_ALLOWED_ATTR;
7943
- ALLOWED_NAMESPACES = 'ALLOWED_NAMESPACES' in cfg ? addToSet({}, cfg.ALLOWED_NAMESPACES, stringToString) : DEFAULT_ALLOWED_NAMESPACES;
7944
- URI_SAFE_ATTRIBUTES = 'ADD_URI_SAFE_ATTR' in cfg ? addToSet(clone(DEFAULT_URI_SAFE_ATTRIBUTES),
7945
- // eslint-disable-line indent
7946
- cfg.ADD_URI_SAFE_ATTR,
7947
- // eslint-disable-line indent
7948
- transformCaseFunc // eslint-disable-line indent
7949
- ) // eslint-disable-line indent
7950
- : DEFAULT_URI_SAFE_ATTRIBUTES;
7951
- DATA_URI_TAGS = 'ADD_DATA_URI_TAGS' in cfg ? addToSet(clone(DEFAULT_DATA_URI_TAGS),
7952
- // eslint-disable-line indent
7953
- cfg.ADD_DATA_URI_TAGS,
7954
- // eslint-disable-line indent
7955
- transformCaseFunc // eslint-disable-line indent
7956
- ) // eslint-disable-line indent
7957
- : DEFAULT_DATA_URI_TAGS;
7958
- FORBID_CONTENTS = 'FORBID_CONTENTS' in cfg ? addToSet({}, cfg.FORBID_CONTENTS, transformCaseFunc) : DEFAULT_FORBID_CONTENTS;
7959
- FORBID_TAGS = 'FORBID_TAGS' in cfg ? addToSet({}, cfg.FORBID_TAGS, transformCaseFunc) : {};
7960
- FORBID_ATTR = 'FORBID_ATTR' in cfg ? addToSet({}, cfg.FORBID_ATTR, transformCaseFunc) : {};
7961
- USE_PROFILES = 'USE_PROFILES' in cfg ? cfg.USE_PROFILES : false;
7962
- ALLOW_ARIA_ATTR = cfg.ALLOW_ARIA_ATTR !== false; // Default true
7963
- ALLOW_DATA_ATTR = cfg.ALLOW_DATA_ATTR !== false; // Default true
7964
- ALLOW_UNKNOWN_PROTOCOLS = cfg.ALLOW_UNKNOWN_PROTOCOLS || false; // Default false
7965
- ALLOW_SELF_CLOSE_IN_ATTR = cfg.ALLOW_SELF_CLOSE_IN_ATTR !== false; // Default true
7966
- SAFE_FOR_TEMPLATES = cfg.SAFE_FOR_TEMPLATES || false; // Default false
7967
- WHOLE_DOCUMENT = cfg.WHOLE_DOCUMENT || false; // Default false
7968
- RETURN_DOM = cfg.RETURN_DOM || false; // Default false
7969
- RETURN_DOM_FRAGMENT = cfg.RETURN_DOM_FRAGMENT || false; // Default false
7970
- RETURN_TRUSTED_TYPE = cfg.RETURN_TRUSTED_TYPE || false; // Default false
7971
- FORCE_BODY = cfg.FORCE_BODY || false; // Default false
7972
- SANITIZE_DOM = cfg.SANITIZE_DOM !== false; // Default true
7973
- SANITIZE_NAMED_PROPS = cfg.SANITIZE_NAMED_PROPS || false; // Default false
7974
- KEEP_CONTENT = cfg.KEEP_CONTENT !== false; // Default true
7975
- IN_PLACE = cfg.IN_PLACE || false; // Default false
7976
- IS_ALLOWED_URI$1 = cfg.ALLOWED_URI_REGEXP || IS_ALLOWED_URI;
7977
- NAMESPACE = cfg.NAMESPACE || HTML_NAMESPACE;
7978
- CUSTOM_ELEMENT_HANDLING = cfg.CUSTOM_ELEMENT_HANDLING || {};
7979
- if (cfg.CUSTOM_ELEMENT_HANDLING && isRegexOrFunction(cfg.CUSTOM_ELEMENT_HANDLING.tagNameCheck)) {
7980
- CUSTOM_ELEMENT_HANDLING.tagNameCheck = cfg.CUSTOM_ELEMENT_HANDLING.tagNameCheck;
7981
- }
7982
- if (cfg.CUSTOM_ELEMENT_HANDLING && isRegexOrFunction(cfg.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)) {
7983
- CUSTOM_ELEMENT_HANDLING.attributeNameCheck = cfg.CUSTOM_ELEMENT_HANDLING.attributeNameCheck;
7984
- }
7985
- if (cfg.CUSTOM_ELEMENT_HANDLING && typeof cfg.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements === 'boolean') {
7986
- CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements = cfg.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements;
7987
- }
7988
- if (SAFE_FOR_TEMPLATES) {
7989
- ALLOW_DATA_ATTR = false;
7990
- }
7991
- if (RETURN_DOM_FRAGMENT) {
7992
- RETURN_DOM = true;
7993
- }
7994
-
7995
- /* Parse profile info */
7996
- if (USE_PROFILES) {
7997
- ALLOWED_TAGS = addToSet({}, text);
7998
- ALLOWED_ATTR = [];
7999
- if (USE_PROFILES.html === true) {
8000
- addToSet(ALLOWED_TAGS, html$1);
8001
- addToSet(ALLOWED_ATTR, html);
8002
- }
8003
- if (USE_PROFILES.svg === true) {
8004
- addToSet(ALLOWED_TAGS, svg$1);
8005
- addToSet(ALLOWED_ATTR, svg);
8006
- addToSet(ALLOWED_ATTR, xml);
8007
- }
8008
- if (USE_PROFILES.svgFilters === true) {
8009
- addToSet(ALLOWED_TAGS, svgFilters);
8010
- addToSet(ALLOWED_ATTR, svg);
8011
- addToSet(ALLOWED_ATTR, xml);
8012
- }
8013
- if (USE_PROFILES.mathMl === true) {
8014
- addToSet(ALLOWED_TAGS, mathMl$1);
8015
- addToSet(ALLOWED_ATTR, mathMl);
8016
- addToSet(ALLOWED_ATTR, xml);
8017
- }
8018
- }
8019
-
8020
- /* Merge configuration parameters */
8021
- if (cfg.ADD_TAGS) {
8022
- if (ALLOWED_TAGS === DEFAULT_ALLOWED_TAGS) {
8023
- ALLOWED_TAGS = clone(ALLOWED_TAGS);
8024
- }
8025
- addToSet(ALLOWED_TAGS, cfg.ADD_TAGS, transformCaseFunc);
8026
- }
8027
- if (cfg.ADD_ATTR) {
8028
- if (ALLOWED_ATTR === DEFAULT_ALLOWED_ATTR) {
8029
- ALLOWED_ATTR = clone(ALLOWED_ATTR);
8030
- }
8031
- addToSet(ALLOWED_ATTR, cfg.ADD_ATTR, transformCaseFunc);
8032
- }
8033
- if (cfg.ADD_URI_SAFE_ATTR) {
8034
- addToSet(URI_SAFE_ATTRIBUTES, cfg.ADD_URI_SAFE_ATTR, transformCaseFunc);
8035
- }
8036
- if (cfg.FORBID_CONTENTS) {
8037
- if (FORBID_CONTENTS === DEFAULT_FORBID_CONTENTS) {
8038
- FORBID_CONTENTS = clone(FORBID_CONTENTS);
8039
- }
8040
- addToSet(FORBID_CONTENTS, cfg.FORBID_CONTENTS, transformCaseFunc);
8041
- }
8042
-
8043
- /* Add #text in case KEEP_CONTENT is set to true */
8044
- if (KEEP_CONTENT) {
8045
- ALLOWED_TAGS['#text'] = true;
8046
- }
8047
-
8048
- /* Add html, head and body to ALLOWED_TAGS in case WHOLE_DOCUMENT is true */
8049
- if (WHOLE_DOCUMENT) {
8050
- addToSet(ALLOWED_TAGS, ['html', 'head', 'body']);
8051
- }
8052
-
8053
- /* Add tbody to ALLOWED_TAGS in case tables are permitted, see #286, #365 */
8054
- if (ALLOWED_TAGS.table) {
8055
- addToSet(ALLOWED_TAGS, ['tbody']);
8056
- delete FORBID_TAGS.tbody;
8057
- }
8058
- if (cfg.TRUSTED_TYPES_POLICY) {
8059
- if (typeof cfg.TRUSTED_TYPES_POLICY.createHTML !== 'function') {
8060
- throw typeErrorCreate('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');
8061
- }
8062
- if (typeof cfg.TRUSTED_TYPES_POLICY.createScriptURL !== 'function') {
8063
- throw typeErrorCreate('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');
8064
- }
8065
-
8066
- // Overwrite existing TrustedTypes policy.
8067
- trustedTypesPolicy = cfg.TRUSTED_TYPES_POLICY;
8068
-
8069
- // Sign local variables required by `sanitize`.
8070
- emptyHTML = trustedTypesPolicy.createHTML('');
8071
- } else {
8072
- // Uninitialized policy, attempt to initialize the internal dompurify policy.
8073
- if (trustedTypesPolicy === undefined) {
8074
- trustedTypesPolicy = _createTrustedTypesPolicy(trustedTypes, currentScript);
8075
- }
8076
-
8077
- // If creating the internal policy succeeded sign internal variables.
8078
- if (trustedTypesPolicy !== null && typeof emptyHTML === 'string') {
8079
- emptyHTML = trustedTypesPolicy.createHTML('');
8080
- }
8081
- }
8082
-
8083
- // Prevent further manipulation of configuration.
8084
- // Not available in IE8, Safari 5, etc.
8085
- if (freeze) {
8086
- freeze(cfg);
8087
- }
8088
- CONFIG = cfg;
8089
- };
8090
- const MATHML_TEXT_INTEGRATION_POINTS = addToSet({}, ['mi', 'mo', 'mn', 'ms', 'mtext']);
8091
- const HTML_INTEGRATION_POINTS = addToSet({}, ['foreignobject', 'desc', 'title', 'annotation-xml']);
8092
-
8093
- // Certain elements are allowed in both SVG and HTML
8094
- // namespace. We need to specify them explicitly
8095
- // so that they don't get erroneously deleted from
8096
- // HTML namespace.
8097
- const COMMON_SVG_AND_HTML_ELEMENTS = addToSet({}, ['title', 'style', 'font', 'a', 'script']);
8098
-
8099
- /* Keep track of all possible SVG and MathML tags
8100
- * so that we can perform the namespace checks
8101
- * correctly. */
8102
- const ALL_SVG_TAGS = addToSet({}, [...svg$1, ...svgFilters, ...svgDisallowed]);
8103
- const ALL_MATHML_TAGS = addToSet({}, [...mathMl$1, ...mathMlDisallowed]);
8104
-
8105
- /**
8106
- * @param {Element} element a DOM element whose namespace is being checked
8107
- * @returns {boolean} Return false if the element has a
8108
- * namespace that a spec-compliant parser would never
8109
- * return. Return true otherwise.
8110
- */
8111
- const _checkValidNamespace = function _checkValidNamespace(element) {
8112
- let parent = getParentNode(element);
8113
-
8114
- // In JSDOM, if we're inside shadow DOM, then parentNode
8115
- // can be null. We just simulate parent in this case.
8116
- if (!parent || !parent.tagName) {
8117
- parent = {
8118
- namespaceURI: NAMESPACE,
8119
- tagName: 'template'
8120
- };
8121
- }
8122
- const tagName = stringToLowerCase(element.tagName);
8123
- const parentTagName = stringToLowerCase(parent.tagName);
8124
- if (!ALLOWED_NAMESPACES[element.namespaceURI]) {
8125
- return false;
8126
- }
8127
- if (element.namespaceURI === SVG_NAMESPACE) {
8128
- // The only way to switch from HTML namespace to SVG
8129
- // is via <svg>. If it happens via any other tag, then
8130
- // it should be killed.
8131
- if (parent.namespaceURI === HTML_NAMESPACE) {
8132
- return tagName === 'svg';
8133
- }
8134
-
8135
- // The only way to switch from MathML to SVG is via`
8136
- // svg if parent is either <annotation-xml> or MathML
8137
- // text integration points.
8138
- if (parent.namespaceURI === MATHML_NAMESPACE) {
8139
- return tagName === 'svg' && (parentTagName === 'annotation-xml' || MATHML_TEXT_INTEGRATION_POINTS[parentTagName]);
8140
- }
8141
-
8142
- // We only allow elements that are defined in SVG
8143
- // spec. All others are disallowed in SVG namespace.
8144
- return Boolean(ALL_SVG_TAGS[tagName]);
8145
- }
8146
- if (element.namespaceURI === MATHML_NAMESPACE) {
8147
- // The only way to switch from HTML namespace to MathML
8148
- // is via <math>. If it happens via any other tag, then
8149
- // it should be killed.
8150
- if (parent.namespaceURI === HTML_NAMESPACE) {
8151
- return tagName === 'math';
8152
- }
8153
-
8154
- // The only way to switch from SVG to MathML is via
8155
- // <math> and HTML integration points
8156
- if (parent.namespaceURI === SVG_NAMESPACE) {
8157
- return tagName === 'math' && HTML_INTEGRATION_POINTS[parentTagName];
8158
- }
8159
-
8160
- // We only allow elements that are defined in MathML
8161
- // spec. All others are disallowed in MathML namespace.
8162
- return Boolean(ALL_MATHML_TAGS[tagName]);
8163
- }
8164
- if (element.namespaceURI === HTML_NAMESPACE) {
8165
- // The only way to switch from SVG to HTML is via
8166
- // HTML integration points, and from MathML to HTML
8167
- // is via MathML text integration points
8168
- if (parent.namespaceURI === SVG_NAMESPACE && !HTML_INTEGRATION_POINTS[parentTagName]) {
8169
- return false;
8170
- }
8171
- if (parent.namespaceURI === MATHML_NAMESPACE && !MATHML_TEXT_INTEGRATION_POINTS[parentTagName]) {
8172
- return false;
8173
- }
8174
-
8175
- // We disallow tags that are specific for MathML
8176
- // or SVG and should never appear in HTML namespace
8177
- return !ALL_MATHML_TAGS[tagName] && (COMMON_SVG_AND_HTML_ELEMENTS[tagName] || !ALL_SVG_TAGS[tagName]);
8178
- }
8179
-
8180
- // For XHTML and XML documents that support custom namespaces
8181
- if (PARSER_MEDIA_TYPE === 'application/xhtml+xml' && ALLOWED_NAMESPACES[element.namespaceURI]) {
8182
- return true;
8183
- }
8184
-
8185
- // The code should never reach this place (this means
8186
- // that the element somehow got namespace that is not
8187
- // HTML, SVG, MathML or allowed via ALLOWED_NAMESPACES).
8188
- // Return false just in case.
8189
- return false;
8190
- };
8191
-
8192
- /**
8193
- * _forceRemove
8194
- *
8195
- * @param {Node} node a DOM node
8196
- */
8197
- const _forceRemove = function _forceRemove(node) {
8198
- arrayPush(DOMPurify.removed, {
8199
- element: node
8200
- });
8201
- try {
8202
- // eslint-disable-next-line unicorn/prefer-dom-node-remove
8203
- node.parentNode.removeChild(node);
8204
- } catch (_) {
8205
- node.remove();
8206
- }
8207
- };
8208
-
8209
- /**
8210
- * _removeAttribute
8211
- *
8212
- * @param {String} name an Attribute name
8213
- * @param {Node} node a DOM node
8214
- */
8215
- const _removeAttribute = function _removeAttribute(name, node) {
8216
- try {
8217
- arrayPush(DOMPurify.removed, {
8218
- attribute: node.getAttributeNode(name),
8219
- from: node
8220
- });
8221
- } catch (_) {
8222
- arrayPush(DOMPurify.removed, {
8223
- attribute: null,
8224
- from: node
8225
- });
8226
- }
8227
- node.removeAttribute(name);
8228
-
8229
- // We void attribute values for unremovable "is"" attributes
8230
- if (name === 'is' && !ALLOWED_ATTR[name]) {
8231
- if (RETURN_DOM || RETURN_DOM_FRAGMENT) {
8232
- try {
8233
- _forceRemove(node);
8234
- } catch (_) {}
8235
- } else {
8236
- try {
8237
- node.setAttribute(name, '');
8238
- } catch (_) {}
8239
- }
8240
- }
8241
- };
8242
-
8243
- /**
8244
- * _initDocument
8245
- *
8246
- * @param {String} dirty a string of dirty markup
8247
- * @return {Document} a DOM, filled with the dirty markup
8248
- */
8249
- const _initDocument = function _initDocument(dirty) {
8250
- /* Create a HTML document */
8251
- let doc = null;
8252
- let leadingWhitespace = null;
8253
- if (FORCE_BODY) {
8254
- dirty = '<remove></remove>' + dirty;
8255
- } else {
8256
- /* If FORCE_BODY isn't used, leading whitespace needs to be preserved manually */
8257
- const matches = stringMatch(dirty, /^[\r\n\t ]+/);
8258
- leadingWhitespace = matches && matches[0];
8259
- }
8260
- if (PARSER_MEDIA_TYPE === 'application/xhtml+xml' && NAMESPACE === HTML_NAMESPACE) {
8261
- // Root of XHTML doc must contain xmlns declaration (see https://www.w3.org/TR/xhtml1/normative.html#strict)
8262
- dirty = '<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>' + dirty + '</body></html>';
8263
- }
8264
- const dirtyPayload = trustedTypesPolicy ? trustedTypesPolicy.createHTML(dirty) : dirty;
8265
- /*
8266
- * Use the DOMParser API by default, fallback later if needs be
8267
- * DOMParser not work for svg when has multiple root element.
8268
- */
8269
- if (NAMESPACE === HTML_NAMESPACE) {
8270
- try {
8271
- doc = new DOMParser().parseFromString(dirtyPayload, PARSER_MEDIA_TYPE);
8272
- } catch (_) {}
8273
- }
8274
-
8275
- /* Use createHTMLDocument in case DOMParser is not available */
8276
- if (!doc || !doc.documentElement) {
8277
- doc = implementation.createDocument(NAMESPACE, 'template', null);
8278
- try {
8279
- doc.documentElement.innerHTML = IS_EMPTY_INPUT ? emptyHTML : dirtyPayload;
8280
- } catch (_) {
8281
- // Syntax error if dirtyPayload is invalid xml
8282
- }
8283
- }
8284
- const body = doc.body || doc.documentElement;
8285
- if (dirty && leadingWhitespace) {
8286
- body.insertBefore(document.createTextNode(leadingWhitespace), body.childNodes[0] || null);
8287
- }
8288
-
8289
- /* Work on whole document or just its body */
8290
- if (NAMESPACE === HTML_NAMESPACE) {
8291
- return getElementsByTagName.call(doc, WHOLE_DOCUMENT ? 'html' : 'body')[0];
8292
- }
8293
- return WHOLE_DOCUMENT ? doc.documentElement : body;
8294
- };
8295
-
8296
- /**
8297
- * Creates a NodeIterator object that you can use to traverse filtered lists of nodes or elements in a document.
8298
- *
8299
- * @param {Node} root The root element or node to start traversing on.
8300
- * @return {NodeIterator} The created NodeIterator
8301
- */
8302
- const _createNodeIterator = function _createNodeIterator(root) {
8303
- return createNodeIterator.call(root.ownerDocument || root, root,
8304
- // eslint-disable-next-line no-bitwise
8305
- NodeFilter.SHOW_ELEMENT | NodeFilter.SHOW_COMMENT | NodeFilter.SHOW_TEXT, null);
8306
- };
8307
-
8308
- /**
8309
- * _isClobbered
8310
- *
8311
- * @param {Node} elm element to check for clobbering attacks
8312
- * @return {Boolean} true if clobbered, false if safe
8313
- */
8314
- const _isClobbered = function _isClobbered(elm) {
8315
- 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');
8316
- };
8317
-
8318
- /**
8319
- * Checks whether the given object is a DOM node.
8320
- *
8321
- * @param {Node} object object to check whether it's a DOM node
8322
- * @return {Boolean} true is object is a DOM node
8323
- */
8324
- const _isNode = function _isNode(object) {
8325
- return typeof Node === 'function' && object instanceof Node;
8326
- };
8327
-
8328
- /**
8329
- * _executeHook
8330
- * Execute user configurable hooks
8331
- *
8332
- * @param {String} entryPoint Name of the hook's entry point
8333
- * @param {Node} currentNode node to work on with the hook
8334
- * @param {Object} data additional hook parameters
8335
- */
8336
- const _executeHook = function _executeHook(entryPoint, currentNode, data) {
8337
- if (!hooks[entryPoint]) {
8338
- return;
8339
- }
8340
- arrayForEach(hooks[entryPoint], hook => {
8341
- hook.call(DOMPurify, currentNode, data, CONFIG);
8342
- });
8343
- };
8344
-
8345
- /**
8346
- * _sanitizeElements
8347
- *
8348
- * @protect nodeName
8349
- * @protect textContent
8350
- * @protect removeChild
8351
- *
8352
- * @param {Node} currentNode to check for permission to exist
8353
- * @return {Boolean} true if node was killed, false if left alive
8354
- */
8355
- const _sanitizeElements = function _sanitizeElements(currentNode) {
8356
- let content = null;
8357
-
8358
- /* Execute a hook if present */
8359
- _executeHook('beforeSanitizeElements', currentNode, null);
8360
-
8361
- /* Check if element is clobbered or can clobber */
8362
- if (_isClobbered(currentNode)) {
8363
- _forceRemove(currentNode);
8364
- return true;
8365
- }
8366
-
8367
- /* Now let's check the element's type and name */
8368
- const tagName = transformCaseFunc(currentNode.nodeName);
8369
-
8370
- /* Execute a hook if present */
8371
- _executeHook('uponSanitizeElement', currentNode, {
8372
- tagName,
8373
- allowedTags: ALLOWED_TAGS
8374
- });
8375
-
8376
- /* Detect mXSS attempts abusing namespace confusion */
8377
- if (currentNode.hasChildNodes() && !_isNode(currentNode.firstElementChild) && regExpTest(/<[/\w]/g, currentNode.innerHTML) && regExpTest(/<[/\w]/g, currentNode.textContent)) {
8378
- _forceRemove(currentNode);
8379
- return true;
8380
- }
8381
-
8382
- /* Remove element if anything forbids its presence */
8383
- if (!ALLOWED_TAGS[tagName] || FORBID_TAGS[tagName]) {
8384
- /* Check if we have a custom element to handle */
8385
- if (!FORBID_TAGS[tagName] && _isBasicCustomElement(tagName)) {
8386
- if (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof RegExp && regExpTest(CUSTOM_ELEMENT_HANDLING.tagNameCheck, tagName)) {
8387
- return false;
8388
- }
8389
- if (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof Function && CUSTOM_ELEMENT_HANDLING.tagNameCheck(tagName)) {
8390
- return false;
8391
- }
8392
- }
8393
-
8394
- /* Keep content except for bad-listed elements */
8395
- if (KEEP_CONTENT && !FORBID_CONTENTS[tagName]) {
8396
- const parentNode = getParentNode(currentNode) || currentNode.parentNode;
8397
- const childNodes = getChildNodes(currentNode) || currentNode.childNodes;
8398
- if (childNodes && parentNode) {
8399
- const childCount = childNodes.length;
8400
- for (let i = childCount - 1; i >= 0; --i) {
8401
- parentNode.insertBefore(cloneNode(childNodes[i], true), getNextSibling(currentNode));
8402
- }
8403
- }
8404
- }
8405
- _forceRemove(currentNode);
8406
- return true;
8407
- }
8408
-
8409
- /* Check whether element has a valid namespace */
8410
- if (currentNode instanceof Element && !_checkValidNamespace(currentNode)) {
8411
- _forceRemove(currentNode);
8412
- return true;
8413
- }
8414
-
8415
- /* Make sure that older browsers don't get fallback-tag mXSS */
8416
- if ((tagName === 'noscript' || tagName === 'noembed' || tagName === 'noframes') && regExpTest(/<\/no(script|embed|frames)/i, currentNode.innerHTML)) {
8417
- _forceRemove(currentNode);
8418
- return true;
8419
- }
8420
-
8421
- /* Sanitize element content to be template-safe */
8422
- if (SAFE_FOR_TEMPLATES && currentNode.nodeType === 3) {
8423
- /* Get the element's text content */
8424
- content = currentNode.textContent;
8425
- arrayForEach([MUSTACHE_EXPR, ERB_EXPR, TMPLIT_EXPR], expr => {
8426
- content = stringReplace(content, expr, ' ');
8427
- });
8428
- if (currentNode.textContent !== content) {
8429
- arrayPush(DOMPurify.removed, {
8430
- element: currentNode.cloneNode()
8431
- });
8432
- currentNode.textContent = content;
8433
- }
8434
- }
8435
-
8436
- /* Execute a hook if present */
8437
- _executeHook('afterSanitizeElements', currentNode, null);
8438
- return false;
8439
- };
8440
-
8441
- /**
8442
- * _isValidAttribute
8443
- *
8444
- * @param {string} lcTag Lowercase tag name of containing element.
8445
- * @param {string} lcName Lowercase attribute name.
8446
- * @param {string} value Attribute value.
8447
- * @return {Boolean} Returns true if `value` is valid, otherwise false.
8448
- */
8449
- // eslint-disable-next-line complexity
8450
- const _isValidAttribute = function _isValidAttribute(lcTag, lcName, value) {
8451
- /* Make sure attribute cannot clobber */
8452
- if (SANITIZE_DOM && (lcName === 'id' || lcName === 'name') && (value in document || value in formElement)) {
8453
- return false;
8454
- }
8455
-
8456
- /* Allow valid data-* attributes: At least one character after "-"
8457
- (https://html.spec.whatwg.org/multipage/dom.html#embedding-custom-non-visible-data-with-the-data-*-attributes)
8458
- XML-compatible (https://html.spec.whatwg.org/multipage/infrastructure.html#xml-compatible and http://www.w3.org/TR/xml/#d0e804)
8459
- We don't need to check the value; it's always URI safe. */
8460
- 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]) {
8461
- if (
8462
- // First condition does a very basic check if a) it's basically a valid custom element tagname AND
8463
- // b) if the tagName passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.tagNameCheck
8464
- // and c) if the attribute name passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.attributeNameCheck
8465
- _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)) ||
8466
- // Alternative, second condition checks if it's an `is`-attribute, AND
8467
- // the value passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.tagNameCheck
8468
- 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 {
8469
- return false;
8470
- }
8471
- /* Check value is safe. First, is attr inert? If so, is safe */
8472
- } 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) {
8473
- return false;
8474
- } else ;
8475
- return true;
8476
- };
8477
-
8478
- /**
8479
- * _isBasicCustomElement
8480
- * checks if at least one dash is included in tagName, and it's not the first char
8481
- * for more sophisticated checking see https://github.com/sindresorhus/validate-element-name
8482
- *
8483
- * @param {string} tagName name of the tag of the node to sanitize
8484
- * @returns {boolean} Returns true if the tag name meets the basic criteria for a custom element, otherwise false.
8485
- */
8486
- const _isBasicCustomElement = function _isBasicCustomElement(tagName) {
8487
- return tagName.indexOf('-') > 0;
8488
- };
8489
-
8490
- /**
8491
- * _sanitizeAttributes
8492
- *
8493
- * @protect attributes
8494
- * @protect nodeName
8495
- * @protect removeAttribute
8496
- * @protect setAttribute
8497
- *
8498
- * @param {Node} currentNode to sanitize
8499
- */
8500
- const _sanitizeAttributes = function _sanitizeAttributes(currentNode) {
8501
- /* Execute a hook if present */
8502
- _executeHook('beforeSanitizeAttributes', currentNode, null);
8503
- const {
8504
- attributes
8505
- } = currentNode;
8506
-
8507
- /* Check if we have attributes; if not we might have a text node */
8508
- if (!attributes) {
8509
- return;
8510
- }
8511
- const hookEvent = {
8512
- attrName: '',
8513
- attrValue: '',
8514
- keepAttr: true,
8515
- allowedAttributes: ALLOWED_ATTR
8516
- };
8517
- let l = attributes.length;
8518
-
8519
- /* Go backwards over all attributes; safely remove bad ones */
8520
- while (l--) {
8521
- const attr = attributes[l];
8522
- const {
8523
- name,
8524
- namespaceURI,
8525
- value: attrValue
8526
- } = attr;
8527
- const lcName = transformCaseFunc(name);
8528
- let value = name === 'value' ? attrValue : stringTrim(attrValue);
8529
-
8530
- /* Execute a hook if present */
8531
- hookEvent.attrName = lcName;
8532
- hookEvent.attrValue = value;
8533
- hookEvent.keepAttr = true;
8534
- hookEvent.forceKeepAttr = undefined; // Allows developers to see this is a property they can set
8535
- _executeHook('uponSanitizeAttribute', currentNode, hookEvent);
8536
- value = hookEvent.attrValue;
8537
- /* Did the hooks approve of the attribute? */
8538
- if (hookEvent.forceKeepAttr) {
8539
- continue;
8540
- }
8541
-
8542
- /* Remove attribute */
8543
- _removeAttribute(name, currentNode);
8544
-
8545
- /* Did the hooks approve of the attribute? */
8546
- if (!hookEvent.keepAttr) {
8547
- continue;
8548
- }
8549
-
8550
- /* Work around a security issue in jQuery 3.0 */
8551
- if (!ALLOW_SELF_CLOSE_IN_ATTR && regExpTest(/\/>/i, value)) {
8552
- _removeAttribute(name, currentNode);
8553
- continue;
8554
- }
8555
-
8556
- /* Sanitize attribute content to be template-safe */
8557
- if (SAFE_FOR_TEMPLATES) {
8558
- arrayForEach([MUSTACHE_EXPR, ERB_EXPR, TMPLIT_EXPR], expr => {
8559
- value = stringReplace(value, expr, ' ');
8560
- });
8561
- }
8562
-
8563
- /* Is `value` valid for this attribute? */
8564
- const lcTag = transformCaseFunc(currentNode.nodeName);
8565
- if (!_isValidAttribute(lcTag, lcName, value)) {
8566
- continue;
8567
- }
8568
-
8569
- /* Full DOM Clobbering protection via namespace isolation,
8570
- * Prefix id and name attributes with `user-content-`
8571
- */
8572
- if (SANITIZE_NAMED_PROPS && (lcName === 'id' || lcName === 'name')) {
8573
- // Remove the attribute with this value
8574
- _removeAttribute(name, currentNode);
8575
-
8576
- // Prefix the value and later re-create the attribute with the sanitized value
8577
- value = SANITIZE_NAMED_PROPS_PREFIX + value;
8578
- }
8579
-
8580
- /* Handle attributes that require Trusted Types */
8581
- if (trustedTypesPolicy && typeof trustedTypes === 'object' && typeof trustedTypes.getAttributeType === 'function') {
8582
- if (namespaceURI) ; else {
8583
- switch (trustedTypes.getAttributeType(lcTag, lcName)) {
8584
- case 'TrustedHTML':
8585
- {
8586
- value = trustedTypesPolicy.createHTML(value);
8587
- break;
8588
- }
8589
- case 'TrustedScriptURL':
8590
- {
8591
- value = trustedTypesPolicy.createScriptURL(value);
8592
- break;
8593
- }
8594
- }
8595
- }
8596
- }
8597
-
8598
- /* Handle invalid data-* attribute set by try-catching it */
8599
- try {
8600
- if (namespaceURI) {
8601
- currentNode.setAttributeNS(namespaceURI, name, value);
8602
- } else {
8603
- /* Fallback to setAttribute() for browser-unrecognized namespaces e.g. "x-schema". */
8604
- currentNode.setAttribute(name, value);
8605
- }
8606
- arrayPop(DOMPurify.removed);
8607
- } catch (_) {}
8608
- }
8609
-
8610
- /* Execute a hook if present */
8611
- _executeHook('afterSanitizeAttributes', currentNode, null);
8612
- };
8613
-
8614
- /**
8615
- * _sanitizeShadowDOM
8616
- *
8617
- * @param {DocumentFragment} fragment to iterate over recursively
8618
- */
8619
- const _sanitizeShadowDOM = function _sanitizeShadowDOM(fragment) {
8620
- let shadowNode = null;
8621
- const shadowIterator = _createNodeIterator(fragment);
8622
-
8623
- /* Execute a hook if present */
8624
- _executeHook('beforeSanitizeShadowDOM', fragment, null);
8625
- while (shadowNode = shadowIterator.nextNode()) {
8626
- /* Execute a hook if present */
8627
- _executeHook('uponSanitizeShadowNode', shadowNode, null);
8628
-
8629
- /* Sanitize tags and elements */
8630
- if (_sanitizeElements(shadowNode)) {
8631
- continue;
8632
- }
8633
-
8634
- /* Deep shadow DOM detected */
8635
- if (shadowNode.content instanceof DocumentFragment) {
8636
- _sanitizeShadowDOM(shadowNode.content);
8637
- }
8638
-
8639
- /* Check attributes, sanitize if necessary */
8640
- _sanitizeAttributes(shadowNode);
8641
- }
8642
-
8643
- /* Execute a hook if present */
8644
- _executeHook('afterSanitizeShadowDOM', fragment, null);
8645
- };
8646
-
8647
- /**
8648
- * Sanitize
8649
- * Public method providing core sanitation functionality
8650
- *
8651
- * @param {String|Node} dirty string or DOM node
8652
- * @param {Object} cfg object
8653
- */
8654
- // eslint-disable-next-line complexity
8655
- DOMPurify.sanitize = function (dirty) {
8656
- let cfg = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
8657
- let body = null;
8658
- let importedNode = null;
8659
- let currentNode = null;
8660
- let returnNode = null;
8661
- /* Make sure we have a string to sanitize.
8662
- DO NOT return early, as this will return the wrong type if
8663
- the user has requested a DOM object rather than a string */
8664
- IS_EMPTY_INPUT = !dirty;
8665
- if (IS_EMPTY_INPUT) {
8666
- dirty = '<!-->';
8667
- }
8668
-
8669
- /* Stringify, in case dirty is an object */
8670
- if (typeof dirty !== 'string' && !_isNode(dirty)) {
8671
- if (typeof dirty.toString === 'function') {
8672
- dirty = dirty.toString();
8673
- if (typeof dirty !== 'string') {
8674
- throw typeErrorCreate('dirty is not a string, aborting');
8675
- }
8676
- } else {
8677
- throw typeErrorCreate('toString is not a function');
8678
- }
8679
- }
8680
-
8681
- /* Return dirty HTML if DOMPurify cannot run */
8682
- if (!DOMPurify.isSupported) {
8683
- return dirty;
8684
- }
8685
-
8686
- /* Assign config vars */
8687
- if (!SET_CONFIG) {
8688
- _parseConfig(cfg);
8689
- }
8690
-
8691
- /* Clean up removed elements */
8692
- DOMPurify.removed = [];
8693
-
8694
- /* Check if dirty is correctly typed for IN_PLACE */
8695
- if (typeof dirty === 'string') {
8696
- IN_PLACE = false;
8697
- }
8698
- if (IN_PLACE) {
8699
- /* Do some early pre-sanitization to avoid unsafe root nodes */
8700
- if (dirty.nodeName) {
8701
- const tagName = transformCaseFunc(dirty.nodeName);
8702
- if (!ALLOWED_TAGS[tagName] || FORBID_TAGS[tagName]) {
8703
- throw typeErrorCreate('root node is forbidden and cannot be sanitized in-place');
8704
- }
8705
- }
8706
- } else if (dirty instanceof Node) {
8707
- /* If dirty is a DOM element, append to an empty document to avoid
8708
- elements being stripped by the parser */
8709
- body = _initDocument('<!---->');
8710
- importedNode = body.ownerDocument.importNode(dirty, true);
8711
- if (importedNode.nodeType === 1 && importedNode.nodeName === 'BODY') {
8712
- /* Node is already a body, use as is */
8713
- body = importedNode;
8714
- } else if (importedNode.nodeName === 'HTML') {
8715
- body = importedNode;
8716
- } else {
8717
- // eslint-disable-next-line unicorn/prefer-dom-node-append
8718
- body.appendChild(importedNode);
8719
- }
8720
- } else {
8721
- /* Exit directly if we have nothing to do */
8722
- if (!RETURN_DOM && !SAFE_FOR_TEMPLATES && !WHOLE_DOCUMENT &&
8723
- // eslint-disable-next-line unicorn/prefer-includes
8724
- dirty.indexOf('<') === -1) {
8725
- return trustedTypesPolicy && RETURN_TRUSTED_TYPE ? trustedTypesPolicy.createHTML(dirty) : dirty;
8726
- }
8727
-
8728
- /* Initialize the document to work on */
8729
- body = _initDocument(dirty);
8730
-
8731
- /* Check we have a DOM node from the data */
8732
- if (!body) {
8733
- return RETURN_DOM ? null : RETURN_TRUSTED_TYPE ? emptyHTML : '';
8734
- }
8735
- }
8736
-
8737
- /* Remove first element node (ours) if FORCE_BODY is set */
8738
- if (body && FORCE_BODY) {
8739
- _forceRemove(body.firstChild);
8740
- }
8741
-
8742
- /* Get node iterator */
8743
- const nodeIterator = _createNodeIterator(IN_PLACE ? dirty : body);
8744
-
8745
- /* Now start iterating over the created document */
8746
- while (currentNode = nodeIterator.nextNode()) {
8747
- /* Sanitize tags and elements */
8748
- if (_sanitizeElements(currentNode)) {
8749
- continue;
8750
- }
8751
-
8752
- /* Shadow DOM detected, sanitize it */
8753
- if (currentNode.content instanceof DocumentFragment) {
8754
- _sanitizeShadowDOM(currentNode.content);
8755
- }
8756
-
8757
- /* Check attributes, sanitize if necessary */
8758
- _sanitizeAttributes(currentNode);
8759
- }
8760
-
8761
- /* If we sanitized `dirty` in-place, return it. */
8762
- if (IN_PLACE) {
8763
- return dirty;
8764
- }
8765
-
8766
- /* Return sanitized string or DOM */
8767
- if (RETURN_DOM) {
8768
- if (RETURN_DOM_FRAGMENT) {
8769
- returnNode = createDocumentFragment.call(body.ownerDocument);
8770
- while (body.firstChild) {
8771
- // eslint-disable-next-line unicorn/prefer-dom-node-append
8772
- returnNode.appendChild(body.firstChild);
8773
- }
8774
- } else {
8775
- returnNode = body;
8776
- }
8777
- if (ALLOWED_ATTR.shadowroot || ALLOWED_ATTR.shadowrootmode) {
8778
- /*
8779
- AdoptNode() is not used because internal state is not reset
8780
- (e.g. the past names map of a HTMLFormElement), this is safe
8781
- in theory but we would rather not risk another attack vector.
8782
- The state that is cloned by importNode() is explicitly defined
8783
- by the specs.
8784
- */
8785
- returnNode = importNode.call(originalDocument, returnNode, true);
8786
- }
8787
- return returnNode;
8788
- }
8789
- let serializedHTML = WHOLE_DOCUMENT ? body.outerHTML : body.innerHTML;
8790
-
8791
- /* Serialize doctype if allowed */
8792
- if (WHOLE_DOCUMENT && ALLOWED_TAGS['!doctype'] && body.ownerDocument && body.ownerDocument.doctype && body.ownerDocument.doctype.name && regExpTest(DOCTYPE_NAME, body.ownerDocument.doctype.name)) {
8793
- serializedHTML = '<!DOCTYPE ' + body.ownerDocument.doctype.name + '>\n' + serializedHTML;
8794
- }
8795
-
8796
- /* Sanitize final string template-safe */
8797
- if (SAFE_FOR_TEMPLATES) {
8798
- arrayForEach([MUSTACHE_EXPR, ERB_EXPR, TMPLIT_EXPR], expr => {
8799
- serializedHTML = stringReplace(serializedHTML, expr, ' ');
8800
- });
8801
- }
8802
- return trustedTypesPolicy && RETURN_TRUSTED_TYPE ? trustedTypesPolicy.createHTML(serializedHTML) : serializedHTML;
8803
- };
8804
-
8805
- /**
8806
- * Public method to set the configuration once
8807
- * setConfig
8808
- *
8809
- * @param {Object} cfg configuration object
8810
- */
8811
- DOMPurify.setConfig = function () {
8812
- let cfg = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
8813
- _parseConfig(cfg);
8814
- SET_CONFIG = true;
8815
- };
8816
-
8817
- /**
8818
- * Public method to remove the configuration
8819
- * clearConfig
8820
- *
8821
- */
8822
- DOMPurify.clearConfig = function () {
8823
- CONFIG = null;
8824
- SET_CONFIG = false;
8825
- };
8826
-
8827
- /**
8828
- * Public method to check if an attribute value is valid.
8829
- * Uses last set config, if any. Otherwise, uses config defaults.
8830
- * isValidAttribute
8831
- *
8832
- * @param {String} tag Tag name of containing element.
8833
- * @param {String} attr Attribute name.
8834
- * @param {String} value Attribute value.
8835
- * @return {Boolean} Returns true if `value` is valid. Otherwise, returns false.
8836
- */
8837
- DOMPurify.isValidAttribute = function (tag, attr, value) {
8838
- /* Initialize shared config vars if necessary. */
8839
- if (!CONFIG) {
8840
- _parseConfig({});
8841
- }
8842
- const lcTag = transformCaseFunc(tag);
8843
- const lcName = transformCaseFunc(attr);
8844
- return _isValidAttribute(lcTag, lcName, value);
8845
- };
8846
-
8847
- /**
8848
- * AddHook
8849
- * Public method to add DOMPurify hooks
8850
- *
8851
- * @param {String} entryPoint entry point for the hook to add
8852
- * @param {Function} hookFunction function to execute
8853
- */
8854
- DOMPurify.addHook = function (entryPoint, hookFunction) {
8855
- if (typeof hookFunction !== 'function') {
8856
- return;
8857
- }
8858
- hooks[entryPoint] = hooks[entryPoint] || [];
8859
- arrayPush(hooks[entryPoint], hookFunction);
8860
- };
8861
-
8862
- /**
8863
- * RemoveHook
8864
- * Public method to remove a DOMPurify hook at a given entryPoint
8865
- * (pops it from the stack of hooks if more are present)
8866
- *
8867
- * @param {String} entryPoint entry point for the hook to remove
8868
- * @return {Function} removed(popped) hook
8869
- */
8870
- DOMPurify.removeHook = function (entryPoint) {
8871
- if (hooks[entryPoint]) {
8872
- return arrayPop(hooks[entryPoint]);
8873
- }
8874
- };
8875
-
8876
- /**
8877
- * RemoveHooks
8878
- * Public method to remove all DOMPurify hooks at a given entryPoint
8879
- *
8880
- * @param {String} entryPoint entry point for the hooks to remove
8881
- */
8882
- DOMPurify.removeHooks = function (entryPoint) {
8883
- if (hooks[entryPoint]) {
8884
- hooks[entryPoint] = [];
8885
- }
8886
- };
8887
-
8888
- /**
8889
- * RemoveAllHooks
8890
- * Public method to remove all DOMPurify hooks
8891
- */
8892
- DOMPurify.removeAllHooks = function () {
8893
- hooks = {};
8894
- };
8895
- return DOMPurify;
8896
- }
8897
- var purify = createDOMPurify();
8898
-
8899
- return purify;
8900
-
8901
- }));
8902
- //# sourceMappingURL=purify.js.map
8903
-
8904
-
8905
7420
  /***/ }),
8906
7421
 
8907
7422
  /***/ 7187: