@descope/flow-components 2.0.444 → 2.0.446
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/index.cjs.js +149 -409
- package/package.json +2 -2
package/dist/index.cjs.js
CHANGED
|
@@ -4396,7 +4396,7 @@ function requireColor () {
|
|
|
4396
4396
|
return color;
|
|
4397
4397
|
}
|
|
4398
4398
|
|
|
4399
|
-
/*! @license DOMPurify 3.
|
|
4399
|
+
/*! @license DOMPurify 3.2.4 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.2.4/LICENSE */
|
|
4400
4400
|
|
|
4401
4401
|
var purify_cjs;
|
|
4402
4402
|
var hasRequiredPurify_cjs;
|
|
@@ -4442,8 +4442,10 @@ function requirePurify_cjs () {
|
|
|
4442
4442
|
};
|
|
4443
4443
|
}
|
|
4444
4444
|
const arrayForEach = unapply(Array.prototype.forEach);
|
|
4445
|
+
const arrayLastIndexOf = unapply(Array.prototype.lastIndexOf);
|
|
4445
4446
|
const arrayPop = unapply(Array.prototype.pop);
|
|
4446
4447
|
const arrayPush = unapply(Array.prototype.push);
|
|
4448
|
+
const arraySplice = unapply(Array.prototype.splice);
|
|
4447
4449
|
const stringToLowerCase = unapply(String.prototype.toLowerCase);
|
|
4448
4450
|
const stringToString = unapply(String.prototype.toString);
|
|
4449
4451
|
const stringMatch = unapply(String.prototype.match);
|
|
@@ -4453,12 +4455,11 @@ function requirePurify_cjs () {
|
|
|
4453
4455
|
const objectHasOwnProperty = unapply(Object.prototype.hasOwnProperty);
|
|
4454
4456
|
const regExpTest = unapply(RegExp.prototype.test);
|
|
4455
4457
|
const typeErrorCreate = unconstruct(TypeError);
|
|
4456
|
-
|
|
4457
4458
|
/**
|
|
4458
4459
|
* Creates a new function that calls the given function with a specified thisArg and arguments.
|
|
4459
4460
|
*
|
|
4460
|
-
* @param
|
|
4461
|
-
* @returns
|
|
4461
|
+
* @param func - The function to be wrapped and called.
|
|
4462
|
+
* @returns A new function that calls the given function with a specified thisArg and arguments.
|
|
4462
4463
|
*/
|
|
4463
4464
|
function unapply(func) {
|
|
4464
4465
|
return function (thisArg) {
|
|
@@ -4468,12 +4469,11 @@ function requirePurify_cjs () {
|
|
|
4468
4469
|
return apply(func, thisArg, args);
|
|
4469
4470
|
};
|
|
4470
4471
|
}
|
|
4471
|
-
|
|
4472
4472
|
/**
|
|
4473
4473
|
* Creates a new function that constructs an instance of the given constructor function with the provided arguments.
|
|
4474
4474
|
*
|
|
4475
|
-
* @param
|
|
4476
|
-
* @returns
|
|
4475
|
+
* @param func - The constructor function to be wrapped and called.
|
|
4476
|
+
* @returns A new function that constructs an instance of the given constructor function with the provided arguments.
|
|
4477
4477
|
*/
|
|
4478
4478
|
function unconstruct(func) {
|
|
4479
4479
|
return function () {
|
|
@@ -4483,14 +4483,13 @@ function requirePurify_cjs () {
|
|
|
4483
4483
|
return construct(func, args);
|
|
4484
4484
|
};
|
|
4485
4485
|
}
|
|
4486
|
-
|
|
4487
4486
|
/**
|
|
4488
4487
|
* Add properties to a lookup table
|
|
4489
4488
|
*
|
|
4490
|
-
* @param
|
|
4491
|
-
* @param
|
|
4492
|
-
* @param
|
|
4493
|
-
* @returns
|
|
4489
|
+
* @param set - The set to which elements will be added.
|
|
4490
|
+
* @param array - The array containing elements to be added to the set.
|
|
4491
|
+
* @param transformCaseFunc - An optional function to transform the case of each element before adding to the set.
|
|
4492
|
+
* @returns The modified set with added elements.
|
|
4494
4493
|
*/
|
|
4495
4494
|
function addToSet(set, array) {
|
|
4496
4495
|
let transformCaseFunc = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : stringToLowerCase;
|
|
@@ -4517,12 +4516,11 @@ function requirePurify_cjs () {
|
|
|
4517
4516
|
}
|
|
4518
4517
|
return set;
|
|
4519
4518
|
}
|
|
4520
|
-
|
|
4521
4519
|
/**
|
|
4522
4520
|
* Clean up an array to harden against CSPP
|
|
4523
4521
|
*
|
|
4524
|
-
* @param
|
|
4525
|
-
* @returns
|
|
4522
|
+
* @param array - The array to be cleaned.
|
|
4523
|
+
* @returns The cleaned version of the array
|
|
4526
4524
|
*/
|
|
4527
4525
|
function cleanArray(array) {
|
|
4528
4526
|
for (let index = 0; index < array.length; index++) {
|
|
@@ -4533,12 +4531,11 @@ function requirePurify_cjs () {
|
|
|
4533
4531
|
}
|
|
4534
4532
|
return array;
|
|
4535
4533
|
}
|
|
4536
|
-
|
|
4537
4534
|
/**
|
|
4538
4535
|
* Shallow clone an object
|
|
4539
4536
|
*
|
|
4540
|
-
* @param
|
|
4541
|
-
* @returns
|
|
4537
|
+
* @param object - The object to be cloned.
|
|
4538
|
+
* @returns A new object that copies the original.
|
|
4542
4539
|
*/
|
|
4543
4540
|
function clone(object) {
|
|
4544
4541
|
const newObject = create(null);
|
|
@@ -4556,13 +4553,12 @@ function requirePurify_cjs () {
|
|
|
4556
4553
|
}
|
|
4557
4554
|
return newObject;
|
|
4558
4555
|
}
|
|
4559
|
-
|
|
4560
4556
|
/**
|
|
4561
4557
|
* This method automatically checks if the prop is function or getter and behaves accordingly.
|
|
4562
4558
|
*
|
|
4563
|
-
* @param
|
|
4564
|
-
* @param
|
|
4565
|
-
* @returns
|
|
4559
|
+
* @param object - The object to look up the getter function in its prototype chain.
|
|
4560
|
+
* @param prop - The property name for which to find the getter function.
|
|
4561
|
+
* @returns The getter function found in the prototype chain or a fallback function.
|
|
4566
4562
|
*/
|
|
4567
4563
|
function lookupGetter(object, prop) {
|
|
4568
4564
|
while (object !== null) {
|
|
@@ -4584,18 +4580,14 @@ function requirePurify_cjs () {
|
|
|
4584
4580
|
}
|
|
4585
4581
|
|
|
4586
4582
|
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']);
|
|
4587
|
-
|
|
4588
|
-
// SVG
|
|
4589
4583
|
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']);
|
|
4590
4584
|
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']);
|
|
4591
|
-
|
|
4592
4585
|
// List of SVG elements that are disallowed by default.
|
|
4593
4586
|
// We still need to know them so that we can do namespace
|
|
4594
4587
|
// checks properly in case one wants to add them to
|
|
4595
4588
|
// allow-list.
|
|
4596
4589
|
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']);
|
|
4597
4590
|
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']);
|
|
4598
|
-
|
|
4599
4591
|
// Similarly to SVG, we want to know all MathML elements,
|
|
4600
4592
|
// even those that we disallow by default.
|
|
4601
4593
|
const mathMlDisallowed = freeze(['maction', 'maligngroup', 'malignmark', 'mlongdiv', 'mscarries', 'mscarry', 'msgroup', 'mstack', 'msline', 'msrow', 'semantics', 'annotation', 'annotation-xml', 'mprescripts', 'none']);
|
|
@@ -4609,8 +4601,8 @@ function requirePurify_cjs () {
|
|
|
4609
4601
|
// eslint-disable-next-line unicorn/better-regex
|
|
4610
4602
|
const MUSTACHE_EXPR = seal(/\{\{[\w\W]*|[\w\W]*\}\}/gm); // Specify template detection regex for SAFE_FOR_TEMPLATES mode
|
|
4611
4603
|
const ERB_EXPR = seal(/<%[\w\W]*|[\w\W]*%>/gm);
|
|
4612
|
-
const TMPLIT_EXPR = seal(
|
|
4613
|
-
const DATA_ATTR = seal(/^data-[\-\w.\u00B7-\uFFFF]
|
|
4604
|
+
const TMPLIT_EXPR = seal(/\$\{[\w\W]*/gm); // eslint-disable-line unicorn/better-regex
|
|
4605
|
+
const DATA_ATTR = seal(/^data-[\-\w.\u00B7-\uFFFF]+$/); // eslint-disable-line no-useless-escape
|
|
4614
4606
|
const ARIA_ATTR = seal(/^aria-[\-\w]+$/); // eslint-disable-line no-useless-escape
|
|
4615
4607
|
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
|
|
4616
4608
|
);
|
|
@@ -4622,18 +4614,19 @@ function requirePurify_cjs () {
|
|
|
4622
4614
|
|
|
4623
4615
|
var EXPRESSIONS = /*#__PURE__*/Object.freeze({
|
|
4624
4616
|
__proto__: null,
|
|
4625
|
-
MUSTACHE_EXPR: MUSTACHE_EXPR,
|
|
4626
|
-
ERB_EXPR: ERB_EXPR,
|
|
4627
|
-
TMPLIT_EXPR: TMPLIT_EXPR,
|
|
4628
|
-
DATA_ATTR: DATA_ATTR,
|
|
4629
4617
|
ARIA_ATTR: ARIA_ATTR,
|
|
4630
|
-
IS_ALLOWED_URI: IS_ALLOWED_URI,
|
|
4631
|
-
IS_SCRIPT_OR_DATA: IS_SCRIPT_OR_DATA,
|
|
4632
4618
|
ATTR_WHITESPACE: ATTR_WHITESPACE,
|
|
4619
|
+
CUSTOM_ELEMENT: CUSTOM_ELEMENT,
|
|
4620
|
+
DATA_ATTR: DATA_ATTR,
|
|
4633
4621
|
DOCTYPE_NAME: DOCTYPE_NAME,
|
|
4634
|
-
|
|
4622
|
+
ERB_EXPR: ERB_EXPR,
|
|
4623
|
+
IS_ALLOWED_URI: IS_ALLOWED_URI,
|
|
4624
|
+
IS_SCRIPT_OR_DATA: IS_SCRIPT_OR_DATA,
|
|
4625
|
+
MUSTACHE_EXPR: MUSTACHE_EXPR,
|
|
4626
|
+
TMPLIT_EXPR: TMPLIT_EXPR
|
|
4635
4627
|
});
|
|
4636
4628
|
|
|
4629
|
+
/* eslint-disable @typescript-eslint/indent */
|
|
4637
4630
|
// https://developer.mozilla.org/en-US/docs/Web/API/Node/nodeType
|
|
4638
4631
|
const NODE_TYPE = {
|
|
4639
4632
|
element: 1,
|
|
@@ -4654,20 +4647,18 @@ function requirePurify_cjs () {
|
|
|
4654
4647
|
const getGlobal = function getGlobal() {
|
|
4655
4648
|
return typeof window === 'undefined' ? null : window;
|
|
4656
4649
|
};
|
|
4657
|
-
|
|
4658
4650
|
/**
|
|
4659
4651
|
* Creates a no-op policy for internal use only.
|
|
4660
4652
|
* Don't export this function outside this module!
|
|
4661
|
-
* @param
|
|
4662
|
-
* @param
|
|
4663
|
-
* @return
|
|
4653
|
+
* @param trustedTypes The policy factory.
|
|
4654
|
+
* @param purifyHostElement The Script element used to load DOMPurify (to determine policy name suffix).
|
|
4655
|
+
* @return The policy created (or null, if Trusted Types
|
|
4664
4656
|
* are not supported or creating the policy failed).
|
|
4665
4657
|
*/
|
|
4666
4658
|
const _createTrustedTypesPolicy = function _createTrustedTypesPolicy(trustedTypes, purifyHostElement) {
|
|
4667
4659
|
if (typeof trustedTypes !== 'object' || typeof trustedTypes.createPolicy !== 'function') {
|
|
4668
4660
|
return null;
|
|
4669
4661
|
}
|
|
4670
|
-
|
|
4671
4662
|
// Allow the callers to control the unique policy name
|
|
4672
4663
|
// by adding a data-tt-policy-suffix to the script element with the DOMPurify.
|
|
4673
4664
|
// Policy creation with duplicate names throws in Trusted Types.
|
|
@@ -4694,22 +4685,25 @@ function requirePurify_cjs () {
|
|
|
4694
4685
|
return null;
|
|
4695
4686
|
}
|
|
4696
4687
|
};
|
|
4688
|
+
const _createHooksMap = function _createHooksMap() {
|
|
4689
|
+
return {
|
|
4690
|
+
afterSanitizeAttributes: [],
|
|
4691
|
+
afterSanitizeElements: [],
|
|
4692
|
+
afterSanitizeShadowDOM: [],
|
|
4693
|
+
beforeSanitizeAttributes: [],
|
|
4694
|
+
beforeSanitizeElements: [],
|
|
4695
|
+
beforeSanitizeShadowDOM: [],
|
|
4696
|
+
uponSanitizeAttribute: [],
|
|
4697
|
+
uponSanitizeElement: [],
|
|
4698
|
+
uponSanitizeShadowNode: []
|
|
4699
|
+
};
|
|
4700
|
+
};
|
|
4697
4701
|
function createDOMPurify() {
|
|
4698
4702
|
let window = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : getGlobal();
|
|
4699
4703
|
const DOMPurify = root => createDOMPurify(root);
|
|
4700
|
-
|
|
4701
|
-
/**
|
|
4702
|
-
* Version label, exposed for easier checks
|
|
4703
|
-
* if DOMPurify is up to date or not
|
|
4704
|
-
*/
|
|
4705
|
-
DOMPurify.version = '3.1.7';
|
|
4706
|
-
|
|
4707
|
-
/**
|
|
4708
|
-
* Array of elements that DOMPurify removed during sanitation.
|
|
4709
|
-
* Empty if nothing was removed.
|
|
4710
|
-
*/
|
|
4704
|
+
DOMPurify.version = '3.2.4';
|
|
4711
4705
|
DOMPurify.removed = [];
|
|
4712
|
-
if (!window || !window.document || window.document.nodeType !== NODE_TYPE.document) {
|
|
4706
|
+
if (!window || !window.document || window.document.nodeType !== NODE_TYPE.document || !window.Element) {
|
|
4713
4707
|
// Not running in a browser, provide a factory function
|
|
4714
4708
|
// so that you can pass your own Window
|
|
4715
4709
|
DOMPurify.isSupported = false;
|
|
@@ -4737,7 +4731,6 @@ function requirePurify_cjs () {
|
|
|
4737
4731
|
const getNextSibling = lookupGetter(ElementPrototype, 'nextSibling');
|
|
4738
4732
|
const getChildNodes = lookupGetter(ElementPrototype, 'childNodes');
|
|
4739
4733
|
const getParentNode = lookupGetter(ElementPrototype, 'parentNode');
|
|
4740
|
-
|
|
4741
4734
|
// As per issue #47, the web-components registry is inherited by a
|
|
4742
4735
|
// new document created via createHTMLDocument. As per the spec
|
|
4743
4736
|
// (http://w3c.github.io/webcomponents/spec/custom/#creating-and-passing-registries)
|
|
@@ -4761,8 +4754,7 @@ function requirePurify_cjs () {
|
|
|
4761
4754
|
const {
|
|
4762
4755
|
importNode
|
|
4763
4756
|
} = originalDocument;
|
|
4764
|
-
let hooks =
|
|
4765
|
-
|
|
4757
|
+
let hooks = _createHooksMap();
|
|
4766
4758
|
/**
|
|
4767
4759
|
* Expose whether this browser supports running the full DOMPurify.
|
|
4768
4760
|
*/
|
|
@@ -4780,22 +4772,18 @@ function requirePurify_cjs () {
|
|
|
4780
4772
|
let {
|
|
4781
4773
|
IS_ALLOWED_URI: IS_ALLOWED_URI$1
|
|
4782
4774
|
} = EXPRESSIONS;
|
|
4783
|
-
|
|
4784
4775
|
/**
|
|
4785
4776
|
* We consider the elements and attributes below to be safe. Ideally
|
|
4786
4777
|
* don't add any new ones but feel free to remove unwanted ones.
|
|
4787
4778
|
*/
|
|
4788
|
-
|
|
4789
4779
|
/* allowed element names */
|
|
4790
4780
|
let ALLOWED_TAGS = null;
|
|
4791
4781
|
const DEFAULT_ALLOWED_TAGS = addToSet({}, [...html$1, ...svg$1, ...svgFilters, ...mathMl$1, ...text]);
|
|
4792
|
-
|
|
4793
4782
|
/* Allowed attribute names */
|
|
4794
4783
|
let ALLOWED_ATTR = null;
|
|
4795
4784
|
const DEFAULT_ALLOWED_ATTR = addToSet({}, [...html, ...svg, ...mathMl, ...xml]);
|
|
4796
|
-
|
|
4797
4785
|
/*
|
|
4798
|
-
* Configure how
|
|
4786
|
+
* Configure how DOMPurify should handle custom elements and their attributes as well as customized built-in elements.
|
|
4799
4787
|
* @property {RegExp|Function|null} tagNameCheck one of [null, regexPattern, predicate]. Default: `null` (disallow any custom elements)
|
|
4800
4788
|
* @property {RegExp|Function|null} attributeNameCheck one of [null, regexPattern, predicate]. Default: `null` (disallow any attributes not on the allow list)
|
|
4801
4789
|
* @property {boolean} allowCustomizedBuiltInElements allow custom elements derived from built-ins if they pass CUSTOM_ELEMENT_HANDLING.tagNameCheck. Default: `false`.
|
|
@@ -4820,65 +4808,49 @@ function requirePurify_cjs () {
|
|
|
4820
4808
|
value: false
|
|
4821
4809
|
}
|
|
4822
4810
|
}));
|
|
4823
|
-
|
|
4824
4811
|
/* Explicitly forbidden tags (overrides ALLOWED_TAGS/ADD_TAGS) */
|
|
4825
4812
|
let FORBID_TAGS = null;
|
|
4826
|
-
|
|
4827
4813
|
/* Explicitly forbidden attributes (overrides ALLOWED_ATTR/ADD_ATTR) */
|
|
4828
4814
|
let FORBID_ATTR = null;
|
|
4829
|
-
|
|
4830
4815
|
/* Decide if ARIA attributes are okay */
|
|
4831
4816
|
let ALLOW_ARIA_ATTR = true;
|
|
4832
|
-
|
|
4833
4817
|
/* Decide if custom data attributes are okay */
|
|
4834
4818
|
let ALLOW_DATA_ATTR = true;
|
|
4835
|
-
|
|
4836
4819
|
/* Decide if unknown protocols are okay */
|
|
4837
4820
|
let ALLOW_UNKNOWN_PROTOCOLS = false;
|
|
4838
|
-
|
|
4839
4821
|
/* Decide if self-closing tags in attributes are allowed.
|
|
4840
4822
|
* Usually removed due to a mXSS issue in jQuery 3.0 */
|
|
4841
4823
|
let ALLOW_SELF_CLOSE_IN_ATTR = true;
|
|
4842
|
-
|
|
4843
4824
|
/* Output should be safe for common template engines.
|
|
4844
4825
|
* This means, DOMPurify removes data attributes, mustaches and ERB
|
|
4845
4826
|
*/
|
|
4846
4827
|
let SAFE_FOR_TEMPLATES = false;
|
|
4847
|
-
|
|
4848
4828
|
/* Output should be safe even for XML used within HTML and alike.
|
|
4849
4829
|
* This means, DOMPurify removes comments when containing risky content.
|
|
4850
4830
|
*/
|
|
4851
4831
|
let SAFE_FOR_XML = true;
|
|
4852
|
-
|
|
4853
4832
|
/* Decide if document with <html>... should be returned */
|
|
4854
4833
|
let WHOLE_DOCUMENT = false;
|
|
4855
|
-
|
|
4856
4834
|
/* Track whether config is already set on this instance of DOMPurify. */
|
|
4857
4835
|
let SET_CONFIG = false;
|
|
4858
|
-
|
|
4859
4836
|
/* Decide if all elements (e.g. style, script) must be children of
|
|
4860
4837
|
* document.body. By default, browsers might move them to document.head */
|
|
4861
4838
|
let FORCE_BODY = false;
|
|
4862
|
-
|
|
4863
4839
|
/* Decide if a DOM `HTMLBodyElement` should be returned, instead of a html
|
|
4864
4840
|
* string (or a TrustedHTML object if Trusted Types are supported).
|
|
4865
4841
|
* If `WHOLE_DOCUMENT` is enabled a `HTMLHtmlElement` will be returned instead
|
|
4866
4842
|
*/
|
|
4867
4843
|
let RETURN_DOM = false;
|
|
4868
|
-
|
|
4869
4844
|
/* Decide if a DOM `DocumentFragment` should be returned, instead of a html
|
|
4870
4845
|
* string (or a TrustedHTML object if Trusted Types are supported) */
|
|
4871
4846
|
let RETURN_DOM_FRAGMENT = false;
|
|
4872
|
-
|
|
4873
4847
|
/* Try to return a Trusted Type object instead of a string, return a string in
|
|
4874
4848
|
* case Trusted Types are not supported */
|
|
4875
4849
|
let RETURN_TRUSTED_TYPE = false;
|
|
4876
|
-
|
|
4877
4850
|
/* Output should be free from DOM clobbering attacks?
|
|
4878
4851
|
* This sanitizes markups named with colliding, clobberable built-in DOM APIs.
|
|
4879
4852
|
*/
|
|
4880
4853
|
let SANITIZE_DOM = true;
|
|
4881
|
-
|
|
4882
4854
|
/* Achieve full DOM Clobbering protection by isolating the namespace of named
|
|
4883
4855
|
* properties and JS variables, mitigating attacks that abuse the HTML/DOM spec rules.
|
|
4884
4856
|
*
|
|
@@ -4894,25 +4866,19 @@ function requirePurify_cjs () {
|
|
|
4894
4866
|
*/
|
|
4895
4867
|
let SANITIZE_NAMED_PROPS = false;
|
|
4896
4868
|
const SANITIZE_NAMED_PROPS_PREFIX = 'user-content-';
|
|
4897
|
-
|
|
4898
4869
|
/* Keep element content when removing element? */
|
|
4899
4870
|
let KEEP_CONTENT = true;
|
|
4900
|
-
|
|
4901
4871
|
/* If a `Node` is passed to sanitize(), then performs sanitization in-place instead
|
|
4902
4872
|
* of importing it into a new Document and returning a sanitized copy */
|
|
4903
4873
|
let IN_PLACE = false;
|
|
4904
|
-
|
|
4905
4874
|
/* Allow usage of profiles like html, svg and mathMl */
|
|
4906
4875
|
let USE_PROFILES = {};
|
|
4907
|
-
|
|
4908
4876
|
/* Tags to ignore content of when KEEP_CONTENT is true */
|
|
4909
4877
|
let FORBID_CONTENTS = null;
|
|
4910
4878
|
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']);
|
|
4911
|
-
|
|
4912
4879
|
/* Tags that are safe for data: URIs */
|
|
4913
4880
|
let DATA_URI_TAGS = null;
|
|
4914
4881
|
const DEFAULT_DATA_URI_TAGS = addToSet({}, ['audio', 'video', 'img', 'source', 'image', 'track']);
|
|
4915
|
-
|
|
4916
4882
|
/* Attributes safe for values like "javascript:" */
|
|
4917
4883
|
let URI_SAFE_ATTRIBUTES = null;
|
|
4918
4884
|
const DEFAULT_URI_SAFE_ATTRIBUTES = addToSet({}, ['alt', 'class', 'for', 'id', 'label', 'name', 'pattern', 'placeholder', 'role', 'summary', 'title', 'value', 'style', 'xmlns']);
|
|
@@ -4922,32 +4888,33 @@ function requirePurify_cjs () {
|
|
|
4922
4888
|
/* Document namespace */
|
|
4923
4889
|
let NAMESPACE = HTML_NAMESPACE;
|
|
4924
4890
|
let IS_EMPTY_INPUT = false;
|
|
4925
|
-
|
|
4926
4891
|
/* Allowed XHTML+XML namespaces */
|
|
4927
4892
|
let ALLOWED_NAMESPACES = null;
|
|
4928
4893
|
const DEFAULT_ALLOWED_NAMESPACES = addToSet({}, [MATHML_NAMESPACE, SVG_NAMESPACE, HTML_NAMESPACE], stringToString);
|
|
4929
|
-
|
|
4894
|
+
let MATHML_TEXT_INTEGRATION_POINTS = addToSet({}, ['mi', 'mo', 'mn', 'ms', 'mtext']);
|
|
4895
|
+
let HTML_INTEGRATION_POINTS = addToSet({}, ['annotation-xml']);
|
|
4896
|
+
// Certain elements are allowed in both SVG and HTML
|
|
4897
|
+
// namespace. We need to specify them explicitly
|
|
4898
|
+
// so that they don't get erroneously deleted from
|
|
4899
|
+
// HTML namespace.
|
|
4900
|
+
const COMMON_SVG_AND_HTML_ELEMENTS = addToSet({}, ['title', 'style', 'font', 'a', 'script']);
|
|
4930
4901
|
/* Parsing of strict XHTML documents */
|
|
4931
4902
|
let PARSER_MEDIA_TYPE = null;
|
|
4932
4903
|
const SUPPORTED_PARSER_MEDIA_TYPES = ['application/xhtml+xml', 'text/html'];
|
|
4933
4904
|
const DEFAULT_PARSER_MEDIA_TYPE = 'text/html';
|
|
4934
4905
|
let transformCaseFunc = null;
|
|
4935
|
-
|
|
4936
4906
|
/* Keep a reference to config to pass to hooks */
|
|
4937
4907
|
let CONFIG = null;
|
|
4938
|
-
|
|
4939
4908
|
/* Ideally, do not touch anything below this line */
|
|
4940
4909
|
/* ______________________________________________ */
|
|
4941
|
-
|
|
4942
4910
|
const formElement = document.createElement('form');
|
|
4943
4911
|
const isRegexOrFunction = function isRegexOrFunction(testValue) {
|
|
4944
4912
|
return testValue instanceof RegExp || testValue instanceof Function;
|
|
4945
4913
|
};
|
|
4946
|
-
|
|
4947
4914
|
/**
|
|
4948
4915
|
* _parseConfig
|
|
4949
4916
|
*
|
|
4950
|
-
* @param
|
|
4917
|
+
* @param cfg optional config literal
|
|
4951
4918
|
*/
|
|
4952
4919
|
// eslint-disable-next-line complexity
|
|
4953
4920
|
const _parseConfig = function _parseConfig() {
|
|
@@ -4955,39 +4922,23 @@ function requirePurify_cjs () {
|
|
|
4955
4922
|
if (CONFIG && CONFIG === cfg) {
|
|
4956
4923
|
return;
|
|
4957
4924
|
}
|
|
4958
|
-
|
|
4959
4925
|
/* Shield configuration object from tampering */
|
|
4960
4926
|
if (!cfg || typeof cfg !== 'object') {
|
|
4961
4927
|
cfg = {};
|
|
4962
4928
|
}
|
|
4963
|
-
|
|
4964
4929
|
/* Shield configuration object from prototype pollution */
|
|
4965
4930
|
cfg = clone(cfg);
|
|
4966
4931
|
PARSER_MEDIA_TYPE =
|
|
4967
4932
|
// eslint-disable-next-line unicorn/prefer-includes
|
|
4968
4933
|
SUPPORTED_PARSER_MEDIA_TYPES.indexOf(cfg.PARSER_MEDIA_TYPE) === -1 ? DEFAULT_PARSER_MEDIA_TYPE : cfg.PARSER_MEDIA_TYPE;
|
|
4969
|
-
|
|
4970
4934
|
// HTML tags and attributes are not case-sensitive, converting to lowercase. Keeping XHTML as is.
|
|
4971
4935
|
transformCaseFunc = PARSER_MEDIA_TYPE === 'application/xhtml+xml' ? stringToString : stringToLowerCase;
|
|
4972
|
-
|
|
4973
4936
|
/* Set configuration parameters */
|
|
4974
4937
|
ALLOWED_TAGS = objectHasOwnProperty(cfg, 'ALLOWED_TAGS') ? addToSet({}, cfg.ALLOWED_TAGS, transformCaseFunc) : DEFAULT_ALLOWED_TAGS;
|
|
4975
4938
|
ALLOWED_ATTR = objectHasOwnProperty(cfg, 'ALLOWED_ATTR') ? addToSet({}, cfg.ALLOWED_ATTR, transformCaseFunc) : DEFAULT_ALLOWED_ATTR;
|
|
4976
4939
|
ALLOWED_NAMESPACES = objectHasOwnProperty(cfg, 'ALLOWED_NAMESPACES') ? addToSet({}, cfg.ALLOWED_NAMESPACES, stringToString) : DEFAULT_ALLOWED_NAMESPACES;
|
|
4977
|
-
URI_SAFE_ATTRIBUTES = objectHasOwnProperty(cfg, 'ADD_URI_SAFE_ATTR') ? addToSet(clone(DEFAULT_URI_SAFE_ATTRIBUTES),
|
|
4978
|
-
|
|
4979
|
-
cfg.ADD_URI_SAFE_ATTR,
|
|
4980
|
-
// eslint-disable-line indent
|
|
4981
|
-
transformCaseFunc // eslint-disable-line indent
|
|
4982
|
-
) // eslint-disable-line indent
|
|
4983
|
-
: DEFAULT_URI_SAFE_ATTRIBUTES;
|
|
4984
|
-
DATA_URI_TAGS = objectHasOwnProperty(cfg, 'ADD_DATA_URI_TAGS') ? addToSet(clone(DEFAULT_DATA_URI_TAGS),
|
|
4985
|
-
// eslint-disable-line indent
|
|
4986
|
-
cfg.ADD_DATA_URI_TAGS,
|
|
4987
|
-
// eslint-disable-line indent
|
|
4988
|
-
transformCaseFunc // eslint-disable-line indent
|
|
4989
|
-
) // eslint-disable-line indent
|
|
4990
|
-
: DEFAULT_DATA_URI_TAGS;
|
|
4940
|
+
URI_SAFE_ATTRIBUTES = objectHasOwnProperty(cfg, 'ADD_URI_SAFE_ATTR') ? addToSet(clone(DEFAULT_URI_SAFE_ATTRIBUTES), cfg.ADD_URI_SAFE_ATTR, transformCaseFunc) : DEFAULT_URI_SAFE_ATTRIBUTES;
|
|
4941
|
+
DATA_URI_TAGS = objectHasOwnProperty(cfg, 'ADD_DATA_URI_TAGS') ? addToSet(clone(DEFAULT_DATA_URI_TAGS), cfg.ADD_DATA_URI_TAGS, transformCaseFunc) : DEFAULT_DATA_URI_TAGS;
|
|
4991
4942
|
FORBID_CONTENTS = objectHasOwnProperty(cfg, 'FORBID_CONTENTS') ? addToSet({}, cfg.FORBID_CONTENTS, transformCaseFunc) : DEFAULT_FORBID_CONTENTS;
|
|
4992
4943
|
FORBID_TAGS = objectHasOwnProperty(cfg, 'FORBID_TAGS') ? addToSet({}, cfg.FORBID_TAGS, transformCaseFunc) : {};
|
|
4993
4944
|
FORBID_ATTR = objectHasOwnProperty(cfg, 'FORBID_ATTR') ? addToSet({}, cfg.FORBID_ATTR, transformCaseFunc) : {};
|
|
@@ -5009,6 +4960,8 @@ function requirePurify_cjs () {
|
|
|
5009
4960
|
IN_PLACE = cfg.IN_PLACE || false; // Default false
|
|
5010
4961
|
IS_ALLOWED_URI$1 = cfg.ALLOWED_URI_REGEXP || IS_ALLOWED_URI;
|
|
5011
4962
|
NAMESPACE = cfg.NAMESPACE || HTML_NAMESPACE;
|
|
4963
|
+
MATHML_TEXT_INTEGRATION_POINTS = cfg.MATHML_TEXT_INTEGRATION_POINTS || MATHML_TEXT_INTEGRATION_POINTS;
|
|
4964
|
+
HTML_INTEGRATION_POINTS = cfg.HTML_INTEGRATION_POINTS || HTML_INTEGRATION_POINTS;
|
|
5012
4965
|
CUSTOM_ELEMENT_HANDLING = cfg.CUSTOM_ELEMENT_HANDLING || {};
|
|
5013
4966
|
if (cfg.CUSTOM_ELEMENT_HANDLING && isRegexOrFunction(cfg.CUSTOM_ELEMENT_HANDLING.tagNameCheck)) {
|
|
5014
4967
|
CUSTOM_ELEMENT_HANDLING.tagNameCheck = cfg.CUSTOM_ELEMENT_HANDLING.tagNameCheck;
|
|
@@ -5025,7 +4978,6 @@ function requirePurify_cjs () {
|
|
|
5025
4978
|
if (RETURN_DOM_FRAGMENT) {
|
|
5026
4979
|
RETURN_DOM = true;
|
|
5027
4980
|
}
|
|
5028
|
-
|
|
5029
4981
|
/* Parse profile info */
|
|
5030
4982
|
if (USE_PROFILES) {
|
|
5031
4983
|
ALLOWED_TAGS = addToSet({}, text);
|
|
@@ -5050,7 +5002,6 @@ function requirePurify_cjs () {
|
|
|
5050
5002
|
addToSet(ALLOWED_ATTR, xml);
|
|
5051
5003
|
}
|
|
5052
5004
|
}
|
|
5053
|
-
|
|
5054
5005
|
/* Merge configuration parameters */
|
|
5055
5006
|
if (cfg.ADD_TAGS) {
|
|
5056
5007
|
if (ALLOWED_TAGS === DEFAULT_ALLOWED_TAGS) {
|
|
@@ -5073,17 +5024,14 @@ function requirePurify_cjs () {
|
|
|
5073
5024
|
}
|
|
5074
5025
|
addToSet(FORBID_CONTENTS, cfg.FORBID_CONTENTS, transformCaseFunc);
|
|
5075
5026
|
}
|
|
5076
|
-
|
|
5077
5027
|
/* Add #text in case KEEP_CONTENT is set to true */
|
|
5078
5028
|
if (KEEP_CONTENT) {
|
|
5079
5029
|
ALLOWED_TAGS['#text'] = true;
|
|
5080
5030
|
}
|
|
5081
|
-
|
|
5082
5031
|
/* Add html, head and body to ALLOWED_TAGS in case WHOLE_DOCUMENT is true */
|
|
5083
5032
|
if (WHOLE_DOCUMENT) {
|
|
5084
5033
|
addToSet(ALLOWED_TAGS, ['html', 'head', 'body']);
|
|
5085
5034
|
}
|
|
5086
|
-
|
|
5087
5035
|
/* Add tbody to ALLOWED_TAGS in case tables are permitted, see #286, #365 */
|
|
5088
5036
|
if (ALLOWED_TAGS.table) {
|
|
5089
5037
|
addToSet(ALLOWED_TAGS, ['tbody']);
|
|
@@ -5096,10 +5044,8 @@ function requirePurify_cjs () {
|
|
|
5096
5044
|
if (typeof cfg.TRUSTED_TYPES_POLICY.createScriptURL !== 'function') {
|
|
5097
5045
|
throw typeErrorCreate('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');
|
|
5098
5046
|
}
|
|
5099
|
-
|
|
5100
5047
|
// Overwrite existing TrustedTypes policy.
|
|
5101
5048
|
trustedTypesPolicy = cfg.TRUSTED_TYPES_POLICY;
|
|
5102
|
-
|
|
5103
5049
|
// Sign local variables required by `sanitize`.
|
|
5104
5050
|
emptyHTML = trustedTypesPolicy.createHTML('');
|
|
5105
5051
|
} else {
|
|
@@ -5107,13 +5053,11 @@ function requirePurify_cjs () {
|
|
|
5107
5053
|
if (trustedTypesPolicy === undefined) {
|
|
5108
5054
|
trustedTypesPolicy = _createTrustedTypesPolicy(trustedTypes, currentScript);
|
|
5109
5055
|
}
|
|
5110
|
-
|
|
5111
5056
|
// If creating the internal policy succeeded sign internal variables.
|
|
5112
5057
|
if (trustedTypesPolicy !== null && typeof emptyHTML === 'string') {
|
|
5113
5058
|
emptyHTML = trustedTypesPolicy.createHTML('');
|
|
5114
5059
|
}
|
|
5115
5060
|
}
|
|
5116
|
-
|
|
5117
5061
|
// Prevent further manipulation of configuration.
|
|
5118
5062
|
// Not available in IE8, Safari 5, etc.
|
|
5119
5063
|
if (freeze) {
|
|
@@ -5121,30 +5065,19 @@ function requirePurify_cjs () {
|
|
|
5121
5065
|
}
|
|
5122
5066
|
CONFIG = cfg;
|
|
5123
5067
|
};
|
|
5124
|
-
const MATHML_TEXT_INTEGRATION_POINTS = addToSet({}, ['mi', 'mo', 'mn', 'ms', 'mtext']);
|
|
5125
|
-
const HTML_INTEGRATION_POINTS = addToSet({}, ['annotation-xml']);
|
|
5126
|
-
|
|
5127
|
-
// Certain elements are allowed in both SVG and HTML
|
|
5128
|
-
// namespace. We need to specify them explicitly
|
|
5129
|
-
// so that they don't get erroneously deleted from
|
|
5130
|
-
// HTML namespace.
|
|
5131
|
-
const COMMON_SVG_AND_HTML_ELEMENTS = addToSet({}, ['title', 'style', 'font', 'a', 'script']);
|
|
5132
|
-
|
|
5133
5068
|
/* Keep track of all possible SVG and MathML tags
|
|
5134
5069
|
* so that we can perform the namespace checks
|
|
5135
5070
|
* correctly. */
|
|
5136
5071
|
const ALL_SVG_TAGS = addToSet({}, [...svg$1, ...svgFilters, ...svgDisallowed]);
|
|
5137
5072
|
const ALL_MATHML_TAGS = addToSet({}, [...mathMl$1, ...mathMlDisallowed]);
|
|
5138
|
-
|
|
5139
5073
|
/**
|
|
5140
|
-
* @param
|
|
5141
|
-
* @returns
|
|
5074
|
+
* @param element a DOM element whose namespace is being checked
|
|
5075
|
+
* @returns Return false if the element has a
|
|
5142
5076
|
* namespace that a spec-compliant parser would never
|
|
5143
5077
|
* return. Return true otherwise.
|
|
5144
5078
|
*/
|
|
5145
5079
|
const _checkValidNamespace = function _checkValidNamespace(element) {
|
|
5146
5080
|
let parent = getParentNode(element);
|
|
5147
|
-
|
|
5148
5081
|
// In JSDOM, if we're inside shadow DOM, then parentNode
|
|
5149
5082
|
// can be null. We just simulate parent in this case.
|
|
5150
5083
|
if (!parent || !parent.tagName) {
|
|
@@ -5165,14 +5098,12 @@ function requirePurify_cjs () {
|
|
|
5165
5098
|
if (parent.namespaceURI === HTML_NAMESPACE) {
|
|
5166
5099
|
return tagName === 'svg';
|
|
5167
5100
|
}
|
|
5168
|
-
|
|
5169
5101
|
// The only way to switch from MathML to SVG is via`
|
|
5170
5102
|
// svg if parent is either <annotation-xml> or MathML
|
|
5171
5103
|
// text integration points.
|
|
5172
5104
|
if (parent.namespaceURI === MATHML_NAMESPACE) {
|
|
5173
5105
|
return tagName === 'svg' && (parentTagName === 'annotation-xml' || MATHML_TEXT_INTEGRATION_POINTS[parentTagName]);
|
|
5174
5106
|
}
|
|
5175
|
-
|
|
5176
5107
|
// We only allow elements that are defined in SVG
|
|
5177
5108
|
// spec. All others are disallowed in SVG namespace.
|
|
5178
5109
|
return Boolean(ALL_SVG_TAGS[tagName]);
|
|
@@ -5184,13 +5115,11 @@ function requirePurify_cjs () {
|
|
|
5184
5115
|
if (parent.namespaceURI === HTML_NAMESPACE) {
|
|
5185
5116
|
return tagName === 'math';
|
|
5186
5117
|
}
|
|
5187
|
-
|
|
5188
5118
|
// The only way to switch from SVG to MathML is via
|
|
5189
5119
|
// <math> and HTML integration points
|
|
5190
5120
|
if (parent.namespaceURI === SVG_NAMESPACE) {
|
|
5191
5121
|
return tagName === 'math' && HTML_INTEGRATION_POINTS[parentTagName];
|
|
5192
5122
|
}
|
|
5193
|
-
|
|
5194
5123
|
// We only allow elements that are defined in MathML
|
|
5195
5124
|
// spec. All others are disallowed in MathML namespace.
|
|
5196
5125
|
return Boolean(ALL_MATHML_TAGS[tagName]);
|
|
@@ -5205,28 +5134,24 @@ function requirePurify_cjs () {
|
|
|
5205
5134
|
if (parent.namespaceURI === MATHML_NAMESPACE && !MATHML_TEXT_INTEGRATION_POINTS[parentTagName]) {
|
|
5206
5135
|
return false;
|
|
5207
5136
|
}
|
|
5208
|
-
|
|
5209
5137
|
// We disallow tags that are specific for MathML
|
|
5210
5138
|
// or SVG and should never appear in HTML namespace
|
|
5211
5139
|
return !ALL_MATHML_TAGS[tagName] && (COMMON_SVG_AND_HTML_ELEMENTS[tagName] || !ALL_SVG_TAGS[tagName]);
|
|
5212
5140
|
}
|
|
5213
|
-
|
|
5214
5141
|
// For XHTML and XML documents that support custom namespaces
|
|
5215
5142
|
if (PARSER_MEDIA_TYPE === 'application/xhtml+xml' && ALLOWED_NAMESPACES[element.namespaceURI]) {
|
|
5216
5143
|
return true;
|
|
5217
5144
|
}
|
|
5218
|
-
|
|
5219
5145
|
// The code should never reach this place (this means
|
|
5220
5146
|
// that the element somehow got namespace that is not
|
|
5221
5147
|
// HTML, SVG, MathML or allowed via ALLOWED_NAMESPACES).
|
|
5222
5148
|
// Return false just in case.
|
|
5223
5149
|
return false;
|
|
5224
5150
|
};
|
|
5225
|
-
|
|
5226
5151
|
/**
|
|
5227
5152
|
* _forceRemove
|
|
5228
5153
|
*
|
|
5229
|
-
* @param
|
|
5154
|
+
* @param node a DOM node
|
|
5230
5155
|
*/
|
|
5231
5156
|
const _forceRemove = function _forceRemove(node) {
|
|
5232
5157
|
arrayPush(DOMPurify.removed, {
|
|
@@ -5239,46 +5164,43 @@ function requirePurify_cjs () {
|
|
|
5239
5164
|
remove(node);
|
|
5240
5165
|
}
|
|
5241
5166
|
};
|
|
5242
|
-
|
|
5243
5167
|
/**
|
|
5244
5168
|
* _removeAttribute
|
|
5245
5169
|
*
|
|
5246
|
-
* @param
|
|
5247
|
-
* @param
|
|
5170
|
+
* @param name an Attribute name
|
|
5171
|
+
* @param element a DOM node
|
|
5248
5172
|
*/
|
|
5249
|
-
const _removeAttribute = function _removeAttribute(name,
|
|
5173
|
+
const _removeAttribute = function _removeAttribute(name, element) {
|
|
5250
5174
|
try {
|
|
5251
5175
|
arrayPush(DOMPurify.removed, {
|
|
5252
|
-
attribute:
|
|
5253
|
-
from:
|
|
5176
|
+
attribute: element.getAttributeNode(name),
|
|
5177
|
+
from: element
|
|
5254
5178
|
});
|
|
5255
5179
|
} catch (_) {
|
|
5256
5180
|
arrayPush(DOMPurify.removed, {
|
|
5257
5181
|
attribute: null,
|
|
5258
|
-
from:
|
|
5182
|
+
from: element
|
|
5259
5183
|
});
|
|
5260
5184
|
}
|
|
5261
|
-
|
|
5262
|
-
|
|
5263
|
-
|
|
5264
|
-
if (name === 'is' && !ALLOWED_ATTR[name]) {
|
|
5185
|
+
element.removeAttribute(name);
|
|
5186
|
+
// We void attribute values for unremovable "is" attributes
|
|
5187
|
+
if (name === 'is') {
|
|
5265
5188
|
if (RETURN_DOM || RETURN_DOM_FRAGMENT) {
|
|
5266
5189
|
try {
|
|
5267
|
-
_forceRemove(
|
|
5190
|
+
_forceRemove(element);
|
|
5268
5191
|
} catch (_) {}
|
|
5269
5192
|
} else {
|
|
5270
5193
|
try {
|
|
5271
|
-
|
|
5194
|
+
element.setAttribute(name, '');
|
|
5272
5195
|
} catch (_) {}
|
|
5273
5196
|
}
|
|
5274
5197
|
}
|
|
5275
5198
|
};
|
|
5276
|
-
|
|
5277
5199
|
/**
|
|
5278
5200
|
* _initDocument
|
|
5279
5201
|
*
|
|
5280
|
-
* @param
|
|
5281
|
-
* @return
|
|
5202
|
+
* @param dirty - a string of dirty markup
|
|
5203
|
+
* @return a DOM, filled with the dirty markup
|
|
5282
5204
|
*/
|
|
5283
5205
|
const _initDocument = function _initDocument(dirty) {
|
|
5284
5206
|
/* Create a HTML document */
|
|
@@ -5305,7 +5227,6 @@ function requirePurify_cjs () {
|
|
|
5305
5227
|
doc = new DOMParser().parseFromString(dirtyPayload, PARSER_MEDIA_TYPE);
|
|
5306
5228
|
} catch (_) {}
|
|
5307
5229
|
}
|
|
5308
|
-
|
|
5309
5230
|
/* Use createHTMLDocument in case DOMParser is not available */
|
|
5310
5231
|
if (!doc || !doc.documentElement) {
|
|
5311
5232
|
doc = implementation.createDocument(NAMESPACE, 'template', null);
|
|
@@ -5319,112 +5240,86 @@ function requirePurify_cjs () {
|
|
|
5319
5240
|
if (dirty && leadingWhitespace) {
|
|
5320
5241
|
body.insertBefore(document.createTextNode(leadingWhitespace), body.childNodes[0] || null);
|
|
5321
5242
|
}
|
|
5322
|
-
|
|
5323
5243
|
/* Work on whole document or just its body */
|
|
5324
5244
|
if (NAMESPACE === HTML_NAMESPACE) {
|
|
5325
5245
|
return getElementsByTagName.call(doc, WHOLE_DOCUMENT ? 'html' : 'body')[0];
|
|
5326
5246
|
}
|
|
5327
5247
|
return WHOLE_DOCUMENT ? doc.documentElement : body;
|
|
5328
5248
|
};
|
|
5329
|
-
|
|
5330
5249
|
/**
|
|
5331
5250
|
* Creates a NodeIterator object that you can use to traverse filtered lists of nodes or elements in a document.
|
|
5332
5251
|
*
|
|
5333
|
-
* @param
|
|
5334
|
-
* @return
|
|
5252
|
+
* @param root The root element or node to start traversing on.
|
|
5253
|
+
* @return The created NodeIterator
|
|
5335
5254
|
*/
|
|
5336
5255
|
const _createNodeIterator = function _createNodeIterator(root) {
|
|
5337
5256
|
return createNodeIterator.call(root.ownerDocument || root, root,
|
|
5338
5257
|
// eslint-disable-next-line no-bitwise
|
|
5339
5258
|
NodeFilter.SHOW_ELEMENT | NodeFilter.SHOW_COMMENT | NodeFilter.SHOW_TEXT | NodeFilter.SHOW_PROCESSING_INSTRUCTION | NodeFilter.SHOW_CDATA_SECTION, null);
|
|
5340
5259
|
};
|
|
5341
|
-
|
|
5342
5260
|
/**
|
|
5343
5261
|
* _isClobbered
|
|
5344
5262
|
*
|
|
5345
|
-
* @param
|
|
5346
|
-
* @return
|
|
5263
|
+
* @param element element to check for clobbering attacks
|
|
5264
|
+
* @return true if clobbered, false if safe
|
|
5347
5265
|
*/
|
|
5348
|
-
const _isClobbered = function _isClobbered(
|
|
5349
|
-
return
|
|
5266
|
+
const _isClobbered = function _isClobbered(element) {
|
|
5267
|
+
return element instanceof HTMLFormElement && (typeof element.nodeName !== 'string' || typeof element.textContent !== 'string' || typeof element.removeChild !== 'function' || !(element.attributes instanceof NamedNodeMap) || typeof element.removeAttribute !== 'function' || typeof element.setAttribute !== 'function' || typeof element.namespaceURI !== 'string' || typeof element.insertBefore !== 'function' || typeof element.hasChildNodes !== 'function');
|
|
5350
5268
|
};
|
|
5351
|
-
|
|
5352
5269
|
/**
|
|
5353
5270
|
* Checks whether the given object is a DOM node.
|
|
5354
5271
|
*
|
|
5355
|
-
* @param
|
|
5356
|
-
* @return
|
|
5272
|
+
* @param value object to check whether it's a DOM node
|
|
5273
|
+
* @return true is object is a DOM node
|
|
5357
5274
|
*/
|
|
5358
|
-
const _isNode = function _isNode(
|
|
5359
|
-
return typeof Node === 'function' &&
|
|
5275
|
+
const _isNode = function _isNode(value) {
|
|
5276
|
+
return typeof Node === 'function' && value instanceof Node;
|
|
5360
5277
|
};
|
|
5361
|
-
|
|
5362
|
-
|
|
5363
|
-
* _executeHook
|
|
5364
|
-
* Execute user configurable hooks
|
|
5365
|
-
*
|
|
5366
|
-
* @param {String} entryPoint Name of the hook's entry point
|
|
5367
|
-
* @param {Node} currentNode node to work on with the hook
|
|
5368
|
-
* @param {Object} data additional hook parameters
|
|
5369
|
-
*/
|
|
5370
|
-
const _executeHook = function _executeHook(entryPoint, currentNode, data) {
|
|
5371
|
-
if (!hooks[entryPoint]) {
|
|
5372
|
-
return;
|
|
5373
|
-
}
|
|
5374
|
-
arrayForEach(hooks[entryPoint], hook => {
|
|
5278
|
+
function _executeHooks(hooks, currentNode, data) {
|
|
5279
|
+
arrayForEach(hooks, hook => {
|
|
5375
5280
|
hook.call(DOMPurify, currentNode, data, CONFIG);
|
|
5376
5281
|
});
|
|
5377
|
-
}
|
|
5378
|
-
|
|
5282
|
+
}
|
|
5379
5283
|
/**
|
|
5380
5284
|
* _sanitizeElements
|
|
5381
5285
|
*
|
|
5382
5286
|
* @protect nodeName
|
|
5383
5287
|
* @protect textContent
|
|
5384
5288
|
* @protect removeChild
|
|
5385
|
-
*
|
|
5386
|
-
* @
|
|
5387
|
-
* @return {Boolean} true if node was killed, false if left alive
|
|
5289
|
+
* @param currentNode to check for permission to exist
|
|
5290
|
+
* @return true if node was killed, false if left alive
|
|
5388
5291
|
*/
|
|
5389
5292
|
const _sanitizeElements = function _sanitizeElements(currentNode) {
|
|
5390
5293
|
let content = null;
|
|
5391
|
-
|
|
5392
5294
|
/* Execute a hook if present */
|
|
5393
|
-
|
|
5394
|
-
|
|
5295
|
+
_executeHooks(hooks.beforeSanitizeElements, currentNode, null);
|
|
5395
5296
|
/* Check if element is clobbered or can clobber */
|
|
5396
5297
|
if (_isClobbered(currentNode)) {
|
|
5397
5298
|
_forceRemove(currentNode);
|
|
5398
5299
|
return true;
|
|
5399
5300
|
}
|
|
5400
|
-
|
|
5401
5301
|
/* Now let's check the element's type and name */
|
|
5402
5302
|
const tagName = transformCaseFunc(currentNode.nodeName);
|
|
5403
|
-
|
|
5404
5303
|
/* Execute a hook if present */
|
|
5405
|
-
|
|
5304
|
+
_executeHooks(hooks.uponSanitizeElement, currentNode, {
|
|
5406
5305
|
tagName,
|
|
5407
5306
|
allowedTags: ALLOWED_TAGS
|
|
5408
5307
|
});
|
|
5409
|
-
|
|
5410
5308
|
/* Detect mXSS attempts abusing namespace confusion */
|
|
5411
5309
|
if (currentNode.hasChildNodes() && !_isNode(currentNode.firstElementChild) && regExpTest(/<[/\w]/g, currentNode.innerHTML) && regExpTest(/<[/\w]/g, currentNode.textContent)) {
|
|
5412
5310
|
_forceRemove(currentNode);
|
|
5413
5311
|
return true;
|
|
5414
5312
|
}
|
|
5415
|
-
|
|
5416
5313
|
/* Remove any occurrence of processing instructions */
|
|
5417
5314
|
if (currentNode.nodeType === NODE_TYPE.progressingInstruction) {
|
|
5418
5315
|
_forceRemove(currentNode);
|
|
5419
5316
|
return true;
|
|
5420
5317
|
}
|
|
5421
|
-
|
|
5422
5318
|
/* Remove any kind of possibly harmful comments */
|
|
5423
5319
|
if (SAFE_FOR_XML && currentNode.nodeType === NODE_TYPE.comment && regExpTest(/<[/\w]/g, currentNode.data)) {
|
|
5424
5320
|
_forceRemove(currentNode);
|
|
5425
5321
|
return true;
|
|
5426
5322
|
}
|
|
5427
|
-
|
|
5428
5323
|
/* Remove element if anything forbids its presence */
|
|
5429
5324
|
if (!ALLOWED_TAGS[tagName] || FORBID_TAGS[tagName]) {
|
|
5430
5325
|
/* Check if we have a custom element to handle */
|
|
@@ -5436,7 +5331,6 @@ function requirePurify_cjs () {
|
|
|
5436
5331
|
return false;
|
|
5437
5332
|
}
|
|
5438
5333
|
}
|
|
5439
|
-
|
|
5440
5334
|
/* Keep content except for bad-listed elements */
|
|
5441
5335
|
if (KEEP_CONTENT && !FORBID_CONTENTS[tagName]) {
|
|
5442
5336
|
const parentNode = getParentNode(currentNode) || currentNode.parentNode;
|
|
@@ -5453,19 +5347,16 @@ function requirePurify_cjs () {
|
|
|
5453
5347
|
_forceRemove(currentNode);
|
|
5454
5348
|
return true;
|
|
5455
5349
|
}
|
|
5456
|
-
|
|
5457
5350
|
/* Check whether element has a valid namespace */
|
|
5458
5351
|
if (currentNode instanceof Element && !_checkValidNamespace(currentNode)) {
|
|
5459
5352
|
_forceRemove(currentNode);
|
|
5460
5353
|
return true;
|
|
5461
5354
|
}
|
|
5462
|
-
|
|
5463
5355
|
/* Make sure that older browsers don't get fallback-tag mXSS */
|
|
5464
5356
|
if ((tagName === 'noscript' || tagName === 'noembed' || tagName === 'noframes') && regExpTest(/<\/no(script|embed|frames)/i, currentNode.innerHTML)) {
|
|
5465
5357
|
_forceRemove(currentNode);
|
|
5466
5358
|
return true;
|
|
5467
5359
|
}
|
|
5468
|
-
|
|
5469
5360
|
/* Sanitize element content to be template-safe */
|
|
5470
5361
|
if (SAFE_FOR_TEMPLATES && currentNode.nodeType === NODE_TYPE.text) {
|
|
5471
5362
|
/* Get the element's text content */
|
|
@@ -5480,19 +5371,17 @@ function requirePurify_cjs () {
|
|
|
5480
5371
|
currentNode.textContent = content;
|
|
5481
5372
|
}
|
|
5482
5373
|
}
|
|
5483
|
-
|
|
5484
5374
|
/* Execute a hook if present */
|
|
5485
|
-
|
|
5375
|
+
_executeHooks(hooks.afterSanitizeElements, currentNode, null);
|
|
5486
5376
|
return false;
|
|
5487
5377
|
};
|
|
5488
|
-
|
|
5489
5378
|
/**
|
|
5490
5379
|
* _isValidAttribute
|
|
5491
5380
|
*
|
|
5492
|
-
* @param
|
|
5493
|
-
* @param
|
|
5494
|
-
* @param
|
|
5495
|
-
* @return
|
|
5381
|
+
* @param lcTag Lowercase tag name of containing element.
|
|
5382
|
+
* @param lcName Lowercase attribute name.
|
|
5383
|
+
* @param value Attribute value.
|
|
5384
|
+
* @return Returns true if `value` is valid, otherwise false.
|
|
5496
5385
|
*/
|
|
5497
5386
|
// eslint-disable-next-line complexity
|
|
5498
5387
|
const _isValidAttribute = function _isValidAttribute(lcTag, lcName, value) {
|
|
@@ -5500,7 +5389,6 @@ function requirePurify_cjs () {
|
|
|
5500
5389
|
if (SANITIZE_DOM && (lcName === 'id' || lcName === 'name') && (value in document || value in formElement)) {
|
|
5501
5390
|
return false;
|
|
5502
5391
|
}
|
|
5503
|
-
|
|
5504
5392
|
/* Allow valid data-* attributes: At least one character after "-"
|
|
5505
5393
|
(https://html.spec.whatwg.org/multipage/dom.html#embedding-custom-non-visible-data-with-the-data-*-attributes)
|
|
5506
5394
|
XML-compatible (https://html.spec.whatwg.org/multipage/infrastructure.html#xml-compatible and http://www.w3.org/TR/xml/#d0e804)
|
|
@@ -5522,19 +5410,17 @@ function requirePurify_cjs () {
|
|
|
5522
5410
|
} else ;
|
|
5523
5411
|
return true;
|
|
5524
5412
|
};
|
|
5525
|
-
|
|
5526
5413
|
/**
|
|
5527
5414
|
* _isBasicCustomElement
|
|
5528
5415
|
* checks if at least one dash is included in tagName, and it's not the first char
|
|
5529
5416
|
* for more sophisticated checking see https://github.com/sindresorhus/validate-element-name
|
|
5530
5417
|
*
|
|
5531
|
-
* @param
|
|
5532
|
-
* @returns
|
|
5418
|
+
* @param tagName name of the tag of the node to sanitize
|
|
5419
|
+
* @returns Returns true if the tag name meets the basic criteria for a custom element, otherwise false.
|
|
5533
5420
|
*/
|
|
5534
5421
|
const _isBasicCustomElement = function _isBasicCustomElement(tagName) {
|
|
5535
5422
|
return tagName !== 'annotation-xml' && stringMatch(tagName, CUSTOM_ELEMENT);
|
|
5536
5423
|
};
|
|
5537
|
-
|
|
5538
5424
|
/**
|
|
5539
5425
|
* _sanitizeAttributes
|
|
5540
5426
|
*
|
|
@@ -5543,27 +5429,26 @@ function requirePurify_cjs () {
|
|
|
5543
5429
|
* @protect removeAttribute
|
|
5544
5430
|
* @protect setAttribute
|
|
5545
5431
|
*
|
|
5546
|
-
* @param
|
|
5432
|
+
* @param currentNode to sanitize
|
|
5547
5433
|
*/
|
|
5548
5434
|
const _sanitizeAttributes = function _sanitizeAttributes(currentNode) {
|
|
5549
5435
|
/* Execute a hook if present */
|
|
5550
|
-
|
|
5436
|
+
_executeHooks(hooks.beforeSanitizeAttributes, currentNode, null);
|
|
5551
5437
|
const {
|
|
5552
5438
|
attributes
|
|
5553
5439
|
} = currentNode;
|
|
5554
|
-
|
|
5555
5440
|
/* Check if we have attributes; if not we might have a text node */
|
|
5556
|
-
if (!attributes) {
|
|
5441
|
+
if (!attributes || _isClobbered(currentNode)) {
|
|
5557
5442
|
return;
|
|
5558
5443
|
}
|
|
5559
5444
|
const hookEvent = {
|
|
5560
5445
|
attrName: '',
|
|
5561
5446
|
attrValue: '',
|
|
5562
5447
|
keepAttr: true,
|
|
5563
|
-
allowedAttributes: ALLOWED_ATTR
|
|
5448
|
+
allowedAttributes: ALLOWED_ATTR,
|
|
5449
|
+
forceKeepAttr: undefined
|
|
5564
5450
|
};
|
|
5565
5451
|
let l = attributes.length;
|
|
5566
|
-
|
|
5567
5452
|
/* Go backwards over all attributes; safely remove bad ones */
|
|
5568
5453
|
while (l--) {
|
|
5569
5454
|
const attr = attributes[l];
|
|
@@ -5574,64 +5459,53 @@ function requirePurify_cjs () {
|
|
|
5574
5459
|
} = attr;
|
|
5575
5460
|
const lcName = transformCaseFunc(name);
|
|
5576
5461
|
let value = name === 'value' ? attrValue : stringTrim(attrValue);
|
|
5577
|
-
|
|
5578
5462
|
/* Execute a hook if present */
|
|
5579
5463
|
hookEvent.attrName = lcName;
|
|
5580
5464
|
hookEvent.attrValue = value;
|
|
5581
5465
|
hookEvent.keepAttr = true;
|
|
5582
5466
|
hookEvent.forceKeepAttr = undefined; // Allows developers to see this is a property they can set
|
|
5583
|
-
|
|
5467
|
+
_executeHooks(hooks.uponSanitizeAttribute, currentNode, hookEvent);
|
|
5584
5468
|
value = hookEvent.attrValue;
|
|
5585
|
-
|
|
5469
|
+
/* Full DOM Clobbering protection via namespace isolation,
|
|
5470
|
+
* Prefix id and name attributes with `user-content-`
|
|
5471
|
+
*/
|
|
5472
|
+
if (SANITIZE_NAMED_PROPS && (lcName === 'id' || lcName === 'name')) {
|
|
5473
|
+
// Remove the attribute with this value
|
|
5474
|
+
_removeAttribute(name, currentNode);
|
|
5475
|
+
// Prefix the value and later re-create the attribute with the sanitized value
|
|
5476
|
+
value = SANITIZE_NAMED_PROPS_PREFIX + value;
|
|
5477
|
+
}
|
|
5478
|
+
/* Work around a security issue with comments inside attributes */
|
|
5479
|
+
if (SAFE_FOR_XML && regExpTest(/((--!?|])>)|<\/(style|title)/i, value)) {
|
|
5480
|
+
_removeAttribute(name, currentNode);
|
|
5481
|
+
continue;
|
|
5482
|
+
}
|
|
5586
5483
|
/* Did the hooks approve of the attribute? */
|
|
5587
5484
|
if (hookEvent.forceKeepAttr) {
|
|
5588
5485
|
continue;
|
|
5589
5486
|
}
|
|
5590
|
-
|
|
5591
5487
|
/* Remove attribute */
|
|
5592
5488
|
_removeAttribute(name, currentNode);
|
|
5593
|
-
|
|
5594
5489
|
/* Did the hooks approve of the attribute? */
|
|
5595
5490
|
if (!hookEvent.keepAttr) {
|
|
5596
5491
|
continue;
|
|
5597
5492
|
}
|
|
5598
|
-
|
|
5599
5493
|
/* Work around a security issue in jQuery 3.0 */
|
|
5600
5494
|
if (!ALLOW_SELF_CLOSE_IN_ATTR && regExpTest(/\/>/i, value)) {
|
|
5601
5495
|
_removeAttribute(name, currentNode);
|
|
5602
5496
|
continue;
|
|
5603
5497
|
}
|
|
5604
|
-
|
|
5605
5498
|
/* Sanitize attribute content to be template-safe */
|
|
5606
5499
|
if (SAFE_FOR_TEMPLATES) {
|
|
5607
5500
|
arrayForEach([MUSTACHE_EXPR, ERB_EXPR, TMPLIT_EXPR], expr => {
|
|
5608
5501
|
value = stringReplace(value, expr, ' ');
|
|
5609
5502
|
});
|
|
5610
5503
|
}
|
|
5611
|
-
|
|
5612
5504
|
/* Is `value` valid for this attribute? */
|
|
5613
5505
|
const lcTag = transformCaseFunc(currentNode.nodeName);
|
|
5614
5506
|
if (!_isValidAttribute(lcTag, lcName, value)) {
|
|
5615
5507
|
continue;
|
|
5616
5508
|
}
|
|
5617
|
-
|
|
5618
|
-
/* Full DOM Clobbering protection via namespace isolation,
|
|
5619
|
-
* Prefix id and name attributes with `user-content-`
|
|
5620
|
-
*/
|
|
5621
|
-
if (SANITIZE_NAMED_PROPS && (lcName === 'id' || lcName === 'name')) {
|
|
5622
|
-
// Remove the attribute with this value
|
|
5623
|
-
_removeAttribute(name, currentNode);
|
|
5624
|
-
|
|
5625
|
-
// Prefix the value and later re-create the attribute with the sanitized value
|
|
5626
|
-
value = SANITIZE_NAMED_PROPS_PREFIX + value;
|
|
5627
|
-
}
|
|
5628
|
-
|
|
5629
|
-
/* Work around a security issue with comments inside attributes */
|
|
5630
|
-
if (SAFE_FOR_XML && regExpTest(/((--!?|])>)|<\/(style|title)/i, value)) {
|
|
5631
|
-
_removeAttribute(name, currentNode);
|
|
5632
|
-
continue;
|
|
5633
|
-
}
|
|
5634
|
-
|
|
5635
5509
|
/* Handle attributes that require Trusted Types */
|
|
5636
5510
|
if (trustedTypesPolicy && typeof trustedTypes === 'object' && typeof trustedTypes.getAttributeType === 'function') {
|
|
5637
5511
|
if (namespaceURI) ; else {
|
|
@@ -5649,7 +5523,6 @@ function requirePurify_cjs () {
|
|
|
5649
5523
|
}
|
|
5650
5524
|
}
|
|
5651
5525
|
}
|
|
5652
|
-
|
|
5653
5526
|
/* Handle invalid data-* attribute set by try-catching it */
|
|
5654
5527
|
try {
|
|
5655
5528
|
if (namespaceURI) {
|
|
@@ -5665,51 +5538,34 @@ function requirePurify_cjs () {
|
|
|
5665
5538
|
}
|
|
5666
5539
|
} catch (_) {}
|
|
5667
5540
|
}
|
|
5668
|
-
|
|
5669
5541
|
/* Execute a hook if present */
|
|
5670
|
-
|
|
5542
|
+
_executeHooks(hooks.afterSanitizeAttributes, currentNode, null);
|
|
5671
5543
|
};
|
|
5672
|
-
|
|
5673
5544
|
/**
|
|
5674
5545
|
* _sanitizeShadowDOM
|
|
5675
5546
|
*
|
|
5676
|
-
* @param
|
|
5547
|
+
* @param fragment to iterate over recursively
|
|
5677
5548
|
*/
|
|
5678
5549
|
const _sanitizeShadowDOM = function _sanitizeShadowDOM(fragment) {
|
|
5679
5550
|
let shadowNode = null;
|
|
5680
5551
|
const shadowIterator = _createNodeIterator(fragment);
|
|
5681
|
-
|
|
5682
5552
|
/* Execute a hook if present */
|
|
5683
|
-
|
|
5553
|
+
_executeHooks(hooks.beforeSanitizeShadowDOM, fragment, null);
|
|
5684
5554
|
while (shadowNode = shadowIterator.nextNode()) {
|
|
5685
5555
|
/* Execute a hook if present */
|
|
5686
|
-
|
|
5687
|
-
|
|
5556
|
+
_executeHooks(hooks.uponSanitizeShadowNode, shadowNode, null);
|
|
5688
5557
|
/* Sanitize tags and elements */
|
|
5689
|
-
|
|
5690
|
-
|
|
5691
|
-
|
|
5692
|
-
|
|
5558
|
+
_sanitizeElements(shadowNode);
|
|
5559
|
+
/* Check attributes next */
|
|
5560
|
+
_sanitizeAttributes(shadowNode);
|
|
5693
5561
|
/* Deep shadow DOM detected */
|
|
5694
5562
|
if (shadowNode.content instanceof DocumentFragment) {
|
|
5695
5563
|
_sanitizeShadowDOM(shadowNode.content);
|
|
5696
5564
|
}
|
|
5697
|
-
|
|
5698
|
-
/* Check attributes, sanitize if necessary */
|
|
5699
|
-
_sanitizeAttributes(shadowNode);
|
|
5700
5565
|
}
|
|
5701
|
-
|
|
5702
5566
|
/* Execute a hook if present */
|
|
5703
|
-
|
|
5567
|
+
_executeHooks(hooks.afterSanitizeShadowDOM, fragment, null);
|
|
5704
5568
|
};
|
|
5705
|
-
|
|
5706
|
-
/**
|
|
5707
|
-
* Sanitize
|
|
5708
|
-
* Public method providing core sanitation functionality
|
|
5709
|
-
*
|
|
5710
|
-
* @param {String|Node} dirty string or DOM node
|
|
5711
|
-
* @param {Object} cfg object
|
|
5712
|
-
*/
|
|
5713
5569
|
// eslint-disable-next-line complexity
|
|
5714
5570
|
DOMPurify.sanitize = function (dirty) {
|
|
5715
5571
|
let cfg = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
@@ -5724,7 +5580,6 @@ function requirePurify_cjs () {
|
|
|
5724
5580
|
if (IS_EMPTY_INPUT) {
|
|
5725
5581
|
dirty = '<!-->';
|
|
5726
5582
|
}
|
|
5727
|
-
|
|
5728
5583
|
/* Stringify, in case dirty is an object */
|
|
5729
5584
|
if (typeof dirty !== 'string' && !_isNode(dirty)) {
|
|
5730
5585
|
if (typeof dirty.toString === 'function') {
|
|
@@ -5736,20 +5591,16 @@ function requirePurify_cjs () {
|
|
|
5736
5591
|
throw typeErrorCreate('toString is not a function');
|
|
5737
5592
|
}
|
|
5738
5593
|
}
|
|
5739
|
-
|
|
5740
5594
|
/* Return dirty HTML if DOMPurify cannot run */
|
|
5741
5595
|
if (!DOMPurify.isSupported) {
|
|
5742
5596
|
return dirty;
|
|
5743
5597
|
}
|
|
5744
|
-
|
|
5745
5598
|
/* Assign config vars */
|
|
5746
5599
|
if (!SET_CONFIG) {
|
|
5747
5600
|
_parseConfig(cfg);
|
|
5748
5601
|
}
|
|
5749
|
-
|
|
5750
5602
|
/* Clean up removed elements */
|
|
5751
5603
|
DOMPurify.removed = [];
|
|
5752
|
-
|
|
5753
5604
|
/* Check if dirty is correctly typed for IN_PLACE */
|
|
5754
5605
|
if (typeof dirty === 'string') {
|
|
5755
5606
|
IN_PLACE = false;
|
|
@@ -5783,45 +5634,34 @@ function requirePurify_cjs () {
|
|
|
5783
5634
|
dirty.indexOf('<') === -1) {
|
|
5784
5635
|
return trustedTypesPolicy && RETURN_TRUSTED_TYPE ? trustedTypesPolicy.createHTML(dirty) : dirty;
|
|
5785
5636
|
}
|
|
5786
|
-
|
|
5787
5637
|
/* Initialize the document to work on */
|
|
5788
5638
|
body = _initDocument(dirty);
|
|
5789
|
-
|
|
5790
5639
|
/* Check we have a DOM node from the data */
|
|
5791
5640
|
if (!body) {
|
|
5792
5641
|
return RETURN_DOM ? null : RETURN_TRUSTED_TYPE ? emptyHTML : '';
|
|
5793
5642
|
}
|
|
5794
5643
|
}
|
|
5795
|
-
|
|
5796
5644
|
/* Remove first element node (ours) if FORCE_BODY is set */
|
|
5797
5645
|
if (body && FORCE_BODY) {
|
|
5798
5646
|
_forceRemove(body.firstChild);
|
|
5799
5647
|
}
|
|
5800
|
-
|
|
5801
5648
|
/* Get node iterator */
|
|
5802
5649
|
const nodeIterator = _createNodeIterator(IN_PLACE ? dirty : body);
|
|
5803
|
-
|
|
5804
5650
|
/* Now start iterating over the created document */
|
|
5805
5651
|
while (currentNode = nodeIterator.nextNode()) {
|
|
5806
5652
|
/* Sanitize tags and elements */
|
|
5807
|
-
|
|
5808
|
-
|
|
5809
|
-
|
|
5810
|
-
|
|
5653
|
+
_sanitizeElements(currentNode);
|
|
5654
|
+
/* Check attributes next */
|
|
5655
|
+
_sanitizeAttributes(currentNode);
|
|
5811
5656
|
/* Shadow DOM detected, sanitize it */
|
|
5812
5657
|
if (currentNode.content instanceof DocumentFragment) {
|
|
5813
5658
|
_sanitizeShadowDOM(currentNode.content);
|
|
5814
5659
|
}
|
|
5815
|
-
|
|
5816
|
-
/* Check attributes, sanitize if necessary */
|
|
5817
|
-
_sanitizeAttributes(currentNode);
|
|
5818
5660
|
}
|
|
5819
|
-
|
|
5820
5661
|
/* If we sanitized `dirty` in-place, return it. */
|
|
5821
5662
|
if (IN_PLACE) {
|
|
5822
5663
|
return dirty;
|
|
5823
5664
|
}
|
|
5824
|
-
|
|
5825
5665
|
/* Return sanitized string or DOM */
|
|
5826
5666
|
if (RETURN_DOM) {
|
|
5827
5667
|
if (RETURN_DOM_FRAGMENT) {
|
|
@@ -5846,12 +5686,10 @@ function requirePurify_cjs () {
|
|
|
5846
5686
|
return returnNode;
|
|
5847
5687
|
}
|
|
5848
5688
|
let serializedHTML = WHOLE_DOCUMENT ? body.outerHTML : body.innerHTML;
|
|
5849
|
-
|
|
5850
5689
|
/* Serialize doctype if allowed */
|
|
5851
5690
|
if (WHOLE_DOCUMENT && ALLOWED_TAGS['!doctype'] && body.ownerDocument && body.ownerDocument.doctype && body.ownerDocument.doctype.name && regExpTest(DOCTYPE_NAME, body.ownerDocument.doctype.name)) {
|
|
5852
5691
|
serializedHTML = '<!DOCTYPE ' + body.ownerDocument.doctype.name + '>\n' + serializedHTML;
|
|
5853
5692
|
}
|
|
5854
|
-
|
|
5855
5693
|
/* Sanitize final string template-safe */
|
|
5856
5694
|
if (SAFE_FOR_TEMPLATES) {
|
|
5857
5695
|
arrayForEach([MUSTACHE_EXPR, ERB_EXPR, TMPLIT_EXPR], expr => {
|
|
@@ -5860,39 +5698,15 @@ function requirePurify_cjs () {
|
|
|
5860
5698
|
}
|
|
5861
5699
|
return trustedTypesPolicy && RETURN_TRUSTED_TYPE ? trustedTypesPolicy.createHTML(serializedHTML) : serializedHTML;
|
|
5862
5700
|
};
|
|
5863
|
-
|
|
5864
|
-
/**
|
|
5865
|
-
* Public method to set the configuration once
|
|
5866
|
-
* setConfig
|
|
5867
|
-
*
|
|
5868
|
-
* @param {Object} cfg configuration object
|
|
5869
|
-
*/
|
|
5870
5701
|
DOMPurify.setConfig = function () {
|
|
5871
5702
|
let cfg = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
5872
5703
|
_parseConfig(cfg);
|
|
5873
5704
|
SET_CONFIG = true;
|
|
5874
5705
|
};
|
|
5875
|
-
|
|
5876
|
-
/**
|
|
5877
|
-
* Public method to remove the configuration
|
|
5878
|
-
* clearConfig
|
|
5879
|
-
*
|
|
5880
|
-
*/
|
|
5881
5706
|
DOMPurify.clearConfig = function () {
|
|
5882
5707
|
CONFIG = null;
|
|
5883
5708
|
SET_CONFIG = false;
|
|
5884
5709
|
};
|
|
5885
|
-
|
|
5886
|
-
/**
|
|
5887
|
-
* Public method to check if an attribute value is valid.
|
|
5888
|
-
* Uses last set config, if any. Otherwise, uses config defaults.
|
|
5889
|
-
* isValidAttribute
|
|
5890
|
-
*
|
|
5891
|
-
* @param {String} tag Tag name of containing element.
|
|
5892
|
-
* @param {String} attr Attribute name.
|
|
5893
|
-
* @param {String} value Attribute value.
|
|
5894
|
-
* @return {Boolean} Returns true if `value` is valid. Otherwise, returns false.
|
|
5895
|
-
*/
|
|
5896
5710
|
DOMPurify.isValidAttribute = function (tag, attr, value) {
|
|
5897
5711
|
/* Initialize shared config vars if necessary. */
|
|
5898
5712
|
if (!CONFIG) {
|
|
@@ -5902,54 +5716,24 @@ function requirePurify_cjs () {
|
|
|
5902
5716
|
const lcName = transformCaseFunc(attr);
|
|
5903
5717
|
return _isValidAttribute(lcTag, lcName, value);
|
|
5904
5718
|
};
|
|
5905
|
-
|
|
5906
|
-
/**
|
|
5907
|
-
* AddHook
|
|
5908
|
-
* Public method to add DOMPurify hooks
|
|
5909
|
-
*
|
|
5910
|
-
* @param {String} entryPoint entry point for the hook to add
|
|
5911
|
-
* @param {Function} hookFunction function to execute
|
|
5912
|
-
*/
|
|
5913
5719
|
DOMPurify.addHook = function (entryPoint, hookFunction) {
|
|
5914
5720
|
if (typeof hookFunction !== 'function') {
|
|
5915
5721
|
return;
|
|
5916
5722
|
}
|
|
5917
|
-
hooks[entryPoint] = hooks[entryPoint] || [];
|
|
5918
5723
|
arrayPush(hooks[entryPoint], hookFunction);
|
|
5919
5724
|
};
|
|
5920
|
-
|
|
5921
|
-
|
|
5922
|
-
|
|
5923
|
-
|
|
5924
|
-
* (pops it from the stack of hooks if more are present)
|
|
5925
|
-
*
|
|
5926
|
-
* @param {String} entryPoint entry point for the hook to remove
|
|
5927
|
-
* @return {Function} removed(popped) hook
|
|
5928
|
-
*/
|
|
5929
|
-
DOMPurify.removeHook = function (entryPoint) {
|
|
5930
|
-
if (hooks[entryPoint]) {
|
|
5931
|
-
return arrayPop(hooks[entryPoint]);
|
|
5725
|
+
DOMPurify.removeHook = function (entryPoint, hookFunction) {
|
|
5726
|
+
if (hookFunction !== undefined) {
|
|
5727
|
+
const index = arrayLastIndexOf(hooks[entryPoint], hookFunction);
|
|
5728
|
+
return index === -1 ? undefined : arraySplice(hooks[entryPoint], index, 1)[0];
|
|
5932
5729
|
}
|
|
5730
|
+
return arrayPop(hooks[entryPoint]);
|
|
5933
5731
|
};
|
|
5934
|
-
|
|
5935
|
-
/**
|
|
5936
|
-
* RemoveHooks
|
|
5937
|
-
* Public method to remove all DOMPurify hooks at a given entryPoint
|
|
5938
|
-
*
|
|
5939
|
-
* @param {String} entryPoint entry point for the hooks to remove
|
|
5940
|
-
*/
|
|
5941
5732
|
DOMPurify.removeHooks = function (entryPoint) {
|
|
5942
|
-
|
|
5943
|
-
hooks[entryPoint] = [];
|
|
5944
|
-
}
|
|
5733
|
+
hooks[entryPoint] = [];
|
|
5945
5734
|
};
|
|
5946
|
-
|
|
5947
|
-
/**
|
|
5948
|
-
* RemoveAllHooks
|
|
5949
|
-
* Public method to remove all DOMPurify hooks
|
|
5950
|
-
*/
|
|
5951
5735
|
DOMPurify.removeAllHooks = function () {
|
|
5952
|
-
hooks =
|
|
5736
|
+
hooks = _createHooksMap();
|
|
5953
5737
|
};
|
|
5954
5738
|
return DOMPurify;
|
|
5955
5739
|
}
|
|
@@ -75669,26 +75453,10 @@ function requireIndex_cjs () {
|
|
|
75669
75453
|
|
|
75670
75454
|
const draggableMixin$1 = (superclass) =>
|
|
75671
75455
|
class DraggableMixinClass extends superclass {
|
|
75672
|
-
#styleEle = null;
|
|
75673
|
-
|
|
75674
|
-
static get observedAttributes() {
|
|
75675
|
-
const superAttrs = superclass.observedAttributes || [];
|
|
75676
|
-
return [...superAttrs, 'draggable'];
|
|
75677
|
-
}
|
|
75678
|
-
|
|
75679
75456
|
constructor() {
|
|
75680
75457
|
super();
|
|
75681
75458
|
|
|
75682
|
-
|
|
75683
|
-
this.#styleEle.innerText = `* { cursor: inherit!important }`;
|
|
75684
|
-
}
|
|
75685
|
-
|
|
75686
|
-
#handleDraggableStyle(isDraggable) {
|
|
75687
|
-
if (isDraggable) {
|
|
75688
|
-
this.shadowRoot.appendChild(this.#styleEle);
|
|
75689
|
-
} else {
|
|
75690
|
-
this.#styleEle.remove();
|
|
75691
|
-
}
|
|
75459
|
+
injectStyle(`:host([draggable="true"]) * { cursor: inherit!important }`, this);
|
|
75692
75460
|
}
|
|
75693
75461
|
|
|
75694
75462
|
get isDraggable() {
|
|
@@ -75706,9 +75474,8 @@ function requireIndex_cjs () {
|
|
|
75706
75474
|
this.baseElement.setAttribute('tabindex', '-1');
|
|
75707
75475
|
|
|
75708
75476
|
const onComplete = () => {
|
|
75709
|
-
prevTabIndex
|
|
75710
|
-
|
|
75711
|
-
: this.baseElement.removeAttribute('tabindex');
|
|
75477
|
+
if (prevTabIndex) this.baseElement.setAttribute('tabindex', prevTabIndex);
|
|
75478
|
+
else this.baseElement.removeAttribute('tabindex');
|
|
75712
75479
|
|
|
75713
75480
|
e.target.removeEventListener('mouseup', onComplete);
|
|
75714
75481
|
e.target.removeEventListener('dragend', onComplete);
|
|
@@ -75721,13 +75488,6 @@ function requireIndex_cjs () {
|
|
|
75721
75488
|
|
|
75722
75489
|
super.init?.();
|
|
75723
75490
|
}
|
|
75724
|
-
|
|
75725
|
-
attributeChangedCallback(attrName, oldValue, newValue) {
|
|
75726
|
-
super.attributeChangedCallback?.(attrName, oldValue, newValue);
|
|
75727
|
-
if (attrName === 'draggable') {
|
|
75728
|
-
this.#handleDraggableStyle(newValue === 'true');
|
|
75729
|
-
}
|
|
75730
|
-
}
|
|
75731
75491
|
};
|
|
75732
75492
|
|
|
75733
75493
|
const componentNameValidationMixin$1 = (superclass) =>
|
|
@@ -77450,25 +77210,10 @@ function requireIndex_cjs () {
|
|
|
77450
77210
|
|
|
77451
77211
|
const draggableMixin = (superclass) =>
|
|
77452
77212
|
class DraggableMixinClass extends superclass {
|
|
77453
|
-
#styleEle = null;
|
|
77454
|
-
|
|
77455
|
-
static get observedAttributes() {
|
|
77456
|
-
const superAttrs = superclass.observedAttributes || [];
|
|
77457
|
-
return [...superAttrs, 'draggable'];
|
|
77458
|
-
}
|
|
77459
|
-
|
|
77460
77213
|
constructor() {
|
|
77461
77214
|
super();
|
|
77462
77215
|
|
|
77463
|
-
injectStyle(
|
|
77464
|
-
}
|
|
77465
|
-
|
|
77466
|
-
#handleDraggableStyle(isDraggable) {
|
|
77467
|
-
if (isDraggable) {
|
|
77468
|
-
this.shadowRoot.appendChild(this.#styleEle);
|
|
77469
|
-
} else {
|
|
77470
|
-
this.#styleEle.remove();
|
|
77471
|
-
}
|
|
77216
|
+
injectStyle(`:host([draggable="true"]) * { cursor: inherit!important }`, this);
|
|
77472
77217
|
}
|
|
77473
77218
|
|
|
77474
77219
|
get isDraggable() {
|
|
@@ -77501,13 +77246,6 @@ function requireIndex_cjs () {
|
|
|
77501
77246
|
|
|
77502
77247
|
super.init?.();
|
|
77503
77248
|
}
|
|
77504
|
-
|
|
77505
|
-
attributeChangedCallback(attrName, oldValue, newValue) {
|
|
77506
|
-
super.attributeChangedCallback?.(attrName, oldValue, newValue);
|
|
77507
|
-
if (attrName === 'draggable') {
|
|
77508
|
-
this.#handleDraggableStyle(newValue === 'true');
|
|
77509
|
-
}
|
|
77510
|
-
}
|
|
77511
77249
|
};
|
|
77512
77250
|
|
|
77513
77251
|
const componentNameValidationMixin = (superclass) =>
|
|
@@ -93585,11 +93323,12 @@ descope-boolean-field-internal {
|
|
|
93585
93323
|
}
|
|
93586
93324
|
|
|
93587
93325
|
descope-autocomplete-field-internal {
|
|
93588
|
-
|
|
93589
|
-
|
|
93590
|
-
|
|
93591
|
-
|
|
93592
|
-
|
|
93326
|
+
display: inline-block;
|
|
93327
|
+
box-sizing: border-box;
|
|
93328
|
+
user-select: none;
|
|
93329
|
+
width: 100%;
|
|
93330
|
+
max-width: 100%;
|
|
93331
|
+
}
|
|
93593
93332
|
|
|
93594
93333
|
descope-autocomplete-field-internal ::slotted {
|
|
93595
93334
|
padding: 0;
|
|
@@ -94087,6 +93826,7 @@ descope-boolean-field-internal {
|
|
|
94087
93826
|
display: inline-block;
|
|
94088
93827
|
box-sizing: border-box;
|
|
94089
93828
|
user-select: none;
|
|
93829
|
+
width: 100%;
|
|
94090
93830
|
max-width: 100%;
|
|
94091
93831
|
}
|
|
94092
93832
|
|