igv 2.15.10 → 2.15.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/igv.esm.js CHANGED
@@ -8100,10 +8100,10 @@ jQuery.isNumeric = function (obj) {
8100
8100
  const $$1 = jQuery;
8101
8101
 
8102
8102
  function div(options) {
8103
- return create("div", options);
8103
+ return create$1("div", options);
8104
8104
  }
8105
8105
 
8106
- function create(tag, options) {
8106
+ function create$1(tag, options) {
8107
8107
  const elem = document.createElement(tag);
8108
8108
  if (options) {
8109
8109
  if (options.class) {
@@ -8216,7 +8216,7 @@ function translateMouseCoordinates(event, domElement) {
8216
8216
  var domUtils = /*#__PURE__*/Object.freeze({
8217
8217
  __proto__: null,
8218
8218
  applyStyle: applyStyle,
8219
- create: create,
8219
+ create: create$1,
8220
8220
  div: div,
8221
8221
  empty: empty,
8222
8222
  guid: guid$2,
@@ -8229,6 +8229,1629 @@ var domUtils = /*#__PURE__*/Object.freeze({
8229
8229
  translateMouseCoordinates: translateMouseCoordinates
8230
8230
  });
8231
8231
 
8232
+ /*! @license DOMPurify 3.0.5 | (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.5/LICENSE */
8233
+
8234
+ const {
8235
+ entries,
8236
+ setPrototypeOf,
8237
+ isFrozen,
8238
+ getPrototypeOf,
8239
+ getOwnPropertyDescriptor
8240
+ } = Object;
8241
+ let {
8242
+ freeze,
8243
+ seal,
8244
+ create
8245
+ } = Object; // eslint-disable-line import/no-mutable-exports
8246
+
8247
+ let {
8248
+ apply,
8249
+ construct
8250
+ } = typeof Reflect !== 'undefined' && Reflect;
8251
+
8252
+ if (!apply) {
8253
+ apply = function apply(fun, thisValue, args) {
8254
+ return fun.apply(thisValue, args);
8255
+ };
8256
+ }
8257
+
8258
+ if (!freeze) {
8259
+ freeze = function freeze(x) {
8260
+ return x;
8261
+ };
8262
+ }
8263
+
8264
+ if (!seal) {
8265
+ seal = function seal(x) {
8266
+ return x;
8267
+ };
8268
+ }
8269
+
8270
+ if (!construct) {
8271
+ construct = function construct(Func, args) {
8272
+ return new Func(...args);
8273
+ };
8274
+ }
8275
+
8276
+ const arrayForEach = unapply(Array.prototype.forEach);
8277
+ const arrayPop = unapply(Array.prototype.pop);
8278
+ const arrayPush = unapply(Array.prototype.push);
8279
+ const stringToLowerCase = unapply(String.prototype.toLowerCase);
8280
+ const stringToString = unapply(String.prototype.toString);
8281
+ const stringMatch = unapply(String.prototype.match);
8282
+ const stringReplace = unapply(String.prototype.replace);
8283
+ const stringIndexOf = unapply(String.prototype.indexOf);
8284
+ const stringTrim = unapply(String.prototype.trim);
8285
+ const regExpTest = unapply(RegExp.prototype.test);
8286
+ const typeErrorCreate = unconstruct(TypeError);
8287
+ function unapply(func) {
8288
+ return function (thisArg) {
8289
+ for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
8290
+ args[_key - 1] = arguments[_key];
8291
+ }
8292
+
8293
+ return apply(func, thisArg, args);
8294
+ };
8295
+ }
8296
+ function unconstruct(func) {
8297
+ return function () {
8298
+ for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
8299
+ args[_key2] = arguments[_key2];
8300
+ }
8301
+
8302
+ return construct(func, args);
8303
+ };
8304
+ }
8305
+ /* Add properties to a lookup table */
8306
+
8307
+ function addToSet(set, array, transformCaseFunc) {
8308
+ var _transformCaseFunc;
8309
+
8310
+ transformCaseFunc = (_transformCaseFunc = transformCaseFunc) !== null && _transformCaseFunc !== void 0 ? _transformCaseFunc : stringToLowerCase;
8311
+
8312
+ if (setPrototypeOf) {
8313
+ // Make 'in' and truthy checks like Boolean(set.constructor)
8314
+ // independent of any properties defined on Object.prototype.
8315
+ // Prevent prototype setters from intercepting set as a this value.
8316
+ setPrototypeOf(set, null);
8317
+ }
8318
+
8319
+ let l = array.length;
8320
+
8321
+ while (l--) {
8322
+ let element = array[l];
8323
+
8324
+ if (typeof element === 'string') {
8325
+ const lcElement = transformCaseFunc(element);
8326
+
8327
+ if (lcElement !== element) {
8328
+ // Config presets (e.g. tags.js, attrs.js) are immutable.
8329
+ if (!isFrozen(array)) {
8330
+ array[l] = lcElement;
8331
+ }
8332
+
8333
+ element = lcElement;
8334
+ }
8335
+ }
8336
+
8337
+ set[element] = true;
8338
+ }
8339
+
8340
+ return set;
8341
+ }
8342
+ /* Shallow clone an object */
8343
+
8344
+ function clone(object) {
8345
+ const newObject = create(null);
8346
+
8347
+ for (const [property, value] of entries(object)) {
8348
+ newObject[property] = value;
8349
+ }
8350
+
8351
+ return newObject;
8352
+ }
8353
+ /* This method automatically checks if the prop is function
8354
+ * or getter and behaves accordingly. */
8355
+
8356
+ function lookupGetter(object, prop) {
8357
+ while (object !== null) {
8358
+ const desc = getOwnPropertyDescriptor(object, prop);
8359
+
8360
+ if (desc) {
8361
+ if (desc.get) {
8362
+ return unapply(desc.get);
8363
+ }
8364
+
8365
+ if (typeof desc.value === 'function') {
8366
+ return unapply(desc.value);
8367
+ }
8368
+ }
8369
+
8370
+ object = getPrototypeOf(object);
8371
+ }
8372
+
8373
+ function fallbackValue(element) {
8374
+ console.warn('fallback value for', element);
8375
+ return null;
8376
+ }
8377
+
8378
+ return fallbackValue;
8379
+ }
8380
+
8381
+ 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']); // SVG
8382
+
8383
+ 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']);
8384
+ 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']); // List of SVG elements that are disallowed by default.
8385
+ // We still need to know them so that we can do namespace
8386
+ // checks properly in case one wants to add them to
8387
+ // allow-list.
8388
+
8389
+ 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']);
8390
+ 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']); // Similarly to SVG, we want to know all MathML elements,
8391
+ // even those that we disallow by default.
8392
+
8393
+ const mathMlDisallowed = freeze(['maction', 'maligngroup', 'malignmark', 'mlongdiv', 'mscarries', 'mscarry', 'msgroup', 'mstack', 'msline', 'msrow', 'semantics', 'annotation', 'annotation-xml', 'mprescripts', 'none']);
8394
+ const text = freeze(['#text']);
8395
+
8396
+ 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']);
8397
+ 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']);
8398
+ 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']);
8399
+ const xml = freeze(['xlink:href', 'xml:id', 'xlink:title', 'xml:space', 'xmlns:xlink']);
8400
+
8401
+ const MUSTACHE_EXPR = seal(/\{\{[\w\W]*|[\w\W]*\}\}/gm); // Specify template detection regex for SAFE_FOR_TEMPLATES mode
8402
+
8403
+ const ERB_EXPR = seal(/<%[\w\W]*|[\w\W]*%>/gm);
8404
+ const TMPLIT_EXPR = seal(/\${[\w\W]*}/gm);
8405
+ const DATA_ATTR = seal(/^data-[\-\w.\u00B7-\uFFFF]/); // eslint-disable-line no-useless-escape
8406
+
8407
+ const ARIA_ATTR = seal(/^aria-[\-\w]+$/); // eslint-disable-line no-useless-escape
8408
+
8409
+ 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
8410
+ );
8411
+ const IS_SCRIPT_OR_DATA = seal(/^(?:\w+script|data):/i);
8412
+ const ATTR_WHITESPACE = seal(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g // eslint-disable-line no-control-regex
8413
+ );
8414
+ const DOCTYPE_NAME = seal(/^html$/i);
8415
+
8416
+ var EXPRESSIONS = /*#__PURE__*/Object.freeze({
8417
+ __proto__: null,
8418
+ MUSTACHE_EXPR: MUSTACHE_EXPR,
8419
+ ERB_EXPR: ERB_EXPR,
8420
+ TMPLIT_EXPR: TMPLIT_EXPR,
8421
+ DATA_ATTR: DATA_ATTR,
8422
+ ARIA_ATTR: ARIA_ATTR,
8423
+ IS_ALLOWED_URI: IS_ALLOWED_URI,
8424
+ IS_SCRIPT_OR_DATA: IS_SCRIPT_OR_DATA,
8425
+ ATTR_WHITESPACE: ATTR_WHITESPACE,
8426
+ DOCTYPE_NAME: DOCTYPE_NAME
8427
+ });
8428
+
8429
+ const getGlobal = () => typeof window === 'undefined' ? null : window;
8430
+ /**
8431
+ * Creates a no-op policy for internal use only.
8432
+ * Don't export this function outside this module!
8433
+ * @param {?TrustedTypePolicyFactory} trustedTypes The policy factory.
8434
+ * @param {HTMLScriptElement} purifyHostElement The Script element used to load DOMPurify (to determine policy name suffix).
8435
+ * @return {?TrustedTypePolicy} The policy created (or null, if Trusted Types
8436
+ * are not supported or creating the policy failed).
8437
+ */
8438
+
8439
+
8440
+ const _createTrustedTypesPolicy = function _createTrustedTypesPolicy(trustedTypes, purifyHostElement) {
8441
+ if (typeof trustedTypes !== 'object' || typeof trustedTypes.createPolicy !== 'function') {
8442
+ return null;
8443
+ } // Allow the callers to control the unique policy name
8444
+ // by adding a data-tt-policy-suffix to the script element with the DOMPurify.
8445
+ // Policy creation with duplicate names throws in Trusted Types.
8446
+
8447
+
8448
+ let suffix = null;
8449
+ const ATTR_NAME = 'data-tt-policy-suffix';
8450
+
8451
+ if (purifyHostElement && purifyHostElement.hasAttribute(ATTR_NAME)) {
8452
+ suffix = purifyHostElement.getAttribute(ATTR_NAME);
8453
+ }
8454
+
8455
+ const policyName = 'dompurify' + (suffix ? '#' + suffix : '');
8456
+
8457
+ try {
8458
+ return trustedTypes.createPolicy(policyName, {
8459
+ createHTML(html) {
8460
+ return html;
8461
+ },
8462
+
8463
+ createScriptURL(scriptUrl) {
8464
+ return scriptUrl;
8465
+ }
8466
+
8467
+ });
8468
+ } catch (_) {
8469
+ // Policy creation failed (most likely another DOMPurify script has
8470
+ // already run). Skip creating the policy, as this will only cause errors
8471
+ // if TT are enforced.
8472
+ console.warn('TrustedTypes policy ' + policyName + ' could not be created.');
8473
+ return null;
8474
+ }
8475
+ };
8476
+
8477
+ function createDOMPurify() {
8478
+ let window = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : getGlobal();
8479
+
8480
+ const DOMPurify = root => createDOMPurify(root);
8481
+ /**
8482
+ * Version label, exposed for easier checks
8483
+ * if DOMPurify is up to date or not
8484
+ */
8485
+
8486
+
8487
+ DOMPurify.version = '3.0.5';
8488
+ /**
8489
+ * Array of elements that DOMPurify removed during sanitation.
8490
+ * Empty if nothing was removed.
8491
+ */
8492
+
8493
+ DOMPurify.removed = [];
8494
+
8495
+ if (!window || !window.document || window.document.nodeType !== 9) {
8496
+ // Not running in a browser, provide a factory function
8497
+ // so that you can pass your own Window
8498
+ DOMPurify.isSupported = false;
8499
+ return DOMPurify;
8500
+ }
8501
+
8502
+ const originalDocument = window.document;
8503
+ const currentScript = originalDocument.currentScript;
8504
+ let {
8505
+ document
8506
+ } = window;
8507
+ const {
8508
+ DocumentFragment,
8509
+ HTMLTemplateElement,
8510
+ Node,
8511
+ Element,
8512
+ NodeFilter,
8513
+ NamedNodeMap = window.NamedNodeMap || window.MozNamedAttrMap,
8514
+ HTMLFormElement,
8515
+ DOMParser,
8516
+ trustedTypes
8517
+ } = window;
8518
+ const ElementPrototype = Element.prototype;
8519
+ const cloneNode = lookupGetter(ElementPrototype, 'cloneNode');
8520
+ const getNextSibling = lookupGetter(ElementPrototype, 'nextSibling');
8521
+ const getChildNodes = lookupGetter(ElementPrototype, 'childNodes');
8522
+ const getParentNode = lookupGetter(ElementPrototype, 'parentNode'); // As per issue #47, the web-components registry is inherited by a
8523
+ // new document created via createHTMLDocument. As per the spec
8524
+ // (http://w3c.github.io/webcomponents/spec/custom/#creating-and-passing-registries)
8525
+ // a new empty registry is used when creating a template contents owner
8526
+ // document, so we use that as our parent document to ensure nothing
8527
+ // is inherited.
8528
+
8529
+ if (typeof HTMLTemplateElement === 'function') {
8530
+ const template = document.createElement('template');
8531
+
8532
+ if (template.content && template.content.ownerDocument) {
8533
+ document = template.content.ownerDocument;
8534
+ }
8535
+ }
8536
+
8537
+ let trustedTypesPolicy;
8538
+ let emptyHTML = '';
8539
+ const {
8540
+ implementation,
8541
+ createNodeIterator,
8542
+ createDocumentFragment,
8543
+ getElementsByTagName
8544
+ } = document;
8545
+ const {
8546
+ importNode
8547
+ } = originalDocument;
8548
+ let hooks = {};
8549
+ /**
8550
+ * Expose whether this browser supports running the full DOMPurify.
8551
+ */
8552
+
8553
+ DOMPurify.isSupported = typeof entries === 'function' && typeof getParentNode === 'function' && implementation && implementation.createHTMLDocument !== undefined;
8554
+ const {
8555
+ MUSTACHE_EXPR,
8556
+ ERB_EXPR,
8557
+ TMPLIT_EXPR,
8558
+ DATA_ATTR,
8559
+ ARIA_ATTR,
8560
+ IS_SCRIPT_OR_DATA,
8561
+ ATTR_WHITESPACE
8562
+ } = EXPRESSIONS;
8563
+ let {
8564
+ IS_ALLOWED_URI: IS_ALLOWED_URI$1
8565
+ } = EXPRESSIONS;
8566
+ /**
8567
+ * We consider the elements and attributes below to be safe. Ideally
8568
+ * don't add any new ones but feel free to remove unwanted ones.
8569
+ */
8570
+
8571
+ /* allowed element names */
8572
+
8573
+ let ALLOWED_TAGS = null;
8574
+ const DEFAULT_ALLOWED_TAGS = addToSet({}, [...html$1, ...svg$1, ...svgFilters, ...mathMl$1, ...text]);
8575
+ /* Allowed attribute names */
8576
+
8577
+ let ALLOWED_ATTR = null;
8578
+ const DEFAULT_ALLOWED_ATTR = addToSet({}, [...html, ...svg, ...mathMl, ...xml]);
8579
+ /*
8580
+ * Configure how DOMPUrify should handle custom elements and their attributes as well as customized built-in elements.
8581
+ * @property {RegExp|Function|null} tagNameCheck one of [null, regexPattern, predicate]. Default: `null` (disallow any custom elements)
8582
+ * @property {RegExp|Function|null} attributeNameCheck one of [null, regexPattern, predicate]. Default: `null` (disallow any attributes not on the allow list)
8583
+ * @property {boolean} allowCustomizedBuiltInElements allow custom elements derived from built-ins if they pass CUSTOM_ELEMENT_HANDLING.tagNameCheck. Default: `false`.
8584
+ */
8585
+
8586
+ let CUSTOM_ELEMENT_HANDLING = Object.seal(Object.create(null, {
8587
+ tagNameCheck: {
8588
+ writable: true,
8589
+ configurable: false,
8590
+ enumerable: true,
8591
+ value: null
8592
+ },
8593
+ attributeNameCheck: {
8594
+ writable: true,
8595
+ configurable: false,
8596
+ enumerable: true,
8597
+ value: null
8598
+ },
8599
+ allowCustomizedBuiltInElements: {
8600
+ writable: true,
8601
+ configurable: false,
8602
+ enumerable: true,
8603
+ value: false
8604
+ }
8605
+ }));
8606
+ /* Explicitly forbidden tags (overrides ALLOWED_TAGS/ADD_TAGS) */
8607
+
8608
+ let FORBID_TAGS = null;
8609
+ /* Explicitly forbidden attributes (overrides ALLOWED_ATTR/ADD_ATTR) */
8610
+
8611
+ let FORBID_ATTR = null;
8612
+ /* Decide if ARIA attributes are okay */
8613
+
8614
+ let ALLOW_ARIA_ATTR = true;
8615
+ /* Decide if custom data attributes are okay */
8616
+
8617
+ let ALLOW_DATA_ATTR = true;
8618
+ /* Decide if unknown protocols are okay */
8619
+
8620
+ let ALLOW_UNKNOWN_PROTOCOLS = false;
8621
+ /* Decide if self-closing tags in attributes are allowed.
8622
+ * Usually removed due to a mXSS issue in jQuery 3.0 */
8623
+
8624
+ let ALLOW_SELF_CLOSE_IN_ATTR = true;
8625
+ /* Output should be safe for common template engines.
8626
+ * This means, DOMPurify removes data attributes, mustaches and ERB
8627
+ */
8628
+
8629
+ let SAFE_FOR_TEMPLATES = false;
8630
+ /* Decide if document with <html>... should be returned */
8631
+
8632
+ let WHOLE_DOCUMENT = false;
8633
+ /* Track whether config is already set on this instance of DOMPurify. */
8634
+
8635
+ let SET_CONFIG = false;
8636
+ /* Decide if all elements (e.g. style, script) must be children of
8637
+ * document.body. By default, browsers might move them to document.head */
8638
+
8639
+ let FORCE_BODY = false;
8640
+ /* Decide if a DOM `HTMLBodyElement` should be returned, instead of a html
8641
+ * string (or a TrustedHTML object if Trusted Types are supported).
8642
+ * If `WHOLE_DOCUMENT` is enabled a `HTMLHtmlElement` will be returned instead
8643
+ */
8644
+
8645
+ let RETURN_DOM = false;
8646
+ /* Decide if a DOM `DocumentFragment` should be returned, instead of a html
8647
+ * string (or a TrustedHTML object if Trusted Types are supported) */
8648
+
8649
+ let RETURN_DOM_FRAGMENT = false;
8650
+ /* Try to return a Trusted Type object instead of a string, return a string in
8651
+ * case Trusted Types are not supported */
8652
+
8653
+ let RETURN_TRUSTED_TYPE = false;
8654
+ /* Output should be free from DOM clobbering attacks?
8655
+ * This sanitizes markups named with colliding, clobberable built-in DOM APIs.
8656
+ */
8657
+
8658
+ let SANITIZE_DOM = true;
8659
+ /* Achieve full DOM Clobbering protection by isolating the namespace of named
8660
+ * properties and JS variables, mitigating attacks that abuse the HTML/DOM spec rules.
8661
+ *
8662
+ * HTML/DOM spec rules that enable DOM Clobbering:
8663
+ * - Named Access on Window (§7.3.3)
8664
+ * - DOM Tree Accessors (§3.1.5)
8665
+ * - Form Element Parent-Child Relations (§4.10.3)
8666
+ * - Iframe srcdoc / Nested WindowProxies (§4.8.5)
8667
+ * - HTMLCollection (§4.2.10.2)
8668
+ *
8669
+ * Namespace isolation is implemented by prefixing `id` and `name` attributes
8670
+ * with a constant string, i.e., `user-content-`
8671
+ */
8672
+
8673
+ let SANITIZE_NAMED_PROPS = false;
8674
+ const SANITIZE_NAMED_PROPS_PREFIX = 'user-content-';
8675
+ /* Keep element content when removing element? */
8676
+
8677
+ let KEEP_CONTENT = true;
8678
+ /* If a `Node` is passed to sanitize(), then performs sanitization in-place instead
8679
+ * of importing it into a new Document and returning a sanitized copy */
8680
+
8681
+ let IN_PLACE = false;
8682
+ /* Allow usage of profiles like html, svg and mathMl */
8683
+
8684
+ let USE_PROFILES = {};
8685
+ /* Tags to ignore content of when KEEP_CONTENT is true */
8686
+
8687
+ let FORBID_CONTENTS = null;
8688
+ 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']);
8689
+ /* Tags that are safe for data: URIs */
8690
+
8691
+ let DATA_URI_TAGS = null;
8692
+ const DEFAULT_DATA_URI_TAGS = addToSet({}, ['audio', 'video', 'img', 'source', 'image', 'track']);
8693
+ /* Attributes safe for values like "javascript:" */
8694
+
8695
+ let URI_SAFE_ATTRIBUTES = null;
8696
+ const DEFAULT_URI_SAFE_ATTRIBUTES = addToSet({}, ['alt', 'class', 'for', 'id', 'label', 'name', 'pattern', 'placeholder', 'role', 'summary', 'title', 'value', 'style', 'xmlns']);
8697
+ const MATHML_NAMESPACE = 'http://www.w3.org/1998/Math/MathML';
8698
+ const SVG_NAMESPACE = 'http://www.w3.org/2000/svg';
8699
+ const HTML_NAMESPACE = 'http://www.w3.org/1999/xhtml';
8700
+ /* Document namespace */
8701
+
8702
+ let NAMESPACE = HTML_NAMESPACE;
8703
+ let IS_EMPTY_INPUT = false;
8704
+ /* Allowed XHTML+XML namespaces */
8705
+
8706
+ let ALLOWED_NAMESPACES = null;
8707
+ const DEFAULT_ALLOWED_NAMESPACES = addToSet({}, [MATHML_NAMESPACE, SVG_NAMESPACE, HTML_NAMESPACE], stringToString);
8708
+ /* Parsing of strict XHTML documents */
8709
+
8710
+ let PARSER_MEDIA_TYPE;
8711
+ const SUPPORTED_PARSER_MEDIA_TYPES = ['application/xhtml+xml', 'text/html'];
8712
+ const DEFAULT_PARSER_MEDIA_TYPE = 'text/html';
8713
+ let transformCaseFunc;
8714
+ /* Keep a reference to config to pass to hooks */
8715
+
8716
+ let CONFIG = null;
8717
+ /* Ideally, do not touch anything below this line */
8718
+
8719
+ /* ______________________________________________ */
8720
+
8721
+ const formElement = document.createElement('form');
8722
+
8723
+ const isRegexOrFunction = function isRegexOrFunction(testValue) {
8724
+ return testValue instanceof RegExp || testValue instanceof Function;
8725
+ };
8726
+ /**
8727
+ * _parseConfig
8728
+ *
8729
+ * @param {Object} cfg optional config literal
8730
+ */
8731
+ // eslint-disable-next-line complexity
8732
+
8733
+
8734
+ const _parseConfig = function _parseConfig(cfg) {
8735
+ if (CONFIG && CONFIG === cfg) {
8736
+ return;
8737
+ }
8738
+ /* Shield configuration object from tampering */
8739
+
8740
+
8741
+ if (!cfg || typeof cfg !== 'object') {
8742
+ cfg = {};
8743
+ }
8744
+ /* Shield configuration object from prototype pollution */
8745
+
8746
+
8747
+ cfg = clone(cfg);
8748
+ PARSER_MEDIA_TYPE = // eslint-disable-next-line unicorn/prefer-includes
8749
+ SUPPORTED_PARSER_MEDIA_TYPES.indexOf(cfg.PARSER_MEDIA_TYPE) === -1 ? PARSER_MEDIA_TYPE = DEFAULT_PARSER_MEDIA_TYPE : PARSER_MEDIA_TYPE = cfg.PARSER_MEDIA_TYPE; // HTML tags and attributes are not case-sensitive, converting to lowercase. Keeping XHTML as is.
8750
+
8751
+ transformCaseFunc = PARSER_MEDIA_TYPE === 'application/xhtml+xml' ? stringToString : stringToLowerCase;
8752
+ /* Set configuration parameters */
8753
+
8754
+ ALLOWED_TAGS = 'ALLOWED_TAGS' in cfg ? addToSet({}, cfg.ALLOWED_TAGS, transformCaseFunc) : DEFAULT_ALLOWED_TAGS;
8755
+ ALLOWED_ATTR = 'ALLOWED_ATTR' in cfg ? addToSet({}, cfg.ALLOWED_ATTR, transformCaseFunc) : DEFAULT_ALLOWED_ATTR;
8756
+ ALLOWED_NAMESPACES = 'ALLOWED_NAMESPACES' in cfg ? addToSet({}, cfg.ALLOWED_NAMESPACES, stringToString) : DEFAULT_ALLOWED_NAMESPACES;
8757
+ URI_SAFE_ATTRIBUTES = 'ADD_URI_SAFE_ATTR' in cfg ? addToSet(clone(DEFAULT_URI_SAFE_ATTRIBUTES), // eslint-disable-line indent
8758
+ cfg.ADD_URI_SAFE_ATTR, // eslint-disable-line indent
8759
+ transformCaseFunc // eslint-disable-line indent
8760
+ ) // eslint-disable-line indent
8761
+ : DEFAULT_URI_SAFE_ATTRIBUTES;
8762
+ DATA_URI_TAGS = 'ADD_DATA_URI_TAGS' in cfg ? addToSet(clone(DEFAULT_DATA_URI_TAGS), // eslint-disable-line indent
8763
+ cfg.ADD_DATA_URI_TAGS, // eslint-disable-line indent
8764
+ transformCaseFunc // eslint-disable-line indent
8765
+ ) // eslint-disable-line indent
8766
+ : DEFAULT_DATA_URI_TAGS;
8767
+ FORBID_CONTENTS = 'FORBID_CONTENTS' in cfg ? addToSet({}, cfg.FORBID_CONTENTS, transformCaseFunc) : DEFAULT_FORBID_CONTENTS;
8768
+ FORBID_TAGS = 'FORBID_TAGS' in cfg ? addToSet({}, cfg.FORBID_TAGS, transformCaseFunc) : {};
8769
+ FORBID_ATTR = 'FORBID_ATTR' in cfg ? addToSet({}, cfg.FORBID_ATTR, transformCaseFunc) : {};
8770
+ USE_PROFILES = 'USE_PROFILES' in cfg ? cfg.USE_PROFILES : false;
8771
+ ALLOW_ARIA_ATTR = cfg.ALLOW_ARIA_ATTR !== false; // Default true
8772
+
8773
+ ALLOW_DATA_ATTR = cfg.ALLOW_DATA_ATTR !== false; // Default true
8774
+
8775
+ ALLOW_UNKNOWN_PROTOCOLS = cfg.ALLOW_UNKNOWN_PROTOCOLS || false; // Default false
8776
+
8777
+ ALLOW_SELF_CLOSE_IN_ATTR = cfg.ALLOW_SELF_CLOSE_IN_ATTR !== false; // Default true
8778
+
8779
+ SAFE_FOR_TEMPLATES = cfg.SAFE_FOR_TEMPLATES || false; // Default false
8780
+
8781
+ WHOLE_DOCUMENT = cfg.WHOLE_DOCUMENT || false; // Default false
8782
+
8783
+ RETURN_DOM = cfg.RETURN_DOM || false; // Default false
8784
+
8785
+ RETURN_DOM_FRAGMENT = cfg.RETURN_DOM_FRAGMENT || false; // Default false
8786
+
8787
+ RETURN_TRUSTED_TYPE = cfg.RETURN_TRUSTED_TYPE || false; // Default false
8788
+
8789
+ FORCE_BODY = cfg.FORCE_BODY || false; // Default false
8790
+
8791
+ SANITIZE_DOM = cfg.SANITIZE_DOM !== false; // Default true
8792
+
8793
+ SANITIZE_NAMED_PROPS = cfg.SANITIZE_NAMED_PROPS || false; // Default false
8794
+
8795
+ KEEP_CONTENT = cfg.KEEP_CONTENT !== false; // Default true
8796
+
8797
+ IN_PLACE = cfg.IN_PLACE || false; // Default false
8798
+
8799
+ IS_ALLOWED_URI$1 = cfg.ALLOWED_URI_REGEXP || IS_ALLOWED_URI;
8800
+ NAMESPACE = cfg.NAMESPACE || HTML_NAMESPACE;
8801
+ CUSTOM_ELEMENT_HANDLING = cfg.CUSTOM_ELEMENT_HANDLING || {};
8802
+
8803
+ if (cfg.CUSTOM_ELEMENT_HANDLING && isRegexOrFunction(cfg.CUSTOM_ELEMENT_HANDLING.tagNameCheck)) {
8804
+ CUSTOM_ELEMENT_HANDLING.tagNameCheck = cfg.CUSTOM_ELEMENT_HANDLING.tagNameCheck;
8805
+ }
8806
+
8807
+ if (cfg.CUSTOM_ELEMENT_HANDLING && isRegexOrFunction(cfg.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)) {
8808
+ CUSTOM_ELEMENT_HANDLING.attributeNameCheck = cfg.CUSTOM_ELEMENT_HANDLING.attributeNameCheck;
8809
+ }
8810
+
8811
+ if (cfg.CUSTOM_ELEMENT_HANDLING && typeof cfg.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements === 'boolean') {
8812
+ CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements = cfg.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements;
8813
+ }
8814
+
8815
+ if (SAFE_FOR_TEMPLATES) {
8816
+ ALLOW_DATA_ATTR = false;
8817
+ }
8818
+
8819
+ if (RETURN_DOM_FRAGMENT) {
8820
+ RETURN_DOM = true;
8821
+ }
8822
+ /* Parse profile info */
8823
+
8824
+
8825
+ if (USE_PROFILES) {
8826
+ ALLOWED_TAGS = addToSet({}, [...text]);
8827
+ ALLOWED_ATTR = [];
8828
+
8829
+ if (USE_PROFILES.html === true) {
8830
+ addToSet(ALLOWED_TAGS, html$1);
8831
+ addToSet(ALLOWED_ATTR, html);
8832
+ }
8833
+
8834
+ if (USE_PROFILES.svg === true) {
8835
+ addToSet(ALLOWED_TAGS, svg$1);
8836
+ addToSet(ALLOWED_ATTR, svg);
8837
+ addToSet(ALLOWED_ATTR, xml);
8838
+ }
8839
+
8840
+ if (USE_PROFILES.svgFilters === true) {
8841
+ addToSet(ALLOWED_TAGS, svgFilters);
8842
+ addToSet(ALLOWED_ATTR, svg);
8843
+ addToSet(ALLOWED_ATTR, xml);
8844
+ }
8845
+
8846
+ if (USE_PROFILES.mathMl === true) {
8847
+ addToSet(ALLOWED_TAGS, mathMl$1);
8848
+ addToSet(ALLOWED_ATTR, mathMl);
8849
+ addToSet(ALLOWED_ATTR, xml);
8850
+ }
8851
+ }
8852
+ /* Merge configuration parameters */
8853
+
8854
+
8855
+ if (cfg.ADD_TAGS) {
8856
+ if (ALLOWED_TAGS === DEFAULT_ALLOWED_TAGS) {
8857
+ ALLOWED_TAGS = clone(ALLOWED_TAGS);
8858
+ }
8859
+
8860
+ addToSet(ALLOWED_TAGS, cfg.ADD_TAGS, transformCaseFunc);
8861
+ }
8862
+
8863
+ if (cfg.ADD_ATTR) {
8864
+ if (ALLOWED_ATTR === DEFAULT_ALLOWED_ATTR) {
8865
+ ALLOWED_ATTR = clone(ALLOWED_ATTR);
8866
+ }
8867
+
8868
+ addToSet(ALLOWED_ATTR, cfg.ADD_ATTR, transformCaseFunc);
8869
+ }
8870
+
8871
+ if (cfg.ADD_URI_SAFE_ATTR) {
8872
+ addToSet(URI_SAFE_ATTRIBUTES, cfg.ADD_URI_SAFE_ATTR, transformCaseFunc);
8873
+ }
8874
+
8875
+ if (cfg.FORBID_CONTENTS) {
8876
+ if (FORBID_CONTENTS === DEFAULT_FORBID_CONTENTS) {
8877
+ FORBID_CONTENTS = clone(FORBID_CONTENTS);
8878
+ }
8879
+
8880
+ addToSet(FORBID_CONTENTS, cfg.FORBID_CONTENTS, transformCaseFunc);
8881
+ }
8882
+ /* Add #text in case KEEP_CONTENT is set to true */
8883
+
8884
+
8885
+ if (KEEP_CONTENT) {
8886
+ ALLOWED_TAGS['#text'] = true;
8887
+ }
8888
+ /* Add html, head and body to ALLOWED_TAGS in case WHOLE_DOCUMENT is true */
8889
+
8890
+
8891
+ if (WHOLE_DOCUMENT) {
8892
+ addToSet(ALLOWED_TAGS, ['html', 'head', 'body']);
8893
+ }
8894
+ /* Add tbody to ALLOWED_TAGS in case tables are permitted, see #286, #365 */
8895
+
8896
+
8897
+ if (ALLOWED_TAGS.table) {
8898
+ addToSet(ALLOWED_TAGS, ['tbody']);
8899
+ delete FORBID_TAGS.tbody;
8900
+ }
8901
+
8902
+ if (cfg.TRUSTED_TYPES_POLICY) {
8903
+ if (typeof cfg.TRUSTED_TYPES_POLICY.createHTML !== 'function') {
8904
+ throw typeErrorCreate('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');
8905
+ }
8906
+
8907
+ if (typeof cfg.TRUSTED_TYPES_POLICY.createScriptURL !== 'function') {
8908
+ throw typeErrorCreate('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');
8909
+ } // Overwrite existing TrustedTypes policy.
8910
+
8911
+
8912
+ trustedTypesPolicy = cfg.TRUSTED_TYPES_POLICY; // Sign local variables required by `sanitize`.
8913
+
8914
+ emptyHTML = trustedTypesPolicy.createHTML('');
8915
+ } else {
8916
+ // Uninitialized policy, attempt to initialize the internal dompurify policy.
8917
+ if (trustedTypesPolicy === undefined) {
8918
+ trustedTypesPolicy = _createTrustedTypesPolicy(trustedTypes, currentScript);
8919
+ } // If creating the internal policy succeeded sign internal variables.
8920
+
8921
+
8922
+ if (trustedTypesPolicy !== null && typeof emptyHTML === 'string') {
8923
+ emptyHTML = trustedTypesPolicy.createHTML('');
8924
+ }
8925
+ } // Prevent further manipulation of configuration.
8926
+ // Not available in IE8, Safari 5, etc.
8927
+
8928
+
8929
+ if (freeze) {
8930
+ freeze(cfg);
8931
+ }
8932
+
8933
+ CONFIG = cfg;
8934
+ };
8935
+
8936
+ const MATHML_TEXT_INTEGRATION_POINTS = addToSet({}, ['mi', 'mo', 'mn', 'ms', 'mtext']);
8937
+ const HTML_INTEGRATION_POINTS = addToSet({}, ['foreignobject', 'desc', 'title', 'annotation-xml']); // Certain elements are allowed in both SVG and HTML
8938
+ // namespace. We need to specify them explicitly
8939
+ // so that they don't get erroneously deleted from
8940
+ // HTML namespace.
8941
+
8942
+ const COMMON_SVG_AND_HTML_ELEMENTS = addToSet({}, ['title', 'style', 'font', 'a', 'script']);
8943
+ /* Keep track of all possible SVG and MathML tags
8944
+ * so that we can perform the namespace checks
8945
+ * correctly. */
8946
+
8947
+ const ALL_SVG_TAGS = addToSet({}, svg$1);
8948
+ addToSet(ALL_SVG_TAGS, svgFilters);
8949
+ addToSet(ALL_SVG_TAGS, svgDisallowed);
8950
+ const ALL_MATHML_TAGS = addToSet({}, mathMl$1);
8951
+ addToSet(ALL_MATHML_TAGS, mathMlDisallowed);
8952
+ /**
8953
+ *
8954
+ *
8955
+ * @param {Element} element a DOM element whose namespace is being checked
8956
+ * @returns {boolean} Return false if the element has a
8957
+ * namespace that a spec-compliant parser would never
8958
+ * return. Return true otherwise.
8959
+ */
8960
+
8961
+ const _checkValidNamespace = function _checkValidNamespace(element) {
8962
+ let parent = getParentNode(element); // In JSDOM, if we're inside shadow DOM, then parentNode
8963
+ // can be null. We just simulate parent in this case.
8964
+
8965
+ if (!parent || !parent.tagName) {
8966
+ parent = {
8967
+ namespaceURI: NAMESPACE,
8968
+ tagName: 'template'
8969
+ };
8970
+ }
8971
+
8972
+ const tagName = stringToLowerCase(element.tagName);
8973
+ const parentTagName = stringToLowerCase(parent.tagName);
8974
+
8975
+ if (!ALLOWED_NAMESPACES[element.namespaceURI]) {
8976
+ return false;
8977
+ }
8978
+
8979
+ if (element.namespaceURI === SVG_NAMESPACE) {
8980
+ // The only way to switch from HTML namespace to SVG
8981
+ // is via <svg>. If it happens via any other tag, then
8982
+ // it should be killed.
8983
+ if (parent.namespaceURI === HTML_NAMESPACE) {
8984
+ return tagName === 'svg';
8985
+ } // The only way to switch from MathML to SVG is via`
8986
+ // svg if parent is either <annotation-xml> or MathML
8987
+ // text integration points.
8988
+
8989
+
8990
+ if (parent.namespaceURI === MATHML_NAMESPACE) {
8991
+ return tagName === 'svg' && (parentTagName === 'annotation-xml' || MATHML_TEXT_INTEGRATION_POINTS[parentTagName]);
8992
+ } // We only allow elements that are defined in SVG
8993
+ // spec. All others are disallowed in SVG namespace.
8994
+
8995
+
8996
+ return Boolean(ALL_SVG_TAGS[tagName]);
8997
+ }
8998
+
8999
+ if (element.namespaceURI === MATHML_NAMESPACE) {
9000
+ // The only way to switch from HTML namespace to MathML
9001
+ // is via <math>. If it happens via any other tag, then
9002
+ // it should be killed.
9003
+ if (parent.namespaceURI === HTML_NAMESPACE) {
9004
+ return tagName === 'math';
9005
+ } // The only way to switch from SVG to MathML is via
9006
+ // <math> and HTML integration points
9007
+
9008
+
9009
+ if (parent.namespaceURI === SVG_NAMESPACE) {
9010
+ return tagName === 'math' && HTML_INTEGRATION_POINTS[parentTagName];
9011
+ } // We only allow elements that are defined in MathML
9012
+ // spec. All others are disallowed in MathML namespace.
9013
+
9014
+
9015
+ return Boolean(ALL_MATHML_TAGS[tagName]);
9016
+ }
9017
+
9018
+ if (element.namespaceURI === HTML_NAMESPACE) {
9019
+ // The only way to switch from SVG to HTML is via
9020
+ // HTML integration points, and from MathML to HTML
9021
+ // is via MathML text integration points
9022
+ if (parent.namespaceURI === SVG_NAMESPACE && !HTML_INTEGRATION_POINTS[parentTagName]) {
9023
+ return false;
9024
+ }
9025
+
9026
+ if (parent.namespaceURI === MATHML_NAMESPACE && !MATHML_TEXT_INTEGRATION_POINTS[parentTagName]) {
9027
+ return false;
9028
+ } // We disallow tags that are specific for MathML
9029
+ // or SVG and should never appear in HTML namespace
9030
+
9031
+
9032
+ return !ALL_MATHML_TAGS[tagName] && (COMMON_SVG_AND_HTML_ELEMENTS[tagName] || !ALL_SVG_TAGS[tagName]);
9033
+ } // For XHTML and XML documents that support custom namespaces
9034
+
9035
+
9036
+ if (PARSER_MEDIA_TYPE === 'application/xhtml+xml' && ALLOWED_NAMESPACES[element.namespaceURI]) {
9037
+ return true;
9038
+ } // The code should never reach this place (this means
9039
+ // that the element somehow got namespace that is not
9040
+ // HTML, SVG, MathML or allowed via ALLOWED_NAMESPACES).
9041
+ // Return false just in case.
9042
+
9043
+
9044
+ return false;
9045
+ };
9046
+ /**
9047
+ * _forceRemove
9048
+ *
9049
+ * @param {Node} node a DOM node
9050
+ */
9051
+
9052
+
9053
+ const _forceRemove = function _forceRemove(node) {
9054
+ arrayPush(DOMPurify.removed, {
9055
+ element: node
9056
+ });
9057
+
9058
+ try {
9059
+ // eslint-disable-next-line unicorn/prefer-dom-node-remove
9060
+ node.parentNode.removeChild(node);
9061
+ } catch (_) {
9062
+ node.remove();
9063
+ }
9064
+ };
9065
+ /**
9066
+ * _removeAttribute
9067
+ *
9068
+ * @param {String} name an Attribute name
9069
+ * @param {Node} node a DOM node
9070
+ */
9071
+
9072
+
9073
+ const _removeAttribute = function _removeAttribute(name, node) {
9074
+ try {
9075
+ arrayPush(DOMPurify.removed, {
9076
+ attribute: node.getAttributeNode(name),
9077
+ from: node
9078
+ });
9079
+ } catch (_) {
9080
+ arrayPush(DOMPurify.removed, {
9081
+ attribute: null,
9082
+ from: node
9083
+ });
9084
+ }
9085
+
9086
+ node.removeAttribute(name); // We void attribute values for unremovable "is"" attributes
9087
+
9088
+ if (name === 'is' && !ALLOWED_ATTR[name]) {
9089
+ if (RETURN_DOM || RETURN_DOM_FRAGMENT) {
9090
+ try {
9091
+ _forceRemove(node);
9092
+ } catch (_) {}
9093
+ } else {
9094
+ try {
9095
+ node.setAttribute(name, '');
9096
+ } catch (_) {}
9097
+ }
9098
+ }
9099
+ };
9100
+ /**
9101
+ * _initDocument
9102
+ *
9103
+ * @param {String} dirty a string of dirty markup
9104
+ * @return {Document} a DOM, filled with the dirty markup
9105
+ */
9106
+
9107
+
9108
+ const _initDocument = function _initDocument(dirty) {
9109
+ /* Create a HTML document */
9110
+ let doc;
9111
+ let leadingWhitespace;
9112
+
9113
+ if (FORCE_BODY) {
9114
+ dirty = '<remove></remove>' + dirty;
9115
+ } else {
9116
+ /* If FORCE_BODY isn't used, leading whitespace needs to be preserved manually */
9117
+ const matches = stringMatch(dirty, /^[\r\n\t ]+/);
9118
+ leadingWhitespace = matches && matches[0];
9119
+ }
9120
+
9121
+ if (PARSER_MEDIA_TYPE === 'application/xhtml+xml' && NAMESPACE === HTML_NAMESPACE) {
9122
+ // Root of XHTML doc must contain xmlns declaration (see https://www.w3.org/TR/xhtml1/normative.html#strict)
9123
+ dirty = '<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>' + dirty + '</body></html>';
9124
+ }
9125
+
9126
+ const dirtyPayload = trustedTypesPolicy ? trustedTypesPolicy.createHTML(dirty) : dirty;
9127
+ /*
9128
+ * Use the DOMParser API by default, fallback later if needs be
9129
+ * DOMParser not work for svg when has multiple root element.
9130
+ */
9131
+
9132
+ if (NAMESPACE === HTML_NAMESPACE) {
9133
+ try {
9134
+ doc = new DOMParser().parseFromString(dirtyPayload, PARSER_MEDIA_TYPE);
9135
+ } catch (_) {}
9136
+ }
9137
+ /* Use createHTMLDocument in case DOMParser is not available */
9138
+
9139
+
9140
+ if (!doc || !doc.documentElement) {
9141
+ doc = implementation.createDocument(NAMESPACE, 'template', null);
9142
+
9143
+ try {
9144
+ doc.documentElement.innerHTML = IS_EMPTY_INPUT ? emptyHTML : dirtyPayload;
9145
+ } catch (_) {// Syntax error if dirtyPayload is invalid xml
9146
+ }
9147
+ }
9148
+
9149
+ const body = doc.body || doc.documentElement;
9150
+
9151
+ if (dirty && leadingWhitespace) {
9152
+ body.insertBefore(document.createTextNode(leadingWhitespace), body.childNodes[0] || null);
9153
+ }
9154
+ /* Work on whole document or just its body */
9155
+
9156
+
9157
+ if (NAMESPACE === HTML_NAMESPACE) {
9158
+ return getElementsByTagName.call(doc, WHOLE_DOCUMENT ? 'html' : 'body')[0];
9159
+ }
9160
+
9161
+ return WHOLE_DOCUMENT ? doc.documentElement : body;
9162
+ };
9163
+ /**
9164
+ * _createIterator
9165
+ *
9166
+ * @param {Document} root document/fragment to create iterator for
9167
+ * @return {Iterator} iterator instance
9168
+ */
9169
+
9170
+
9171
+ const _createIterator = function _createIterator(root) {
9172
+ return createNodeIterator.call(root.ownerDocument || root, root, // eslint-disable-next-line no-bitwise
9173
+ NodeFilter.SHOW_ELEMENT | NodeFilter.SHOW_COMMENT | NodeFilter.SHOW_TEXT, null, false);
9174
+ };
9175
+ /**
9176
+ * _isClobbered
9177
+ *
9178
+ * @param {Node} elm element to check for clobbering attacks
9179
+ * @return {Boolean} true if clobbered, false if safe
9180
+ */
9181
+
9182
+
9183
+ const _isClobbered = function _isClobbered(elm) {
9184
+ 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');
9185
+ };
9186
+ /**
9187
+ * _isNode
9188
+ *
9189
+ * @param {Node} obj object to check whether it's a DOM node
9190
+ * @return {Boolean} true is object is a DOM node
9191
+ */
9192
+
9193
+
9194
+ const _isNode = function _isNode(object) {
9195
+ return typeof Node === 'object' ? object instanceof Node : object && typeof object === 'object' && typeof object.nodeType === 'number' && typeof object.nodeName === 'string';
9196
+ };
9197
+ /**
9198
+ * _executeHook
9199
+ * Execute user configurable hooks
9200
+ *
9201
+ * @param {String} entryPoint Name of the hook's entry point
9202
+ * @param {Node} currentNode node to work on with the hook
9203
+ * @param {Object} data additional hook parameters
9204
+ */
9205
+
9206
+
9207
+ const _executeHook = function _executeHook(entryPoint, currentNode, data) {
9208
+ if (!hooks[entryPoint]) {
9209
+ return;
9210
+ }
9211
+
9212
+ arrayForEach(hooks[entryPoint], hook => {
9213
+ hook.call(DOMPurify, currentNode, data, CONFIG);
9214
+ });
9215
+ };
9216
+ /**
9217
+ * _sanitizeElements
9218
+ *
9219
+ * @protect nodeName
9220
+ * @protect textContent
9221
+ * @protect removeChild
9222
+ *
9223
+ * @param {Node} currentNode to check for permission to exist
9224
+ * @return {Boolean} true if node was killed, false if left alive
9225
+ */
9226
+
9227
+
9228
+ const _sanitizeElements = function _sanitizeElements(currentNode) {
9229
+ let content;
9230
+ /* Execute a hook if present */
9231
+
9232
+ _executeHook('beforeSanitizeElements', currentNode, null);
9233
+ /* Check if element is clobbered or can clobber */
9234
+
9235
+
9236
+ if (_isClobbered(currentNode)) {
9237
+ _forceRemove(currentNode);
9238
+
9239
+ return true;
9240
+ }
9241
+ /* Now let's check the element's type and name */
9242
+
9243
+
9244
+ const tagName = transformCaseFunc(currentNode.nodeName);
9245
+ /* Execute a hook if present */
9246
+
9247
+ _executeHook('uponSanitizeElement', currentNode, {
9248
+ tagName,
9249
+ allowedTags: ALLOWED_TAGS
9250
+ });
9251
+ /* Detect mXSS attempts abusing namespace confusion */
9252
+
9253
+
9254
+ if (currentNode.hasChildNodes() && !_isNode(currentNode.firstElementChild) && (!_isNode(currentNode.content) || !_isNode(currentNode.content.firstElementChild)) && regExpTest(/<[/\w]/g, currentNode.innerHTML) && regExpTest(/<[/\w]/g, currentNode.textContent)) {
9255
+ _forceRemove(currentNode);
9256
+
9257
+ return true;
9258
+ }
9259
+ /* Remove element if anything forbids its presence */
9260
+
9261
+
9262
+ if (!ALLOWED_TAGS[tagName] || FORBID_TAGS[tagName]) {
9263
+ /* Check if we have a custom element to handle */
9264
+ if (!FORBID_TAGS[tagName] && _basicCustomElementTest(tagName)) {
9265
+ if (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof RegExp && regExpTest(CUSTOM_ELEMENT_HANDLING.tagNameCheck, tagName)) return false;
9266
+ if (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof Function && CUSTOM_ELEMENT_HANDLING.tagNameCheck(tagName)) return false;
9267
+ }
9268
+ /* Keep content except for bad-listed elements */
9269
+
9270
+
9271
+ if (KEEP_CONTENT && !FORBID_CONTENTS[tagName]) {
9272
+ const parentNode = getParentNode(currentNode) || currentNode.parentNode;
9273
+ const childNodes = getChildNodes(currentNode) || currentNode.childNodes;
9274
+
9275
+ if (childNodes && parentNode) {
9276
+ const childCount = childNodes.length;
9277
+
9278
+ for (let i = childCount - 1; i >= 0; --i) {
9279
+ parentNode.insertBefore(cloneNode(childNodes[i], true), getNextSibling(currentNode));
9280
+ }
9281
+ }
9282
+ }
9283
+
9284
+ _forceRemove(currentNode);
9285
+
9286
+ return true;
9287
+ }
9288
+ /* Check whether element has a valid namespace */
9289
+
9290
+
9291
+ if (currentNode instanceof Element && !_checkValidNamespace(currentNode)) {
9292
+ _forceRemove(currentNode);
9293
+
9294
+ return true;
9295
+ }
9296
+ /* Make sure that older browsers don't get fallback-tag mXSS */
9297
+
9298
+
9299
+ if ((tagName === 'noscript' || tagName === 'noembed' || tagName === 'noframes') && regExpTest(/<\/no(script|embed|frames)/i, currentNode.innerHTML)) {
9300
+ _forceRemove(currentNode);
9301
+
9302
+ return true;
9303
+ }
9304
+ /* Sanitize element content to be template-safe */
9305
+
9306
+
9307
+ if (SAFE_FOR_TEMPLATES && currentNode.nodeType === 3) {
9308
+ /* Get the element's text content */
9309
+ content = currentNode.textContent;
9310
+ content = stringReplace(content, MUSTACHE_EXPR, ' ');
9311
+ content = stringReplace(content, ERB_EXPR, ' ');
9312
+ content = stringReplace(content, TMPLIT_EXPR, ' ');
9313
+
9314
+ if (currentNode.textContent !== content) {
9315
+ arrayPush(DOMPurify.removed, {
9316
+ element: currentNode.cloneNode()
9317
+ });
9318
+ currentNode.textContent = content;
9319
+ }
9320
+ }
9321
+ /* Execute a hook if present */
9322
+
9323
+
9324
+ _executeHook('afterSanitizeElements', currentNode, null);
9325
+
9326
+ return false;
9327
+ };
9328
+ /**
9329
+ * _isValidAttribute
9330
+ *
9331
+ * @param {string} lcTag Lowercase tag name of containing element.
9332
+ * @param {string} lcName Lowercase attribute name.
9333
+ * @param {string} value Attribute value.
9334
+ * @return {Boolean} Returns true if `value` is valid, otherwise false.
9335
+ */
9336
+ // eslint-disable-next-line complexity
9337
+
9338
+
9339
+ const _isValidAttribute = function _isValidAttribute(lcTag, lcName, value) {
9340
+ /* Make sure attribute cannot clobber */
9341
+ if (SANITIZE_DOM && (lcName === 'id' || lcName === 'name') && (value in document || value in formElement)) {
9342
+ return false;
9343
+ }
9344
+ /* Allow valid data-* attributes: At least one character after "-"
9345
+ (https://html.spec.whatwg.org/multipage/dom.html#embedding-custom-non-visible-data-with-the-data-*-attributes)
9346
+ XML-compatible (https://html.spec.whatwg.org/multipage/infrastructure.html#xml-compatible and http://www.w3.org/TR/xml/#d0e804)
9347
+ We don't need to check the value; it's always URI safe. */
9348
+
9349
+
9350
+ 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]) {
9351
+ if ( // First condition does a very basic check if a) it's basically a valid custom element tagname AND
9352
+ // b) if the tagName passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.tagNameCheck
9353
+ // and c) if the attribute name passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.attributeNameCheck
9354
+ _basicCustomElementTest(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)) || // Alternative, second condition checks if it's an `is`-attribute, AND
9355
+ // the value passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.tagNameCheck
9356
+ 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 {
9357
+ return false;
9358
+ }
9359
+ /* Check value is safe. First, is attr inert? If so, is safe */
9360
+
9361
+ } 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) {
9362
+ return false;
9363
+ } else ;
9364
+
9365
+ return true;
9366
+ };
9367
+ /**
9368
+ * _basicCustomElementCheck
9369
+ * checks if at least one dash is included in tagName, and it's not the first char
9370
+ * for more sophisticated checking see https://github.com/sindresorhus/validate-element-name
9371
+ * @param {string} tagName name of the tag of the node to sanitize
9372
+ */
9373
+
9374
+
9375
+ const _basicCustomElementTest = function _basicCustomElementTest(tagName) {
9376
+ return tagName.indexOf('-') > 0;
9377
+ };
9378
+ /**
9379
+ * _sanitizeAttributes
9380
+ *
9381
+ * @protect attributes
9382
+ * @protect nodeName
9383
+ * @protect removeAttribute
9384
+ * @protect setAttribute
9385
+ *
9386
+ * @param {Node} currentNode to sanitize
9387
+ */
9388
+
9389
+
9390
+ const _sanitizeAttributes = function _sanitizeAttributes(currentNode) {
9391
+ let attr;
9392
+ let value;
9393
+ let lcName;
9394
+ let l;
9395
+ /* Execute a hook if present */
9396
+
9397
+ _executeHook('beforeSanitizeAttributes', currentNode, null);
9398
+
9399
+ const {
9400
+ attributes
9401
+ } = currentNode;
9402
+ /* Check if we have attributes; if not we might have a text node */
9403
+
9404
+ if (!attributes) {
9405
+ return;
9406
+ }
9407
+
9408
+ const hookEvent = {
9409
+ attrName: '',
9410
+ attrValue: '',
9411
+ keepAttr: true,
9412
+ allowedAttributes: ALLOWED_ATTR
9413
+ };
9414
+ l = attributes.length;
9415
+ /* Go backwards over all attributes; safely remove bad ones */
9416
+
9417
+ while (l--) {
9418
+ attr = attributes[l];
9419
+ const {
9420
+ name,
9421
+ namespaceURI
9422
+ } = attr;
9423
+ value = name === 'value' ? attr.value : stringTrim(attr.value);
9424
+ lcName = transformCaseFunc(name);
9425
+ /* Execute a hook if present */
9426
+
9427
+ hookEvent.attrName = lcName;
9428
+ hookEvent.attrValue = value;
9429
+ hookEvent.keepAttr = true;
9430
+ hookEvent.forceKeepAttr = undefined; // Allows developers to see this is a property they can set
9431
+
9432
+ _executeHook('uponSanitizeAttribute', currentNode, hookEvent);
9433
+
9434
+ value = hookEvent.attrValue;
9435
+ /* Did the hooks approve of the attribute? */
9436
+
9437
+ if (hookEvent.forceKeepAttr) {
9438
+ continue;
9439
+ }
9440
+ /* Remove attribute */
9441
+
9442
+
9443
+ _removeAttribute(name, currentNode);
9444
+ /* Did the hooks approve of the attribute? */
9445
+
9446
+
9447
+ if (!hookEvent.keepAttr) {
9448
+ continue;
9449
+ }
9450
+ /* Work around a security issue in jQuery 3.0 */
9451
+
9452
+
9453
+ if (!ALLOW_SELF_CLOSE_IN_ATTR && regExpTest(/\/>/i, value)) {
9454
+ _removeAttribute(name, currentNode);
9455
+
9456
+ continue;
9457
+ }
9458
+ /* Sanitize attribute content to be template-safe */
9459
+
9460
+
9461
+ if (SAFE_FOR_TEMPLATES) {
9462
+ value = stringReplace(value, MUSTACHE_EXPR, ' ');
9463
+ value = stringReplace(value, ERB_EXPR, ' ');
9464
+ value = stringReplace(value, TMPLIT_EXPR, ' ');
9465
+ }
9466
+ /* Is `value` valid for this attribute? */
9467
+
9468
+
9469
+ const lcTag = transformCaseFunc(currentNode.nodeName);
9470
+
9471
+ if (!_isValidAttribute(lcTag, lcName, value)) {
9472
+ continue;
9473
+ }
9474
+ /* Full DOM Clobbering protection via namespace isolation,
9475
+ * Prefix id and name attributes with `user-content-`
9476
+ */
9477
+
9478
+
9479
+ if (SANITIZE_NAMED_PROPS && (lcName === 'id' || lcName === 'name')) {
9480
+ // Remove the attribute with this value
9481
+ _removeAttribute(name, currentNode); // Prefix the value and later re-create the attribute with the sanitized value
9482
+
9483
+
9484
+ value = SANITIZE_NAMED_PROPS_PREFIX + value;
9485
+ }
9486
+ /* Handle attributes that require Trusted Types */
9487
+
9488
+
9489
+ if (trustedTypesPolicy && typeof trustedTypes === 'object' && typeof trustedTypes.getAttributeType === 'function') {
9490
+ if (namespaceURI) ; else {
9491
+ switch (trustedTypes.getAttributeType(lcTag, lcName)) {
9492
+ case 'TrustedHTML':
9493
+ {
9494
+ value = trustedTypesPolicy.createHTML(value);
9495
+ break;
9496
+ }
9497
+
9498
+ case 'TrustedScriptURL':
9499
+ {
9500
+ value = trustedTypesPolicy.createScriptURL(value);
9501
+ break;
9502
+ }
9503
+ }
9504
+ }
9505
+ }
9506
+ /* Handle invalid data-* attribute set by try-catching it */
9507
+
9508
+
9509
+ try {
9510
+ if (namespaceURI) {
9511
+ currentNode.setAttributeNS(namespaceURI, name, value);
9512
+ } else {
9513
+ /* Fallback to setAttribute() for browser-unrecognized namespaces e.g. "x-schema". */
9514
+ currentNode.setAttribute(name, value);
9515
+ }
9516
+
9517
+ arrayPop(DOMPurify.removed);
9518
+ } catch (_) {}
9519
+ }
9520
+ /* Execute a hook if present */
9521
+
9522
+
9523
+ _executeHook('afterSanitizeAttributes', currentNode, null);
9524
+ };
9525
+ /**
9526
+ * _sanitizeShadowDOM
9527
+ *
9528
+ * @param {DocumentFragment} fragment to iterate over recursively
9529
+ */
9530
+
9531
+
9532
+ const _sanitizeShadowDOM = function _sanitizeShadowDOM(fragment) {
9533
+ let shadowNode;
9534
+
9535
+ const shadowIterator = _createIterator(fragment);
9536
+ /* Execute a hook if present */
9537
+
9538
+
9539
+ _executeHook('beforeSanitizeShadowDOM', fragment, null);
9540
+
9541
+ while (shadowNode = shadowIterator.nextNode()) {
9542
+ /* Execute a hook if present */
9543
+ _executeHook('uponSanitizeShadowNode', shadowNode, null);
9544
+ /* Sanitize tags and elements */
9545
+
9546
+
9547
+ if (_sanitizeElements(shadowNode)) {
9548
+ continue;
9549
+ }
9550
+ /* Deep shadow DOM detected */
9551
+
9552
+
9553
+ if (shadowNode.content instanceof DocumentFragment) {
9554
+ _sanitizeShadowDOM(shadowNode.content);
9555
+ }
9556
+ /* Check attributes, sanitize if necessary */
9557
+
9558
+
9559
+ _sanitizeAttributes(shadowNode);
9560
+ }
9561
+ /* Execute a hook if present */
9562
+
9563
+
9564
+ _executeHook('afterSanitizeShadowDOM', fragment, null);
9565
+ };
9566
+ /**
9567
+ * Sanitize
9568
+ * Public method providing core sanitation functionality
9569
+ *
9570
+ * @param {String|Node} dirty string or DOM node
9571
+ * @param {Object} configuration object
9572
+ */
9573
+ // eslint-disable-next-line complexity
9574
+
9575
+
9576
+ DOMPurify.sanitize = function (dirty) {
9577
+ let cfg = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
9578
+ let body;
9579
+ let importedNode;
9580
+ let currentNode;
9581
+ let returnNode;
9582
+ /* Make sure we have a string to sanitize.
9583
+ DO NOT return early, as this will return the wrong type if
9584
+ the user has requested a DOM object rather than a string */
9585
+
9586
+ IS_EMPTY_INPUT = !dirty;
9587
+
9588
+ if (IS_EMPTY_INPUT) {
9589
+ dirty = '<!-->';
9590
+ }
9591
+ /* Stringify, in case dirty is an object */
9592
+
9593
+
9594
+ if (typeof dirty !== 'string' && !_isNode(dirty)) {
9595
+ if (typeof dirty.toString === 'function') {
9596
+ dirty = dirty.toString();
9597
+
9598
+ if (typeof dirty !== 'string') {
9599
+ throw typeErrorCreate('dirty is not a string, aborting');
9600
+ }
9601
+ } else {
9602
+ throw typeErrorCreate('toString is not a function');
9603
+ }
9604
+ }
9605
+ /* Return dirty HTML if DOMPurify cannot run */
9606
+
9607
+
9608
+ if (!DOMPurify.isSupported) {
9609
+ return dirty;
9610
+ }
9611
+ /* Assign config vars */
9612
+
9613
+
9614
+ if (!SET_CONFIG) {
9615
+ _parseConfig(cfg);
9616
+ }
9617
+ /* Clean up removed elements */
9618
+
9619
+
9620
+ DOMPurify.removed = [];
9621
+ /* Check if dirty is correctly typed for IN_PLACE */
9622
+
9623
+ if (typeof dirty === 'string') {
9624
+ IN_PLACE = false;
9625
+ }
9626
+
9627
+ if (IN_PLACE) {
9628
+ /* Do some early pre-sanitization to avoid unsafe root nodes */
9629
+ if (dirty.nodeName) {
9630
+ const tagName = transformCaseFunc(dirty.nodeName);
9631
+
9632
+ if (!ALLOWED_TAGS[tagName] || FORBID_TAGS[tagName]) {
9633
+ throw typeErrorCreate('root node is forbidden and cannot be sanitized in-place');
9634
+ }
9635
+ }
9636
+ } else if (dirty instanceof Node) {
9637
+ /* If dirty is a DOM element, append to an empty document to avoid
9638
+ elements being stripped by the parser */
9639
+ body = _initDocument('<!---->');
9640
+ importedNode = body.ownerDocument.importNode(dirty, true);
9641
+
9642
+ if (importedNode.nodeType === 1 && importedNode.nodeName === 'BODY') {
9643
+ /* Node is already a body, use as is */
9644
+ body = importedNode;
9645
+ } else if (importedNode.nodeName === 'HTML') {
9646
+ body = importedNode;
9647
+ } else {
9648
+ // eslint-disable-next-line unicorn/prefer-dom-node-append
9649
+ body.appendChild(importedNode);
9650
+ }
9651
+ } else {
9652
+ /* Exit directly if we have nothing to do */
9653
+ if (!RETURN_DOM && !SAFE_FOR_TEMPLATES && !WHOLE_DOCUMENT && // eslint-disable-next-line unicorn/prefer-includes
9654
+ dirty.indexOf('<') === -1) {
9655
+ return trustedTypesPolicy && RETURN_TRUSTED_TYPE ? trustedTypesPolicy.createHTML(dirty) : dirty;
9656
+ }
9657
+ /* Initialize the document to work on */
9658
+
9659
+
9660
+ body = _initDocument(dirty);
9661
+ /* Check we have a DOM node from the data */
9662
+
9663
+ if (!body) {
9664
+ return RETURN_DOM ? null : RETURN_TRUSTED_TYPE ? emptyHTML : '';
9665
+ }
9666
+ }
9667
+ /* Remove first element node (ours) if FORCE_BODY is set */
9668
+
9669
+
9670
+ if (body && FORCE_BODY) {
9671
+ _forceRemove(body.firstChild);
9672
+ }
9673
+ /* Get node iterator */
9674
+
9675
+
9676
+ const nodeIterator = _createIterator(IN_PLACE ? dirty : body);
9677
+ /* Now start iterating over the created document */
9678
+
9679
+
9680
+ while (currentNode = nodeIterator.nextNode()) {
9681
+ /* Sanitize tags and elements */
9682
+ if (_sanitizeElements(currentNode)) {
9683
+ continue;
9684
+ }
9685
+ /* Shadow DOM detected, sanitize it */
9686
+
9687
+
9688
+ if (currentNode.content instanceof DocumentFragment) {
9689
+ _sanitizeShadowDOM(currentNode.content);
9690
+ }
9691
+ /* Check attributes, sanitize if necessary */
9692
+
9693
+
9694
+ _sanitizeAttributes(currentNode);
9695
+ }
9696
+ /* If we sanitized `dirty` in-place, return it. */
9697
+
9698
+
9699
+ if (IN_PLACE) {
9700
+ return dirty;
9701
+ }
9702
+ /* Return sanitized string or DOM */
9703
+
9704
+
9705
+ if (RETURN_DOM) {
9706
+ if (RETURN_DOM_FRAGMENT) {
9707
+ returnNode = createDocumentFragment.call(body.ownerDocument);
9708
+
9709
+ while (body.firstChild) {
9710
+ // eslint-disable-next-line unicorn/prefer-dom-node-append
9711
+ returnNode.appendChild(body.firstChild);
9712
+ }
9713
+ } else {
9714
+ returnNode = body;
9715
+ }
9716
+
9717
+ if (ALLOWED_ATTR.shadowroot || ALLOWED_ATTR.shadowrootmode) {
9718
+ /*
9719
+ AdoptNode() is not used because internal state is not reset
9720
+ (e.g. the past names map of a HTMLFormElement), this is safe
9721
+ in theory but we would rather not risk another attack vector.
9722
+ The state that is cloned by importNode() is explicitly defined
9723
+ by the specs.
9724
+ */
9725
+ returnNode = importNode.call(originalDocument, returnNode, true);
9726
+ }
9727
+
9728
+ return returnNode;
9729
+ }
9730
+
9731
+ let serializedHTML = WHOLE_DOCUMENT ? body.outerHTML : body.innerHTML;
9732
+ /* Serialize doctype if allowed */
9733
+
9734
+ if (WHOLE_DOCUMENT && ALLOWED_TAGS['!doctype'] && body.ownerDocument && body.ownerDocument.doctype && body.ownerDocument.doctype.name && regExpTest(DOCTYPE_NAME, body.ownerDocument.doctype.name)) {
9735
+ serializedHTML = '<!DOCTYPE ' + body.ownerDocument.doctype.name + '>\n' + serializedHTML;
9736
+ }
9737
+ /* Sanitize final string template-safe */
9738
+
9739
+
9740
+ if (SAFE_FOR_TEMPLATES) {
9741
+ serializedHTML = stringReplace(serializedHTML, MUSTACHE_EXPR, ' ');
9742
+ serializedHTML = stringReplace(serializedHTML, ERB_EXPR, ' ');
9743
+ serializedHTML = stringReplace(serializedHTML, TMPLIT_EXPR, ' ');
9744
+ }
9745
+
9746
+ return trustedTypesPolicy && RETURN_TRUSTED_TYPE ? trustedTypesPolicy.createHTML(serializedHTML) : serializedHTML;
9747
+ };
9748
+ /**
9749
+ * Public method to set the configuration once
9750
+ * setConfig
9751
+ *
9752
+ * @param {Object} cfg configuration object
9753
+ */
9754
+
9755
+
9756
+ DOMPurify.setConfig = function (cfg) {
9757
+ _parseConfig(cfg);
9758
+
9759
+ SET_CONFIG = true;
9760
+ };
9761
+ /**
9762
+ * Public method to remove the configuration
9763
+ * clearConfig
9764
+ *
9765
+ */
9766
+
9767
+
9768
+ DOMPurify.clearConfig = function () {
9769
+ CONFIG = null;
9770
+ SET_CONFIG = false;
9771
+ };
9772
+ /**
9773
+ * Public method to check if an attribute value is valid.
9774
+ * Uses last set config, if any. Otherwise, uses config defaults.
9775
+ * isValidAttribute
9776
+ *
9777
+ * @param {string} tag Tag name of containing element.
9778
+ * @param {string} attr Attribute name.
9779
+ * @param {string} value Attribute value.
9780
+ * @return {Boolean} Returns true if `value` is valid. Otherwise, returns false.
9781
+ */
9782
+
9783
+
9784
+ DOMPurify.isValidAttribute = function (tag, attr, value) {
9785
+ /* Initialize shared config vars if necessary. */
9786
+ if (!CONFIG) {
9787
+ _parseConfig({});
9788
+ }
9789
+
9790
+ const lcTag = transformCaseFunc(tag);
9791
+ const lcName = transformCaseFunc(attr);
9792
+ return _isValidAttribute(lcTag, lcName, value);
9793
+ };
9794
+ /**
9795
+ * AddHook
9796
+ * Public method to add DOMPurify hooks
9797
+ *
9798
+ * @param {String} entryPoint entry point for the hook to add
9799
+ * @param {Function} hookFunction function to execute
9800
+ */
9801
+
9802
+
9803
+ DOMPurify.addHook = function (entryPoint, hookFunction) {
9804
+ if (typeof hookFunction !== 'function') {
9805
+ return;
9806
+ }
9807
+
9808
+ hooks[entryPoint] = hooks[entryPoint] || [];
9809
+ arrayPush(hooks[entryPoint], hookFunction);
9810
+ };
9811
+ /**
9812
+ * RemoveHook
9813
+ * Public method to remove a DOMPurify hook at a given entryPoint
9814
+ * (pops it from the stack of hooks if more are present)
9815
+ *
9816
+ * @param {String} entryPoint entry point for the hook to remove
9817
+ * @return {Function} removed(popped) hook
9818
+ */
9819
+
9820
+
9821
+ DOMPurify.removeHook = function (entryPoint) {
9822
+ if (hooks[entryPoint]) {
9823
+ return arrayPop(hooks[entryPoint]);
9824
+ }
9825
+ };
9826
+ /**
9827
+ * RemoveHooks
9828
+ * Public method to remove all DOMPurify hooks at a given entryPoint
9829
+ *
9830
+ * @param {String} entryPoint entry point for the hooks to remove
9831
+ */
9832
+
9833
+
9834
+ DOMPurify.removeHooks = function (entryPoint) {
9835
+ if (hooks[entryPoint]) {
9836
+ hooks[entryPoint] = [];
9837
+ }
9838
+ };
9839
+ /**
9840
+ * RemoveAllHooks
9841
+ * Public method to remove all DOMPurify hooks
9842
+ *
9843
+ */
9844
+
9845
+
9846
+ DOMPurify.removeAllHooks = function () {
9847
+ hooks = {};
9848
+ };
9849
+
9850
+ return DOMPurify;
9851
+ }
9852
+
9853
+ var purify = createDOMPurify();
9854
+
8232
9855
  function createCheckbox$1(name, initialState) {
8233
9856
  const container = div({class: 'igv-ui-trackgear-popover-check-container'});
8234
9857
  const svg = iconMarkup('check', (true === initialState ? '#444' : 'transparent'));
@@ -8480,7 +10103,9 @@ class AlertDialog {
8480
10103
  string = httpMessages[string];
8481
10104
  }
8482
10105
 
8483
- this.body.innerHTML = string;
10106
+ const clean = purify.sanitize(string);
10107
+
10108
+ this.body.innerHTML = clean;
8484
10109
  this.callback = callback;
8485
10110
  show(this.container);
8486
10111
  if (this.alertProps.shouldFocus) {
@@ -8569,6 +10194,10 @@ class InputDialog {
8569
10194
 
8570
10195
  }
8571
10196
 
10197
+ get value() {
10198
+ return purify.sanitize(this.input.value)
10199
+ }
10200
+
8572
10201
  present(options, e) {
8573
10202
 
8574
10203
  this.label.textContent = options.label;
@@ -8582,14 +10211,14 @@ class InputDialog {
8582
10211
 
8583
10212
  clampLocation(clientX, clientY) {
8584
10213
 
8585
- const { width:w, height:h } = this.container.getBoundingClientRect();
10214
+ const {width: w, height: h} = this.container.getBoundingClientRect();
8586
10215
  const wh = window.innerHeight;
8587
10216
  const ww = window.innerWidth;
8588
10217
 
8589
10218
  const y = Math.min(wh - h, clientY);
8590
10219
  const x = Math.min(ww - w, clientX);
8591
- this.container.style.left = `${ x }px`;
8592
- this.container.style.top = `${ y }px`;
10220
+ this.container.style.left = `${x}px`;
10221
+ this.container.style.top = `${y}px`;
8593
10222
 
8594
10223
  }
8595
10224
  }
@@ -9044,10 +10673,7 @@ function embedCSS$2() {
9044
10673
  background-color: white;
9045
10674
  }
9046
10675
  .igv-ui-popover > div:last-child > div {
9047
- -webkit-user-select: text;
9048
- -moz-user-select: text;
9049
- -ms-user-select: text;
9050
- user-select: text;
10676
+ user-select: all;
9051
10677
  margin-left: 4px;
9052
10678
  margin-right: 4px;
9053
10679
  min-width: 220px;
@@ -9818,7 +11444,7 @@ function visibilityWindowMenuItem(trackView) {
9818
11444
 
9819
11445
  const callback = () => {
9820
11446
 
9821
- let value = trackView.browser.inputDialog.input.value;
11447
+ let value = trackView.browser.inputDialog.value;
9822
11448
  value = '' === value || undefined === value ? -1 : value.trim();
9823
11449
 
9824
11450
  trackView.track.visibilityWindow = Number.parseInt(value);
@@ -9896,7 +11522,7 @@ function trackRenameMenuItem(trackView) {
9896
11522
  const click = e => {
9897
11523
 
9898
11524
  const callback = function () {
9899
- let value = trackView.browser.inputDialog.input.value;
11525
+ let value = trackView.browser.inputDialog.value;
9900
11526
  value = ('' === value || undefined === value) ? 'untitled' : value.trim();
9901
11527
  trackView.track.name = value;
9902
11528
  };
@@ -9925,7 +11551,7 @@ function trackHeightMenuItem(trackView) {
9925
11551
 
9926
11552
  const callback = () => {
9927
11553
 
9928
- const number = Number(trackView.browser.inputDialog.input.value, 10);
11554
+ const number = Number(trackView.browser.inputDialog.value, 10);
9929
11555
 
9930
11556
  if (undefined !== number) {
9931
11557
 
@@ -23990,7 +25616,7 @@ const Cytoband = function (start, end, name, typestain) {
23990
25616
  }
23991
25617
  };
23992
25618
 
23993
- const _version = "2.15.10";
25619
+ const _version = "2.15.11";
23994
25620
  function version() {
23995
25621
  return _version
23996
25622
  }
@@ -59570,7 +61196,7 @@ class ROIMenu {
59570
61196
 
59571
61197
  const callback = () => {
59572
61198
 
59573
- const value = this.browser.inputDialog.input.value || '';
61199
+ const value = this.browser.inputDialog.value || '';
59574
61200
  feature.name = value.trim();
59575
61201
 
59576
61202
  this.container.style.display = 'none';