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