@returningai/widget-sdk 1.7.1 → 1.8.0
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/CHANGELOG.md +44 -0
- package/README.md +55 -11
- package/dist/rai-banner.iife.js +3 -3
- package/dist/rai-banner.js +307 -173
- package/dist/rai-widget.iife.js +3 -3
- package/dist/rai-widget.js +893 -294
- package/dist/types/BaseWidget.d.ts +7 -4
- package/dist/types/banner/color.d.ts +3 -0
- package/dist/types/banner/render.d.ts +3 -1
- package/dist/types/core/auto-theme-lease.d.ts +5 -0
- package/dist/types/core/bundle-runtime-cache.d.ts +6 -0
- package/dist/types/core/host-callback.d.ts +49 -0
- package/dist/types/index.d.ts +2 -2
- package/dist/types/types.d.ts +65 -10
- package/package.json +4 -4
package/dist/rai-banner.js
CHANGED
|
@@ -17,7 +17,7 @@ async function fetchEligibleBanner(apiUrl, request) {
|
|
|
17
17
|
return { banner: null, reason: "network_error" };
|
|
18
18
|
}
|
|
19
19
|
}
|
|
20
|
-
/*! @license DOMPurify 3.4.
|
|
20
|
+
/*! @license DOMPurify 3.4.12 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.4.12/LICENSE */
|
|
21
21
|
function _arrayLikeToArray(r, a) {
|
|
22
22
|
(null == a || a > r.length) && (a = r.length);
|
|
23
23
|
for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
|
|
@@ -250,7 +250,7 @@ const mathMl$1 = freeze(["math", "menclose", "merror", "mfenced", "mfrac", "mgly
|
|
|
250
250
|
const mathMlDisallowed = freeze(["maction", "maligngroup", "malignmark", "mlongdiv", "mscarries", "mscarry", "msgroup", "mstack", "msline", "msrow", "semantics", "annotation", "annotation-xml", "mprescripts", "none"]);
|
|
251
251
|
const text = freeze(["#text"]);
|
|
252
252
|
const html = freeze(["accept", "action", "align", "alt", "autocapitalize", "autocomplete", "autopictureinpicture", "autoplay", "background", "bgcolor", "border", "capture", "cellpadding", "cellspacing", "checked", "cite", "class", "clear", "color", "cols", "colspan", "command", "commandfor", "controls", "controlslist", "coords", "crossorigin", "datetime", "decoding", "default", "dir", "disabled", "disablepictureinpicture", "disableremoteplayback", "download", "draggable", "enctype", "enterkeyhint", "exportparts", "face", "for", "headers", "height", "hidden", "high", "href", "hreflang", "id", "inert", "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", "part", "pattern", "placeholder", "playsinline", "popover", "popovertarget", "popovertargetaction", "poster", "preload", "pubdate", "radiogroup", "readonly", "rel", "required", "rev", "reversed", "role", "rows", "rowspan", "spellcheck", "scope", "selected", "shape", "size", "sizes", "slot", "span", "srclang", "start", "src", "srcset", "step", "style", "summary", "tabindex", "title", "translate", "type", "usemap", "valign", "value", "width", "wrap", "xmlns"]);
|
|
253
|
-
const svg = freeze(["accent-height", "accumulate", "additive", "alignment-baseline", "amplitude", "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", "exponent", "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", "intercept", "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", "mask-type", "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", "slope", "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", "tablevalues", "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"]);
|
|
253
|
+
const svg = freeze(["accent-height", "accumulate", "additive", "alignment-baseline", "amplitude", "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", "dominant-baseline", "dur", "edgemode", "elevation", "end", "exponent", "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", "intercept", "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", "mask-type", "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", "slope", "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", "tablevalues", "targetx", "targety", "transform", "transform-origin", "text-anchor", "text-decoration", "text-orientation", "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"]);
|
|
254
254
|
const mathMl = freeze(["accent", "accentunder", "align", "bevelled", "close", "columnalign", "columnlines", "columnspacing", "columnspan", "denomalign", "depth", "dir", "display", "displaystyle", "encoding", "fence", "frame", "height", "href", "id", "largeop", "length", "linethickness", "lquote", "lspace", "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"]);
|
|
255
255
|
const xml = freeze(["xlink:href", "xml:id", "xlink:title", "xml:space", "xmlns:xlink"]);
|
|
256
256
|
const MUSTACHE_EXPR = seal(/{{[\w\W]*|^[\w\W]*}}/g);
|
|
@@ -269,6 +269,10 @@ const ATTR_WHITESPACE = seal(
|
|
|
269
269
|
);
|
|
270
270
|
const DOCTYPE_NAME = seal(/^html$/i);
|
|
271
271
|
const CUSTOM_ELEMENT = seal(/^[a-z][.\w]*(-[.\w]+)+$/i);
|
|
272
|
+
const ELEMENT_MARKUP_PROBE = seal(/<[/\w!]/g);
|
|
273
|
+
const COMMENT_MARKUP_PROBE = seal(/<[/\w]/g);
|
|
274
|
+
const FALLBACK_TAG_CLOSE = seal(/<\/no(script|embed|frames)/i);
|
|
275
|
+
const SELF_CLOSING_TAG = seal(/\/>/i);
|
|
272
276
|
const NODE_TYPE = {
|
|
273
277
|
element: 1,
|
|
274
278
|
attribute: 2,
|
|
@@ -278,7 +282,7 @@ const NODE_TYPE = {
|
|
|
278
282
|
// Deprecated
|
|
279
283
|
entityNode: 6,
|
|
280
284
|
// Deprecated
|
|
281
|
-
|
|
285
|
+
processingInstruction: 7,
|
|
282
286
|
comment: 8,
|
|
283
287
|
document: 9,
|
|
284
288
|
documentType: 10,
|
|
@@ -326,10 +330,13 @@ const _createHooksMap = function _createHooksMap2() {
|
|
|
326
330
|
uponSanitizeShadowNode: []
|
|
327
331
|
};
|
|
328
332
|
};
|
|
333
|
+
const _resolveSetOption = function _resolveSetOption2(cfg, key, fallback, options) {
|
|
334
|
+
return objectHasOwnProperty(cfg, key) && arrayIsArray(cfg[key]) ? addToSet(options.base ? clone(options.base) : {}, cfg[key], options.transform) : fallback;
|
|
335
|
+
};
|
|
329
336
|
function createDOMPurify() {
|
|
330
337
|
let window2 = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : getGlobal();
|
|
331
338
|
const DOMPurify = (root) => createDOMPurify(root);
|
|
332
|
-
DOMPurify.version = "3.4.
|
|
339
|
+
DOMPurify.version = "3.4.12";
|
|
333
340
|
DOMPurify.removed = [];
|
|
334
341
|
if (!window2 || !window2.document || window2.document.nodeType !== NODE_TYPE.document || !window2.Element) {
|
|
335
342
|
DOMPurify.isSupported = false;
|
|
@@ -448,6 +455,8 @@ function createDOMPurify() {
|
|
|
448
455
|
let SAFE_FOR_XML = true;
|
|
449
456
|
let WHOLE_DOCUMENT = false;
|
|
450
457
|
let SET_CONFIG = false;
|
|
458
|
+
let SET_CONFIG_ALLOWED_TAGS = null;
|
|
459
|
+
let SET_CONFIG_ALLOWED_ATTR = null;
|
|
451
460
|
let FORCE_BODY = false;
|
|
452
461
|
let RETURN_DOM = false;
|
|
453
462
|
let RETURN_DOM_FRAGMENT = false;
|
|
@@ -507,8 +516,10 @@ function createDOMPurify() {
|
|
|
507
516
|
let IS_EMPTY_INPUT = false;
|
|
508
517
|
let ALLOWED_NAMESPACES = null;
|
|
509
518
|
const DEFAULT_ALLOWED_NAMESPACES = addToSet({}, [MATHML_NAMESPACE, SVG_NAMESPACE, HTML_NAMESPACE], stringToString);
|
|
510
|
-
|
|
511
|
-
let
|
|
519
|
+
const DEFAULT_MATHML_TEXT_INTEGRATION_POINTS = freeze(["mi", "mo", "mn", "ms", "mtext"]);
|
|
520
|
+
let MATHML_TEXT_INTEGRATION_POINTS = addToSet({}, DEFAULT_MATHML_TEXT_INTEGRATION_POINTS);
|
|
521
|
+
const DEFAULT_HTML_INTEGRATION_POINTS = freeze(["annotation-xml"]);
|
|
522
|
+
let HTML_INTEGRATION_POINTS = addToSet({}, DEFAULT_HTML_INTEGRATION_POINTS);
|
|
512
523
|
const COMMON_SVG_AND_HTML_ELEMENTS = addToSet({}, ["title", "style", "font", "a", "script"]);
|
|
513
524
|
let PARSER_MEDIA_TYPE = null;
|
|
514
525
|
const SUPPORTED_PARSER_MEDIA_TYPES = ["application/xhtml+xml", "text/html"];
|
|
@@ -531,14 +542,32 @@ function createDOMPurify() {
|
|
|
531
542
|
PARSER_MEDIA_TYPE = // eslint-disable-next-line unicorn/prefer-includes
|
|
532
543
|
SUPPORTED_PARSER_MEDIA_TYPES.indexOf(cfg.PARSER_MEDIA_TYPE) === -1 ? DEFAULT_PARSER_MEDIA_TYPE : cfg.PARSER_MEDIA_TYPE;
|
|
533
544
|
transformCaseFunc = PARSER_MEDIA_TYPE === "application/xhtml+xml" ? stringToString : stringToLowerCase;
|
|
534
|
-
ALLOWED_TAGS =
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
545
|
+
ALLOWED_TAGS = _resolveSetOption(cfg, "ALLOWED_TAGS", DEFAULT_ALLOWED_TAGS, {
|
|
546
|
+
transform: transformCaseFunc
|
|
547
|
+
});
|
|
548
|
+
ALLOWED_ATTR = _resolveSetOption(cfg, "ALLOWED_ATTR", DEFAULT_ALLOWED_ATTR, {
|
|
549
|
+
transform: transformCaseFunc
|
|
550
|
+
});
|
|
551
|
+
ALLOWED_NAMESPACES = _resolveSetOption(cfg, "ALLOWED_NAMESPACES", DEFAULT_ALLOWED_NAMESPACES, {
|
|
552
|
+
transform: stringToString
|
|
553
|
+
});
|
|
554
|
+
URI_SAFE_ATTRIBUTES = _resolveSetOption(cfg, "ADD_URI_SAFE_ATTR", DEFAULT_URI_SAFE_ATTRIBUTES, {
|
|
555
|
+
transform: transformCaseFunc,
|
|
556
|
+
base: DEFAULT_URI_SAFE_ATTRIBUTES
|
|
557
|
+
});
|
|
558
|
+
DATA_URI_TAGS = _resolveSetOption(cfg, "ADD_DATA_URI_TAGS", DEFAULT_DATA_URI_TAGS, {
|
|
559
|
+
transform: transformCaseFunc,
|
|
560
|
+
base: DEFAULT_DATA_URI_TAGS
|
|
561
|
+
});
|
|
562
|
+
FORBID_CONTENTS = _resolveSetOption(cfg, "FORBID_CONTENTS", DEFAULT_FORBID_CONTENTS, {
|
|
563
|
+
transform: transformCaseFunc
|
|
564
|
+
});
|
|
565
|
+
FORBID_TAGS = _resolveSetOption(cfg, "FORBID_TAGS", clone({}), {
|
|
566
|
+
transform: transformCaseFunc
|
|
567
|
+
});
|
|
568
|
+
FORBID_ATTR = _resolveSetOption(cfg, "FORBID_ATTR", clone({}), {
|
|
569
|
+
transform: transformCaseFunc
|
|
570
|
+
});
|
|
542
571
|
USE_PROFILES = objectHasOwnProperty(cfg, "USE_PROFILES") ? cfg.USE_PROFILES && typeof cfg.USE_PROFILES === "object" ? clone(cfg.USE_PROFILES) : cfg.USE_PROFILES : false;
|
|
543
572
|
ALLOW_ARIA_ATTR = cfg.ALLOW_ARIA_ATTR !== false;
|
|
544
573
|
ALLOW_DATA_ATTR = cfg.ALLOW_DATA_ATTR !== false;
|
|
@@ -557,8 +586,8 @@ function createDOMPurify() {
|
|
|
557
586
|
IN_PLACE = cfg.IN_PLACE || false;
|
|
558
587
|
IS_ALLOWED_URI$1 = isRegex(cfg.ALLOWED_URI_REGEXP) ? cfg.ALLOWED_URI_REGEXP : IS_ALLOWED_URI;
|
|
559
588
|
NAMESPACE = typeof cfg.NAMESPACE === "string" ? cfg.NAMESPACE : HTML_NAMESPACE;
|
|
560
|
-
MATHML_TEXT_INTEGRATION_POINTS = objectHasOwnProperty(cfg, "MATHML_TEXT_INTEGRATION_POINTS") && cfg.MATHML_TEXT_INTEGRATION_POINTS && typeof cfg.MATHML_TEXT_INTEGRATION_POINTS === "object" ? clone(cfg.MATHML_TEXT_INTEGRATION_POINTS) : addToSet({},
|
|
561
|
-
HTML_INTEGRATION_POINTS = objectHasOwnProperty(cfg, "HTML_INTEGRATION_POINTS") && cfg.HTML_INTEGRATION_POINTS && typeof cfg.HTML_INTEGRATION_POINTS === "object" ? clone(cfg.HTML_INTEGRATION_POINTS) : addToSet({},
|
|
589
|
+
MATHML_TEXT_INTEGRATION_POINTS = objectHasOwnProperty(cfg, "MATHML_TEXT_INTEGRATION_POINTS") && cfg.MATHML_TEXT_INTEGRATION_POINTS && typeof cfg.MATHML_TEXT_INTEGRATION_POINTS === "object" ? clone(cfg.MATHML_TEXT_INTEGRATION_POINTS) : addToSet({}, DEFAULT_MATHML_TEXT_INTEGRATION_POINTS);
|
|
590
|
+
HTML_INTEGRATION_POINTS = objectHasOwnProperty(cfg, "HTML_INTEGRATION_POINTS") && cfg.HTML_INTEGRATION_POINTS && typeof cfg.HTML_INTEGRATION_POINTS === "object" ? clone(cfg.HTML_INTEGRATION_POINTS) : addToSet({}, DEFAULT_HTML_INTEGRATION_POINTS);
|
|
562
591
|
const customElementHandling = objectHasOwnProperty(cfg, "CUSTOM_ELEMENT_HANDLING") && cfg.CUSTOM_ELEMENT_HANDLING && typeof cfg.CUSTOM_ELEMENT_HANDLING === "object" ? clone(cfg.CUSTOM_ELEMENT_HANDLING) : create(null);
|
|
563
592
|
CUSTOM_ELEMENT_HANDLING = create(null);
|
|
564
593
|
if (objectHasOwnProperty(customElementHandling, "tagNameCheck") && isRegexOrFunction(customElementHandling.tagNameCheck)) {
|
|
@@ -570,6 +599,7 @@ function createDOMPurify() {
|
|
|
570
599
|
if (objectHasOwnProperty(customElementHandling, "allowCustomizedBuiltInElements") && typeof customElementHandling.allowCustomizedBuiltInElements === "boolean") {
|
|
571
600
|
CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements = customElementHandling.allowCustomizedBuiltInElements;
|
|
572
601
|
}
|
|
602
|
+
seal(CUSTOM_ELEMENT_HANDLING);
|
|
573
603
|
if (SAFE_FOR_TEMPLATES) {
|
|
574
604
|
ALLOW_DATA_ATTR = false;
|
|
575
605
|
}
|
|
@@ -672,12 +702,6 @@ function createDOMPurify() {
|
|
|
672
702
|
emptyHTML = _createTrustedHTML("");
|
|
673
703
|
}
|
|
674
704
|
}
|
|
675
|
-
if ((hooks.uponSanitizeElement.length > 0 || hooks.uponSanitizeAttribute.length > 0) && ALLOWED_TAGS === DEFAULT_ALLOWED_TAGS) {
|
|
676
|
-
ALLOWED_TAGS = clone(ALLOWED_TAGS);
|
|
677
|
-
}
|
|
678
|
-
if (hooks.uponSanitizeAttribute.length > 0 && ALLOWED_ATTR === DEFAULT_ALLOWED_ATTR) {
|
|
679
|
-
ALLOWED_ATTR = clone(ALLOWED_ATTR);
|
|
680
|
-
}
|
|
681
705
|
if (freeze) {
|
|
682
706
|
freeze(cfg);
|
|
683
707
|
}
|
|
@@ -685,6 +709,33 @@ function createDOMPurify() {
|
|
|
685
709
|
};
|
|
686
710
|
const ALL_SVG_TAGS = addToSet({}, [...svg$1, ...svgFilters, ...svgDisallowed]);
|
|
687
711
|
const ALL_MATHML_TAGS = addToSet({}, [...mathMl$1, ...mathMlDisallowed]);
|
|
712
|
+
const _checkSvgNamespace = function _checkSvgNamespace2(tagName, parent, parentTagName) {
|
|
713
|
+
if (parent.namespaceURI === HTML_NAMESPACE) {
|
|
714
|
+
return tagName === "svg";
|
|
715
|
+
}
|
|
716
|
+
if (parent.namespaceURI === MATHML_NAMESPACE) {
|
|
717
|
+
return tagName === "svg" && (parentTagName === "annotation-xml" || MATHML_TEXT_INTEGRATION_POINTS[parentTagName]);
|
|
718
|
+
}
|
|
719
|
+
return Boolean(ALL_SVG_TAGS[tagName]);
|
|
720
|
+
};
|
|
721
|
+
const _checkMathMlNamespace = function _checkMathMlNamespace2(tagName, parent, parentTagName) {
|
|
722
|
+
if (parent.namespaceURI === HTML_NAMESPACE) {
|
|
723
|
+
return tagName === "math";
|
|
724
|
+
}
|
|
725
|
+
if (parent.namespaceURI === SVG_NAMESPACE) {
|
|
726
|
+
return tagName === "math" && HTML_INTEGRATION_POINTS[parentTagName];
|
|
727
|
+
}
|
|
728
|
+
return Boolean(ALL_MATHML_TAGS[tagName]);
|
|
729
|
+
};
|
|
730
|
+
const _checkHtmlNamespace = function _checkHtmlNamespace2(tagName, parent, parentTagName) {
|
|
731
|
+
if (parent.namespaceURI === SVG_NAMESPACE && !HTML_INTEGRATION_POINTS[parentTagName]) {
|
|
732
|
+
return false;
|
|
733
|
+
}
|
|
734
|
+
if (parent.namespaceURI === MATHML_NAMESPACE && !MATHML_TEXT_INTEGRATION_POINTS[parentTagName]) {
|
|
735
|
+
return false;
|
|
736
|
+
}
|
|
737
|
+
return !ALL_MATHML_TAGS[tagName] && (COMMON_SVG_AND_HTML_ELEMENTS[tagName] || !ALL_SVG_TAGS[tagName]);
|
|
738
|
+
};
|
|
688
739
|
const _checkValidNamespace = function _checkValidNamespace2(element) {
|
|
689
740
|
let parent = getParentNode(element);
|
|
690
741
|
if (!parent || !parent.tagName) {
|
|
@@ -699,31 +750,13 @@ function createDOMPurify() {
|
|
|
699
750
|
return false;
|
|
700
751
|
}
|
|
701
752
|
if (element.namespaceURI === SVG_NAMESPACE) {
|
|
702
|
-
|
|
703
|
-
return tagName === "svg";
|
|
704
|
-
}
|
|
705
|
-
if (parent.namespaceURI === MATHML_NAMESPACE) {
|
|
706
|
-
return tagName === "svg" && (parentTagName === "annotation-xml" || MATHML_TEXT_INTEGRATION_POINTS[parentTagName]);
|
|
707
|
-
}
|
|
708
|
-
return Boolean(ALL_SVG_TAGS[tagName]);
|
|
753
|
+
return _checkSvgNamespace(tagName, parent, parentTagName);
|
|
709
754
|
}
|
|
710
755
|
if (element.namespaceURI === MATHML_NAMESPACE) {
|
|
711
|
-
|
|
712
|
-
return tagName === "math";
|
|
713
|
-
}
|
|
714
|
-
if (parent.namespaceURI === SVG_NAMESPACE) {
|
|
715
|
-
return tagName === "math" && HTML_INTEGRATION_POINTS[parentTagName];
|
|
716
|
-
}
|
|
717
|
-
return Boolean(ALL_MATHML_TAGS[tagName]);
|
|
756
|
+
return _checkMathMlNamespace(tagName, parent, parentTagName);
|
|
718
757
|
}
|
|
719
758
|
if (element.namespaceURI === HTML_NAMESPACE) {
|
|
720
|
-
|
|
721
|
-
return false;
|
|
722
|
-
}
|
|
723
|
-
if (parent.namespaceURI === MATHML_NAMESPACE && !MATHML_TEXT_INTEGRATION_POINTS[parentTagName]) {
|
|
724
|
-
return false;
|
|
725
|
-
}
|
|
726
|
-
return !ALL_MATHML_TAGS[tagName] && (COMMON_SVG_AND_HTML_ELEMENTS[tagName] || !ALL_SVG_TAGS[tagName]);
|
|
759
|
+
return _checkHtmlNamespace(tagName, parent, parentTagName);
|
|
727
760
|
}
|
|
728
761
|
if (PARSER_MEDIA_TYPE === "application/xhtml+xml" && ALLOWED_NAMESPACES[element.namespaceURI]) {
|
|
729
762
|
return true;
|
|
@@ -744,7 +777,8 @@ function createDOMPurify() {
|
|
|
744
777
|
}
|
|
745
778
|
};
|
|
746
779
|
const _neutralizeRoot = function _neutralizeRoot2(root) {
|
|
747
|
-
|
|
780
|
+
_neutralizeSubtree(root);
|
|
781
|
+
const childNodes = getChildNodes(root);
|
|
748
782
|
if (childNodes) {
|
|
749
783
|
const snapshot = [];
|
|
750
784
|
arrayForEach(childNodes, (child) => {
|
|
@@ -757,7 +791,7 @@ function createDOMPurify() {
|
|
|
757
791
|
}
|
|
758
792
|
});
|
|
759
793
|
}
|
|
760
|
-
const attributes = getAttributes
|
|
794
|
+
const attributes = getAttributes(root);
|
|
761
795
|
if (attributes) {
|
|
762
796
|
for (let i = attributes.length - 1; i >= 0; --i) {
|
|
763
797
|
const attribute = attributes[i];
|
|
@@ -799,7 +833,7 @@ function createDOMPurify() {
|
|
|
799
833
|
}
|
|
800
834
|
};
|
|
801
835
|
const _stripDisallowedAttributes = function _stripDisallowedAttributes2(element) {
|
|
802
|
-
const attributes = getAttributes
|
|
836
|
+
const attributes = getAttributes(element);
|
|
803
837
|
if (!attributes) {
|
|
804
838
|
return;
|
|
805
839
|
}
|
|
@@ -823,7 +857,43 @@ function createDOMPurify() {
|
|
|
823
857
|
if (nodeType === NODE_TYPE.element) {
|
|
824
858
|
_stripDisallowedAttributes(node);
|
|
825
859
|
}
|
|
826
|
-
const childNodes = getChildNodes
|
|
860
|
+
const childNodes = getChildNodes(node);
|
|
861
|
+
if (childNodes) {
|
|
862
|
+
for (let i = childNodes.length - 1; i >= 0; --i) {
|
|
863
|
+
stack.push(childNodes[i]);
|
|
864
|
+
}
|
|
865
|
+
}
|
|
866
|
+
}
|
|
867
|
+
};
|
|
868
|
+
const _neutralizePatchLinkage = function _neutralizePatchLinkage2(root) {
|
|
869
|
+
if (!SAFE_FOR_XML) {
|
|
870
|
+
return;
|
|
871
|
+
}
|
|
872
|
+
const stack = [root];
|
|
873
|
+
while (stack.length > 0) {
|
|
874
|
+
const node = stack.pop();
|
|
875
|
+
const nodeType = getNodeType ? getNodeType(node) : node.nodeType;
|
|
876
|
+
if (nodeType === NODE_TYPE.processingInstruction || nodeType === NODE_TYPE.comment && regExpTest(COMMENT_MARKUP_PROBE, node.data)) {
|
|
877
|
+
try {
|
|
878
|
+
remove(node);
|
|
879
|
+
} catch (_) {
|
|
880
|
+
}
|
|
881
|
+
continue;
|
|
882
|
+
}
|
|
883
|
+
if (nodeType === NODE_TYPE.element) {
|
|
884
|
+
const element = node;
|
|
885
|
+
const lcTag = transformCaseFunc(getNodeName ? getNodeName(node) : node.nodeName);
|
|
886
|
+
try {
|
|
887
|
+
if (element.hasAttribute && element.hasAttribute("patchsrc")) {
|
|
888
|
+
element.removeAttribute("patchsrc");
|
|
889
|
+
}
|
|
890
|
+
if (element.hasAttribute && element.hasAttribute("for") && lcTag !== "label" && lcTag !== "output") {
|
|
891
|
+
element.removeAttribute("for");
|
|
892
|
+
}
|
|
893
|
+
} catch (_) {
|
|
894
|
+
}
|
|
895
|
+
}
|
|
896
|
+
const childNodes = getChildNodes(node);
|
|
827
897
|
if (childNodes) {
|
|
828
898
|
for (let i = childNodes.length - 1; i >= 0; --i) {
|
|
829
899
|
stack.push(childNodes[i]);
|
|
@@ -875,8 +945,14 @@ function createDOMPurify() {
|
|
|
875
945
|
null
|
|
876
946
|
);
|
|
877
947
|
};
|
|
948
|
+
const _stripTemplateExpressions = function _stripTemplateExpressions2(value) {
|
|
949
|
+
value = stringReplace(value, MUSTACHE_EXPR$1, " ");
|
|
950
|
+
value = stringReplace(value, ERB_EXPR$1, " ");
|
|
951
|
+
value = stringReplace(value, TMPLIT_EXPR$1, " ");
|
|
952
|
+
return value;
|
|
953
|
+
};
|
|
878
954
|
const _scrubTemplateExpressions2 = function _scrubTemplateExpressions(node) {
|
|
879
|
-
var _node$querySelectorAl
|
|
955
|
+
var _node$querySelectorAl;
|
|
880
956
|
node.normalize();
|
|
881
957
|
const walker = createNodeIterator.call(
|
|
882
958
|
node.ownerDocument || node,
|
|
@@ -887,19 +963,17 @@ function createDOMPurify() {
|
|
|
887
963
|
);
|
|
888
964
|
let currentNode = walker.nextNode();
|
|
889
965
|
while (currentNode) {
|
|
890
|
-
|
|
891
|
-
arrayForEach([MUSTACHE_EXPR$1, ERB_EXPR$1, TMPLIT_EXPR$1], (expr) => {
|
|
892
|
-
data = stringReplace(data, expr, " ");
|
|
893
|
-
});
|
|
894
|
-
currentNode.data = data;
|
|
966
|
+
currentNode.data = _stripTemplateExpressions(currentNode.data);
|
|
895
967
|
currentNode = walker.nextNode();
|
|
896
968
|
}
|
|
897
|
-
const templates = (_node$querySelectorAl =
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
969
|
+
const templates = (_node$querySelectorAl = node.querySelectorAll) === null || _node$querySelectorAl === void 0 ? void 0 : _node$querySelectorAl.call(node, "template");
|
|
970
|
+
if (templates) {
|
|
971
|
+
arrayForEach(templates, (tmpl) => {
|
|
972
|
+
if (_isDocumentFragment(tmpl.content)) {
|
|
973
|
+
_scrubTemplateExpressions2(tmpl.content);
|
|
974
|
+
}
|
|
975
|
+
});
|
|
976
|
+
}
|
|
903
977
|
};
|
|
904
978
|
const _isClobbered = function _isClobbered2(element) {
|
|
905
979
|
const realTagName = getNodeName ? getNodeName(element) : null;
|
|
@@ -955,13 +1029,56 @@ function createDOMPurify() {
|
|
|
955
1029
|
}
|
|
956
1030
|
};
|
|
957
1031
|
function _executeHooks(hooks2, currentNode, data) {
|
|
1032
|
+
if (hooks2.length === 0) {
|
|
1033
|
+
return;
|
|
1034
|
+
}
|
|
958
1035
|
arrayForEach(hooks2, (hook) => {
|
|
959
1036
|
hook.call(DOMPurify, currentNode, data, CONFIG);
|
|
960
1037
|
});
|
|
961
1038
|
}
|
|
962
|
-
const
|
|
963
|
-
|
|
1039
|
+
const _isUnsafeNode = function _isUnsafeNode2(currentNode, tagName) {
|
|
1040
|
+
if (SAFE_FOR_XML && currentNode.hasChildNodes() && !_isNode(currentNode.firstElementChild) && regExpTest(ELEMENT_MARKUP_PROBE, currentNode.textContent) && regExpTest(ELEMENT_MARKUP_PROBE, currentNode.innerHTML)) {
|
|
1041
|
+
return true;
|
|
1042
|
+
}
|
|
1043
|
+
if (SAFE_FOR_XML && currentNode.namespaceURI === HTML_NAMESPACE && tagName === "style" && _isNode(currentNode.firstElementChild)) {
|
|
1044
|
+
return true;
|
|
1045
|
+
}
|
|
1046
|
+
if (currentNode.nodeType === NODE_TYPE.processingInstruction) {
|
|
1047
|
+
return true;
|
|
1048
|
+
}
|
|
1049
|
+
if (SAFE_FOR_XML && currentNode.nodeType === NODE_TYPE.comment && regExpTest(COMMENT_MARKUP_PROBE, currentNode.data)) {
|
|
1050
|
+
return true;
|
|
1051
|
+
}
|
|
1052
|
+
return false;
|
|
1053
|
+
};
|
|
1054
|
+
const _sanitizeDisallowedNode = function _sanitizeDisallowedNode2(currentNode, tagName) {
|
|
1055
|
+
if (!FORBID_TAGS[tagName] && _isBasicCustomElement(tagName)) {
|
|
1056
|
+
if (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof RegExp && regExpTest(CUSTOM_ELEMENT_HANDLING.tagNameCheck, tagName)) {
|
|
1057
|
+
return false;
|
|
1058
|
+
}
|
|
1059
|
+
if (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof Function && CUSTOM_ELEMENT_HANDLING.tagNameCheck(tagName)) {
|
|
1060
|
+
return false;
|
|
1061
|
+
}
|
|
1062
|
+
}
|
|
1063
|
+
if (KEEP_CONTENT && !FORBID_CONTENTS[tagName]) {
|
|
1064
|
+
const parentNode = getParentNode(currentNode);
|
|
1065
|
+
const childNodes = getChildNodes(currentNode);
|
|
1066
|
+
if (childNodes && parentNode) {
|
|
1067
|
+
const childCount = childNodes.length;
|
|
1068
|
+
for (let i = childCount - 1; i >= 0; --i) {
|
|
1069
|
+
const hoisted = IN_PLACE ? childNodes[i] : cloneNode(childNodes[i], true);
|
|
1070
|
+
parentNode.insertBefore(hoisted, getNextSibling(currentNode));
|
|
1071
|
+
}
|
|
1072
|
+
}
|
|
1073
|
+
}
|
|
1074
|
+
_forceRemove(currentNode);
|
|
1075
|
+
return true;
|
|
1076
|
+
};
|
|
1077
|
+
const _sanitizeElements = function _sanitizeElements2(currentNode, root) {
|
|
964
1078
|
_executeHooks(hooks.beforeSanitizeElements, currentNode, null);
|
|
1079
|
+
if (currentNode !== root && getParentNode(currentNode) === null) {
|
|
1080
|
+
return true;
|
|
1081
|
+
}
|
|
965
1082
|
if (_isClobbered(currentNode)) {
|
|
966
1083
|
_forceRemove(currentNode);
|
|
967
1084
|
return true;
|
|
@@ -971,59 +1088,31 @@ function createDOMPurify() {
|
|
|
971
1088
|
tagName,
|
|
972
1089
|
allowedTags: ALLOWED_TAGS
|
|
973
1090
|
});
|
|
974
|
-
if (
|
|
975
|
-
_forceRemove(currentNode);
|
|
976
|
-
return true;
|
|
977
|
-
}
|
|
978
|
-
if (SAFE_FOR_XML && currentNode.namespaceURI === HTML_NAMESPACE && tagName === "style" && _isNode(currentNode.firstElementChild)) {
|
|
979
|
-
_forceRemove(currentNode);
|
|
980
|
-
return true;
|
|
981
|
-
}
|
|
982
|
-
if (currentNode.nodeType === NODE_TYPE.progressingInstruction) {
|
|
983
|
-
_forceRemove(currentNode);
|
|
1091
|
+
if (currentNode !== root && getParentNode(currentNode) === null) {
|
|
984
1092
|
return true;
|
|
985
1093
|
}
|
|
986
|
-
if (
|
|
1094
|
+
if (_isUnsafeNode(currentNode, tagName)) {
|
|
987
1095
|
_forceRemove(currentNode);
|
|
988
1096
|
return true;
|
|
989
1097
|
}
|
|
990
1098
|
if (FORBID_TAGS[tagName] || !(EXTRA_ELEMENT_HANDLING.tagCheck instanceof Function && EXTRA_ELEMENT_HANDLING.tagCheck(tagName)) && !ALLOWED_TAGS[tagName]) {
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
}
|
|
995
|
-
if (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof Function && CUSTOM_ELEMENT_HANDLING.tagNameCheck(tagName)) {
|
|
996
|
-
return false;
|
|
997
|
-
}
|
|
998
|
-
}
|
|
999
|
-
if (KEEP_CONTENT && !FORBID_CONTENTS[tagName]) {
|
|
1000
|
-
const parentNode = getParentNode(currentNode);
|
|
1001
|
-
const childNodes = getChildNodes(currentNode);
|
|
1002
|
-
if (childNodes && parentNode) {
|
|
1003
|
-
const childCount = childNodes.length;
|
|
1004
|
-
for (let i = childCount - 1; i >= 0; --i) {
|
|
1005
|
-
const hoisted = IN_PLACE ? childNodes[i] : cloneNode(childNodes[i], true);
|
|
1006
|
-
parentNode.insertBefore(hoisted, getNextSibling(currentNode));
|
|
1007
|
-
}
|
|
1008
|
-
}
|
|
1099
|
+
const removed = _sanitizeDisallowedNode(currentNode, tagName);
|
|
1100
|
+
if (removed === false) {
|
|
1101
|
+
_executeHooks(hooks.afterSanitizeElements, currentNode, null);
|
|
1009
1102
|
}
|
|
1010
|
-
|
|
1011
|
-
return true;
|
|
1103
|
+
return removed;
|
|
1012
1104
|
}
|
|
1013
1105
|
const nt = getNodeType ? getNodeType(currentNode) : currentNode.nodeType;
|
|
1014
1106
|
if (nt === NODE_TYPE.element && !_checkValidNamespace(currentNode)) {
|
|
1015
1107
|
_forceRemove(currentNode);
|
|
1016
1108
|
return true;
|
|
1017
1109
|
}
|
|
1018
|
-
if ((tagName === "noscript" || tagName === "noembed" || tagName === "noframes") && regExpTest(
|
|
1110
|
+
if ((tagName === "noscript" || tagName === "noembed" || tagName === "noframes") && regExpTest(FALLBACK_TAG_CLOSE, currentNode.innerHTML)) {
|
|
1019
1111
|
_forceRemove(currentNode);
|
|
1020
1112
|
return true;
|
|
1021
1113
|
}
|
|
1022
1114
|
if (SAFE_FOR_TEMPLATES && currentNode.nodeType === NODE_TYPE.text) {
|
|
1023
|
-
content = currentNode.textContent;
|
|
1024
|
-
arrayForEach([MUSTACHE_EXPR$1, ERB_EXPR$1, TMPLIT_EXPR$1], (expr) => {
|
|
1025
|
-
content = stringReplace(content, expr, " ");
|
|
1026
|
-
});
|
|
1115
|
+
const content = _stripTemplateExpressions(currentNode.textContent);
|
|
1027
1116
|
if (currentNode.textContent !== content) {
|
|
1028
1117
|
arrayPush(DOMPurify.removed, {
|
|
1029
1118
|
element: currentNode.cloneNode()
|
|
@@ -1038,13 +1127,19 @@ function createDOMPurify() {
|
|
|
1038
1127
|
if (FORBID_ATTR[lcName]) {
|
|
1039
1128
|
return false;
|
|
1040
1129
|
}
|
|
1130
|
+
if (SAFE_FOR_XML && lcName === "patchsrc") {
|
|
1131
|
+
return false;
|
|
1132
|
+
}
|
|
1133
|
+
if (SAFE_FOR_XML && lcName === "for" && lcTag !== "label" && lcTag !== "output") {
|
|
1134
|
+
return false;
|
|
1135
|
+
}
|
|
1041
1136
|
if (SANITIZE_DOM && (lcName === "id" || lcName === "name") && (value in document2 || value in formElement)) {
|
|
1042
1137
|
return false;
|
|
1043
1138
|
}
|
|
1044
1139
|
const nameIsPermitted = ALLOWED_ATTR[lcName] || EXTRA_ELEMENT_HANDLING.attributeCheck instanceof Function && EXTRA_ELEMENT_HANDLING.attributeCheck(lcName, lcTag);
|
|
1045
|
-
if (ALLOW_DATA_ATTR &&
|
|
1140
|
+
if (ALLOW_DATA_ATTR && regExpTest(DATA_ATTR$1, lcName)) ;
|
|
1046
1141
|
else if (ALLOW_ARIA_ATTR && regExpTest(ARIA_ATTR$1, lcName)) ;
|
|
1047
|
-
else if (!nameIsPermitted
|
|
1142
|
+
else if (!nameIsPermitted) {
|
|
1048
1143
|
if (
|
|
1049
1144
|
// First condition does a very basic check if a) it's basically a valid custom element tagname AND
|
|
1050
1145
|
// b) if the tagName passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.tagNameCheck
|
|
@@ -1069,6 +1164,35 @@ function createDOMPurify() {
|
|
|
1069
1164
|
const _isBasicCustomElement = function _isBasicCustomElement2(tagName) {
|
|
1070
1165
|
return !RESERVED_CUSTOM_ELEMENT_NAMES[stringToLowerCase(tagName)] && regExpTest(CUSTOM_ELEMENT$1, tagName);
|
|
1071
1166
|
};
|
|
1167
|
+
const _applyTrustedTypesToAttribute = function _applyTrustedTypesToAttribute2(lcTag, lcName, namespaceURI, value) {
|
|
1168
|
+
if (trustedTypesPolicy && typeof trustedTypes === "object" && typeof trustedTypes.getAttributeType === "function" && !namespaceURI) {
|
|
1169
|
+
switch (trustedTypes.getAttributeType(lcTag, lcName)) {
|
|
1170
|
+
case "TrustedHTML": {
|
|
1171
|
+
return _createTrustedHTML(value);
|
|
1172
|
+
}
|
|
1173
|
+
case "TrustedScriptURL": {
|
|
1174
|
+
return _createTrustedScriptURL(value);
|
|
1175
|
+
}
|
|
1176
|
+
}
|
|
1177
|
+
}
|
|
1178
|
+
return value;
|
|
1179
|
+
};
|
|
1180
|
+
const _setAttributeValue = function _setAttributeValue2(currentNode, name, namespaceURI, value) {
|
|
1181
|
+
try {
|
|
1182
|
+
if (namespaceURI) {
|
|
1183
|
+
currentNode.setAttributeNS(namespaceURI, name, value);
|
|
1184
|
+
} else {
|
|
1185
|
+
currentNode.setAttribute(name, value);
|
|
1186
|
+
}
|
|
1187
|
+
if (_isClobbered(currentNode)) {
|
|
1188
|
+
_forceRemove(currentNode);
|
|
1189
|
+
} else {
|
|
1190
|
+
arrayPop(DOMPurify.removed);
|
|
1191
|
+
}
|
|
1192
|
+
} catch (_) {
|
|
1193
|
+
_removeAttribute(name, currentNode);
|
|
1194
|
+
}
|
|
1195
|
+
};
|
|
1072
1196
|
const _sanitizeAttributes = function _sanitizeAttributes2(currentNode) {
|
|
1073
1197
|
_executeHooks(hooks.beforeSanitizeAttributes, currentNode, null);
|
|
1074
1198
|
const attributes = currentNode.attributes;
|
|
@@ -1083,6 +1207,7 @@ function createDOMPurify() {
|
|
|
1083
1207
|
forceKeepAttr: void 0
|
|
1084
1208
|
};
|
|
1085
1209
|
let l = attributes.length;
|
|
1210
|
+
const lcTag = transformCaseFunc(currentNode.nodeName);
|
|
1086
1211
|
while (l--) {
|
|
1087
1212
|
const attr = attributes[l];
|
|
1088
1213
|
const name = attr.name, namespaceURI = attr.namespaceURI, attrValue = attr.value;
|
|
@@ -1114,50 +1239,20 @@ function createDOMPurify() {
|
|
|
1114
1239
|
_removeAttribute(name, currentNode);
|
|
1115
1240
|
continue;
|
|
1116
1241
|
}
|
|
1117
|
-
if (!ALLOW_SELF_CLOSE_IN_ATTR && regExpTest(
|
|
1242
|
+
if (!ALLOW_SELF_CLOSE_IN_ATTR && regExpTest(SELF_CLOSING_TAG, value)) {
|
|
1118
1243
|
_removeAttribute(name, currentNode);
|
|
1119
1244
|
continue;
|
|
1120
1245
|
}
|
|
1121
1246
|
if (SAFE_FOR_TEMPLATES) {
|
|
1122
|
-
|
|
1123
|
-
value = stringReplace(value, expr, " ");
|
|
1124
|
-
});
|
|
1247
|
+
value = _stripTemplateExpressions(value);
|
|
1125
1248
|
}
|
|
1126
|
-
const lcTag = transformCaseFunc(currentNode.nodeName);
|
|
1127
1249
|
if (!_isValidAttribute(lcTag, lcName, value)) {
|
|
1128
1250
|
_removeAttribute(name, currentNode);
|
|
1129
1251
|
continue;
|
|
1130
1252
|
}
|
|
1131
|
-
|
|
1132
|
-
if (namespaceURI) ;
|
|
1133
|
-
else {
|
|
1134
|
-
switch (trustedTypes.getAttributeType(lcTag, lcName)) {
|
|
1135
|
-
case "TrustedHTML": {
|
|
1136
|
-
value = _createTrustedHTML(value);
|
|
1137
|
-
break;
|
|
1138
|
-
}
|
|
1139
|
-
case "TrustedScriptURL": {
|
|
1140
|
-
value = _createTrustedScriptURL(value);
|
|
1141
|
-
break;
|
|
1142
|
-
}
|
|
1143
|
-
}
|
|
1144
|
-
}
|
|
1145
|
-
}
|
|
1253
|
+
value = _applyTrustedTypesToAttribute(lcTag, lcName, namespaceURI, value);
|
|
1146
1254
|
if (value !== initValue) {
|
|
1147
|
-
|
|
1148
|
-
if (namespaceURI) {
|
|
1149
|
-
currentNode.setAttributeNS(namespaceURI, name, value);
|
|
1150
|
-
} else {
|
|
1151
|
-
currentNode.setAttribute(name, value);
|
|
1152
|
-
}
|
|
1153
|
-
if (_isClobbered(currentNode)) {
|
|
1154
|
-
_forceRemove(currentNode);
|
|
1155
|
-
} else {
|
|
1156
|
-
arrayPop(DOMPurify.removed);
|
|
1157
|
-
}
|
|
1158
|
-
} catch (_) {
|
|
1159
|
-
_removeAttribute(name, currentNode);
|
|
1160
|
-
}
|
|
1255
|
+
_setAttributeValue(currentNode, name, namespaceURI, value);
|
|
1161
1256
|
}
|
|
1162
1257
|
}
|
|
1163
1258
|
_executeHooks(hooks.afterSanitizeAttributes, currentNode, null);
|
|
@@ -1168,14 +1263,14 @@ function createDOMPurify() {
|
|
|
1168
1263
|
_executeHooks(hooks.beforeSanitizeShadowDOM, fragment, null);
|
|
1169
1264
|
while (shadowNode = shadowIterator.nextNode()) {
|
|
1170
1265
|
_executeHooks(hooks.uponSanitizeShadowNode, shadowNode, null);
|
|
1171
|
-
_sanitizeElements(shadowNode);
|
|
1266
|
+
_sanitizeElements(shadowNode, fragment);
|
|
1172
1267
|
_sanitizeAttributes(shadowNode);
|
|
1173
1268
|
if (_isDocumentFragment(shadowNode.content)) {
|
|
1174
1269
|
_sanitizeShadowDOM2(shadowNode.content);
|
|
1175
1270
|
}
|
|
1176
1271
|
const shadowNodeType = getNodeType ? getNodeType(shadowNode) : shadowNode.nodeType;
|
|
1177
1272
|
if (shadowNodeType === NODE_TYPE.element) {
|
|
1178
|
-
const innerSr = getShadowRoot
|
|
1273
|
+
const innerSr = getShadowRoot(shadowNode);
|
|
1179
1274
|
if (_isDocumentFragment(innerSr)) {
|
|
1180
1275
|
_sanitizeAttachedShadowRoots(innerSr);
|
|
1181
1276
|
_sanitizeShadowDOM2(innerSr);
|
|
@@ -1198,7 +1293,7 @@ function createDOMPurify() {
|
|
|
1198
1293
|
const node = item.node;
|
|
1199
1294
|
const nodeType = getNodeType ? getNodeType(node) : node.nodeType;
|
|
1200
1295
|
const isElement = nodeType === NODE_TYPE.element;
|
|
1201
|
-
const childNodes = getChildNodes
|
|
1296
|
+
const childNodes = getChildNodes(node);
|
|
1202
1297
|
if (childNodes) {
|
|
1203
1298
|
for (let i = childNodes.length - 1; i >= 0; --i) {
|
|
1204
1299
|
stack.push({
|
|
@@ -1220,7 +1315,7 @@ function createDOMPurify() {
|
|
|
1220
1315
|
}
|
|
1221
1316
|
}
|
|
1222
1317
|
if (isElement) {
|
|
1223
|
-
const sr = getShadowRoot
|
|
1318
|
+
const sr = getShadowRoot(node);
|
|
1224
1319
|
if (_isDocumentFragment(sr)) {
|
|
1225
1320
|
stack.push({
|
|
1226
1321
|
node: null,
|
|
@@ -1252,20 +1347,32 @@ function createDOMPurify() {
|
|
|
1252
1347
|
if (!DOMPurify.isSupported) {
|
|
1253
1348
|
return dirty;
|
|
1254
1349
|
}
|
|
1255
|
-
if (
|
|
1350
|
+
if (SET_CONFIG) {
|
|
1351
|
+
ALLOWED_TAGS = SET_CONFIG_ALLOWED_TAGS;
|
|
1352
|
+
ALLOWED_ATTR = SET_CONFIG_ALLOWED_ATTR;
|
|
1353
|
+
} else {
|
|
1256
1354
|
_parseConfig(cfg);
|
|
1257
1355
|
}
|
|
1356
|
+
if (hooks.uponSanitizeElement.length > 0 || hooks.uponSanitizeAttribute.length > 0) {
|
|
1357
|
+
ALLOWED_TAGS = clone(ALLOWED_TAGS);
|
|
1358
|
+
}
|
|
1359
|
+
if (hooks.uponSanitizeAttribute.length > 0) {
|
|
1360
|
+
ALLOWED_ATTR = clone(ALLOWED_ATTR);
|
|
1361
|
+
}
|
|
1258
1362
|
DOMPurify.removed = [];
|
|
1259
1363
|
const inPlace = IN_PLACE && typeof dirty !== "string" && _isNode(dirty);
|
|
1260
1364
|
if (inPlace) {
|
|
1365
|
+
_neutralizePatchLinkage(dirty);
|
|
1261
1366
|
const nn = getNodeName ? getNodeName(dirty) : dirty.nodeName;
|
|
1262
1367
|
if (typeof nn === "string") {
|
|
1263
1368
|
const tagName = transformCaseFunc(nn);
|
|
1264
1369
|
if (!ALLOWED_TAGS[tagName] || FORBID_TAGS[tagName]) {
|
|
1370
|
+
_neutralizeRoot(dirty);
|
|
1265
1371
|
throw typeErrorCreate("root node is forbidden and cannot be sanitized in-place");
|
|
1266
1372
|
}
|
|
1267
1373
|
}
|
|
1268
1374
|
if (_isClobbered(dirty)) {
|
|
1375
|
+
_neutralizeRoot(dirty);
|
|
1269
1376
|
throw typeErrorCreate("root node is clobbered and cannot be sanitized in-place");
|
|
1270
1377
|
}
|
|
1271
1378
|
try {
|
|
@@ -1298,10 +1405,11 @@ function createDOMPurify() {
|
|
|
1298
1405
|
if (body && FORCE_BODY) {
|
|
1299
1406
|
_forceRemove(body.firstChild);
|
|
1300
1407
|
}
|
|
1301
|
-
const
|
|
1408
|
+
const walkRoot = inPlace ? dirty : body;
|
|
1409
|
+
const nodeIterator = _createNodeIterator(walkRoot);
|
|
1302
1410
|
try {
|
|
1303
1411
|
while (currentNode = nodeIterator.nextNode()) {
|
|
1304
|
-
_sanitizeElements(currentNode);
|
|
1412
|
+
_sanitizeElements(currentNode, walkRoot);
|
|
1305
1413
|
_sanitizeAttributes(currentNode);
|
|
1306
1414
|
if (_isDocumentFragment(currentNode.content)) {
|
|
1307
1415
|
_sanitizeShadowDOM2(currentNode.content);
|
|
@@ -1310,6 +1418,11 @@ function createDOMPurify() {
|
|
|
1310
1418
|
} catch (error) {
|
|
1311
1419
|
if (inPlace) {
|
|
1312
1420
|
_neutralizeRoot(dirty);
|
|
1421
|
+
arrayForEach(DOMPurify.removed, (entry) => {
|
|
1422
|
+
if (entry.element) {
|
|
1423
|
+
_neutralizeSubtree(entry.element);
|
|
1424
|
+
}
|
|
1425
|
+
});
|
|
1313
1426
|
}
|
|
1314
1427
|
throw error;
|
|
1315
1428
|
}
|
|
@@ -1346,9 +1459,7 @@ function createDOMPurify() {
|
|
|
1346
1459
|
serializedHTML = "<!DOCTYPE " + body.ownerDocument.doctype.name + ">\n" + serializedHTML;
|
|
1347
1460
|
}
|
|
1348
1461
|
if (SAFE_FOR_TEMPLATES) {
|
|
1349
|
-
|
|
1350
|
-
serializedHTML = stringReplace(serializedHTML, expr, " ");
|
|
1351
|
-
});
|
|
1462
|
+
serializedHTML = _stripTemplateExpressions(serializedHTML);
|
|
1352
1463
|
}
|
|
1353
1464
|
return trustedTypesPolicy && RETURN_TRUSTED_TYPE ? _createTrustedHTML(serializedHTML) : serializedHTML;
|
|
1354
1465
|
};
|
|
@@ -1356,10 +1467,14 @@ function createDOMPurify() {
|
|
|
1356
1467
|
let cfg = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
|
1357
1468
|
_parseConfig(cfg);
|
|
1358
1469
|
SET_CONFIG = true;
|
|
1470
|
+
SET_CONFIG_ALLOWED_TAGS = ALLOWED_TAGS;
|
|
1471
|
+
SET_CONFIG_ALLOWED_ATTR = ALLOWED_ATTR;
|
|
1359
1472
|
};
|
|
1360
1473
|
DOMPurify.clearConfig = function() {
|
|
1361
1474
|
CONFIG = null;
|
|
1362
1475
|
SET_CONFIG = false;
|
|
1476
|
+
SET_CONFIG_ALLOWED_TAGS = null;
|
|
1477
|
+
SET_CONFIG_ALLOWED_ATTR = null;
|
|
1363
1478
|
trustedTypesPolicy = defaultTrustedTypesPolicy;
|
|
1364
1479
|
emptyHTML = "";
|
|
1365
1480
|
};
|
|
@@ -1375,9 +1490,15 @@ function createDOMPurify() {
|
|
|
1375
1490
|
if (typeof hookFunction !== "function") {
|
|
1376
1491
|
return;
|
|
1377
1492
|
}
|
|
1493
|
+
if (!objectHasOwnProperty(hooks, entryPoint)) {
|
|
1494
|
+
return;
|
|
1495
|
+
}
|
|
1378
1496
|
arrayPush(hooks[entryPoint], hookFunction);
|
|
1379
1497
|
};
|
|
1380
1498
|
DOMPurify.removeHook = function(entryPoint, hookFunction) {
|
|
1499
|
+
if (!objectHasOwnProperty(hooks, entryPoint)) {
|
|
1500
|
+
return void 0;
|
|
1501
|
+
}
|
|
1381
1502
|
if (hookFunction !== void 0) {
|
|
1382
1503
|
const index = arrayLastIndexOf(hooks[entryPoint], hookFunction);
|
|
1383
1504
|
return index === -1 ? void 0 : arraySplice(hooks[entryPoint], index, 1)[0];
|
|
@@ -1385,6 +1506,9 @@ function createDOMPurify() {
|
|
|
1385
1506
|
return arrayPop(hooks[entryPoint]);
|
|
1386
1507
|
};
|
|
1387
1508
|
DOMPurify.removeHooks = function(entryPoint) {
|
|
1509
|
+
if (!objectHasOwnProperty(hooks, entryPoint)) {
|
|
1510
|
+
return;
|
|
1511
|
+
}
|
|
1388
1512
|
hooks[entryPoint] = [];
|
|
1389
1513
|
};
|
|
1390
1514
|
DOMPurify.removeAllHooks = function() {
|
|
@@ -1407,9 +1531,10 @@ function sanitizeBannerHtml(html2) {
|
|
|
1407
1531
|
ALLOW_DATA_ATTR: false
|
|
1408
1532
|
});
|
|
1409
1533
|
}
|
|
1410
|
-
function resolveCssToken(token) {
|
|
1534
|
+
function resolveCssToken(token, preferredScope) {
|
|
1411
1535
|
const normalizedToken = token.startsWith("--") ? token : `--${token}`;
|
|
1412
1536
|
const candidates = [
|
|
1537
|
+
preferredScope,
|
|
1413
1538
|
document.documentElement,
|
|
1414
1539
|
document.body,
|
|
1415
1540
|
...Array.from(
|
|
@@ -1429,32 +1554,33 @@ function resolveCssToken(token) {
|
|
|
1429
1554
|
)
|
|
1430
1555
|
)
|
|
1431
1556
|
].filter(Boolean);
|
|
1557
|
+
const checked = /* @__PURE__ */ new Set();
|
|
1432
1558
|
for (const node of candidates) {
|
|
1559
|
+
if (checked.has(node)) continue;
|
|
1560
|
+
checked.add(node);
|
|
1433
1561
|
const value = getComputedStyle(node).getPropertyValue(normalizedToken).trim();
|
|
1434
1562
|
if (value) return value;
|
|
1435
1563
|
}
|
|
1436
1564
|
for (const node of Array.from(document.querySelectorAll("*"))) {
|
|
1565
|
+
if (checked.has(node)) continue;
|
|
1437
1566
|
const value = getComputedStyle(node).getPropertyValue(normalizedToken).trim();
|
|
1438
1567
|
if (value) return value;
|
|
1439
1568
|
}
|
|
1440
1569
|
return void 0;
|
|
1441
1570
|
}
|
|
1442
|
-
|
|
1571
|
+
function safeColor(v, preferredScope) {
|
|
1443
1572
|
if (!v) return void 0;
|
|
1444
1573
|
const value = v.trim();
|
|
1445
1574
|
if (/^(#|rgb|hsl)/i.test(value)) return value;
|
|
1446
1575
|
if (/^(--)?[a-z0-9-]+$/i.test(value)) {
|
|
1447
|
-
|
|
1448
|
-
return resolved;
|
|
1576
|
+
return resolveCssToken(value, preferredScope);
|
|
1449
1577
|
}
|
|
1450
1578
|
const varMatch = value.match(/^var\((--[a-z0-9-]+)\)$/i);
|
|
1451
1579
|
if (varMatch) {
|
|
1452
|
-
|
|
1453
|
-
const resolved = resolveCssToken(token);
|
|
1454
|
-
return resolved;
|
|
1580
|
+
return resolveCssToken(varMatch[1], preferredScope);
|
|
1455
1581
|
}
|
|
1456
1582
|
return void 0;
|
|
1457
|
-
}
|
|
1583
|
+
}
|
|
1458
1584
|
function el(tag, styles, attrs) {
|
|
1459
1585
|
const node = document.createElement(tag);
|
|
1460
1586
|
Object.assign(node.style, styles);
|
|
@@ -1538,15 +1664,15 @@ function justifyFromTextAlign(align) {
|
|
|
1538
1664
|
if (align === "right") return "flex-end";
|
|
1539
1665
|
return "flex-start";
|
|
1540
1666
|
}
|
|
1541
|
-
function renderBanner(banner, handlers) {
|
|
1667
|
+
function renderBanner(banner, handlers, colorScope) {
|
|
1542
1668
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n;
|
|
1543
1669
|
const placement = banner.placement || {};
|
|
1544
1670
|
const mode = placement.mode || "overlay";
|
|
1545
1671
|
const position = placement.position || "top";
|
|
1546
1672
|
const zIndex = String(placement.zIndex || 2147483e3);
|
|
1547
1673
|
const imageBanner = isImageBanner(banner);
|
|
1548
|
-
const bg = imageBanner ? "transparent" : safeColor((_a = banner.style) == null ? void 0 : _a.backgroundColor) || "#1f2024";
|
|
1549
|
-
const color = safeColor((_b = banner.style) == null ? void 0 : _b.color) || "#ffffff";
|
|
1674
|
+
const bg = imageBanner ? "transparent" : safeColor((_a = banner.style) == null ? void 0 : _a.backgroundColor, colorScope) || "#1f2024";
|
|
1675
|
+
const color = safeColor((_b = banner.style) == null ? void 0 : _b.color, colorScope) || "#ffffff";
|
|
1550
1676
|
const isCard = mode === "overlay" || mode === "popup";
|
|
1551
1677
|
const ctaPosition = getCtaStyleValue(banner, ["position"]) || "center";
|
|
1552
1678
|
const imageHorizontal = imageAlign((_c = banner.image) == null ? void 0 : _c.horizontalAlignment);
|
|
@@ -1687,9 +1813,13 @@ function renderBanner(banner, handlers) {
|
|
|
1687
1813
|
}
|
|
1688
1814
|
if (!imageBanner && ((_n = banner.cta) == null ? void 0 : _n.enabled)) {
|
|
1689
1815
|
const ctaBg = safeColor(
|
|
1690
|
-
getCtaStyleValue(banner, ["backgroundColor", "buttonColor", "aColor"])
|
|
1816
|
+
getCtaStyleValue(banner, ["backgroundColor", "buttonColor", "aColor"]),
|
|
1817
|
+
colorScope
|
|
1691
1818
|
) || "#2f6df6";
|
|
1692
|
-
const ctaColor = safeColor(
|
|
1819
|
+
const ctaColor = safeColor(
|
|
1820
|
+
getCtaStyleValue(banner, ["textColor", "color"]),
|
|
1821
|
+
colorScope
|
|
1822
|
+
) || "#ffffff";
|
|
1693
1823
|
const btn = el("button", {
|
|
1694
1824
|
cursor: "pointer",
|
|
1695
1825
|
border: "none",
|
|
@@ -1875,23 +2005,27 @@ class BannerRuntime extends HTMLElement {
|
|
|
1875
2005
|
mount(banner) {
|
|
1876
2006
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
1877
2007
|
if (!this.isConnected) return;
|
|
1878
|
-
const node = renderBanner(
|
|
1879
|
-
|
|
1880
|
-
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
|
|
2008
|
+
const node = renderBanner(
|
|
2009
|
+
banner,
|
|
2010
|
+
{
|
|
2011
|
+
onCtaClick: () => {
|
|
2012
|
+
var _a2, _b2, _c2;
|
|
2013
|
+
fireTracking((_a2 = banner.tracking) == null ? void 0 : _a2.clickUrl);
|
|
2014
|
+
this.dispatch("rai-banner-click", { bannerId: banner.id });
|
|
2015
|
+
const u = (_b2 = banner.cta) == null ? void 0 : _b2.url;
|
|
2016
|
+
if (!u) return;
|
|
2017
|
+
if ((_c2 = banner.cta) == null ? void 0 : _c2.openInNewTab) window.open(u, "_blank", "noopener,noreferrer");
|
|
2018
|
+
else window.location.href = u;
|
|
2019
|
+
},
|
|
2020
|
+
onDismiss: () => {
|
|
2021
|
+
var _a2;
|
|
2022
|
+
fireTracking((_a2 = banner.tracking) == null ? void 0 : _a2.dismissUrl);
|
|
2023
|
+
this.dispatch("rai-banner-dismiss", { bannerId: banner.id });
|
|
2024
|
+
this.cleanup();
|
|
2025
|
+
}
|
|
1887
2026
|
},
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
fireTracking((_a2 = banner.tracking) == null ? void 0 : _a2.dismissUrl);
|
|
1891
|
-
this.dispatch("rai-banner-dismiss", { bannerId: banner.id });
|
|
1892
|
-
this.cleanup();
|
|
1893
|
-
}
|
|
1894
|
-
});
|
|
2027
|
+
this
|
|
2028
|
+
);
|
|
1895
2029
|
this.rendered = node;
|
|
1896
2030
|
const isCard = ((_a = banner.placement) == null ? void 0 : _a.mode) === "overlay" || ((_b = banner.placement) == null ? void 0 : _b.mode) === "popup";
|
|
1897
2031
|
if (isCard) {
|
|
@@ -1927,7 +2061,7 @@ class BannerRuntime extends HTMLElement {
|
|
|
1927
2061
|
this.dispatchEvent(new CustomEvent(name, { detail, bubbles: true, composed: true }));
|
|
1928
2062
|
}
|
|
1929
2063
|
}
|
|
1930
|
-
console.log(`[rai-banner] v${"1.
|
|
2064
|
+
console.log(`[rai-banner] v${"1.8.0"}`);
|
|
1931
2065
|
if (typeof customElements !== "undefined" && !customElements.get("rai-banner")) {
|
|
1932
2066
|
customElements.define("rai-banner", BannerRuntime);
|
|
1933
2067
|
}
|