@fairfox/polly 0.85.1 → 0.86.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/dist/cli/polly.js.map +1 -1
- package/dist/gallery/gallery.css +1 -1
- package/dist/gallery/gallery.js +2 -27
- package/dist/scripts/build-extension.js.map +1 -1
- package/dist/src/actions/index.js +34 -32
- package/dist/src/actions/index.js.map +2 -2
- package/dist/src/background/index.js +24 -22
- package/dist/src/background/index.js.map +2 -2
- package/dist/src/background/message-router.js +21 -19
- package/dist/src/background/message-router.js.map +2 -2
- package/dist/src/client/index.js +9 -7
- package/dist/src/client/index.js.map +3 -3
- package/dist/src/client/wrapper.d.ts +3 -3
- package/dist/src/elysia/index.d.ts +1 -1
- package/dist/src/elysia/index.js +25 -23
- package/dist/src/elysia/index.js.map +2 -2
- package/dist/src/elysia/types.d.ts +11 -2
- package/dist/src/index.js +68 -64
- package/dist/src/index.js.map +3 -3
- package/dist/src/mesh-node.js +6 -6
- package/dist/src/mesh-node.js.map +1 -1
- package/dist/src/mesh.js +92 -90
- package/dist/src/mesh.js.map +2 -2
- package/dist/src/peer.js +83 -52
- package/dist/src/peer.js.map +3 -3
- package/dist/src/polly-ui/index.css +1 -1
- package/dist/src/polly-ui/index.js +37 -35
- package/dist/src/polly-ui/index.js.map +2 -2
- package/dist/src/polly-ui/markdown.js +233 -96
- package/dist/src/polly-ui/markdown.js.map +4 -4
- package/dist/src/polly-ui/styles.css +1 -1
- package/dist/src/shared/adapters/index.js +30 -28
- package/dist/src/shared/adapters/index.js.map +2 -2
- package/dist/src/shared/lib/context-helpers.js +23 -21
- package/dist/src/shared/lib/context-helpers.js.map +2 -2
- package/dist/src/shared/lib/errors.js +16 -14
- package/dist/src/shared/lib/errors.js.map +2 -2
- package/dist/src/shared/lib/guards.js +11 -9
- package/dist/src/shared/lib/guards.js.map +2 -2
- package/dist/src/shared/lib/message-bus.js +24 -22
- package/dist/src/shared/lib/message-bus.js.map +2 -2
- package/dist/src/shared/lib/peer-relay-adapter.d.ts +6 -0
- package/dist/src/shared/lib/resource.js +19 -15
- package/dist/src/shared/lib/resource.js.map +3 -3
- package/dist/src/shared/lib/state.js +26 -22
- package/dist/src/shared/lib/state.js.map +3 -3
- package/dist/src/shared/lib/test-helpers.js +11 -9
- package/dist/src/shared/lib/test-helpers.js.map +2 -2
- package/dist/src/shared/state/app-state.js +22 -18
- package/dist/src/shared/state/app-state.js.map +3 -3
- package/dist/src/shared/types/messages.js +11 -9
- package/dist/src/shared/types/messages.js.map +2 -2
- package/dist/tools/bdd/src/cli.js +44 -1
- package/dist/tools/bdd/src/cli.js.map +4 -4
- package/dist/tools/bdd/src/index.js +54 -11
- package/dist/tools/bdd/src/index.js.map +4 -4
- package/dist/tools/gallery/src/cli.js +1 -1
- package/dist/tools/gallery/src/cli.js.map +2 -2
- package/dist/tools/init/src/cli.js +1 -1
- package/dist/tools/init/src/cli.js.map +2 -2
- package/dist/tools/mutate/src/cli.js +1 -1
- package/dist/tools/mutate/src/cli.js.map +2 -2
- package/dist/tools/mutate/src/index.js +8 -8
- package/dist/tools/mutate/src/index.js.map +2 -2
- package/dist/tools/quality/src/cli.js +3 -2
- package/dist/tools/quality/src/cli.js.map +3 -3
- package/dist/tools/quality/src/index.js +37 -36
- package/dist/tools/quality/src/index.js.map +3 -3
- package/dist/tools/test/src/adapters/index.js +19 -17
- package/dist/tools/test/src/adapters/index.js.map +2 -2
- package/dist/tools/test/src/browser/index.js +15 -13
- package/dist/tools/test/src/browser/index.js.map +2 -2
- package/dist/tools/test/src/browser/run.js +12 -3
- package/dist/tools/test/src/browser/run.js.map +5 -4
- package/dist/tools/test/src/contrast/index.js +14 -12
- package/dist/tools/test/src/contrast/index.js.map +2 -2
- package/dist/tools/test/src/coverage-policy/cli.js +5 -5
- package/dist/tools/test/src/coverage-policy/cli.js.map +2 -2
- package/dist/tools/test/src/coverage-policy/index.js +12 -12
- package/dist/tools/test/src/coverage-policy/index.js.map +1 -1
- package/dist/tools/test/src/e2e-mesh/index.js +88 -50
- package/dist/tools/test/src/e2e-mesh/index.js.map +6 -5
- package/dist/tools/test/src/e2e-mesh/with-relay.d.ts +1 -1
- package/dist/tools/test/src/e2e-relay/index.js +3 -3
- package/dist/tools/test/src/e2e-relay/index.js.map +2 -2
- package/dist/tools/test/src/e2e-shared/ephemeral-port.d.ts +73 -0
- package/dist/tools/test/src/e2e-shared/index.d.ts +1 -0
- package/dist/tools/test/src/index.d.ts +1 -0
- package/dist/tools/test/src/index.js +68 -24
- package/dist/tools/test/src/index.js.map +4 -3
- package/dist/tools/test/src/test-utils.js +14 -12
- package/dist/tools/test/src/test-utils.js.map +2 -2
- package/dist/tools/test/src/tiers/budget.d.ts +32 -0
- package/dist/tools/test/src/tiers/cli.js +35 -5
- package/dist/tools/test/src/tiers/cli.js.map +6 -5
- package/dist/tools/test/src/tiers/index.d.ts +1 -0
- package/dist/tools/test/src/tiers/reporter.d.ts +0 -5
- package/dist/tools/test/src/tiers/types.d.ts +9 -0
- package/dist/tools/test/src/tiers/worker.js +1 -1
- package/dist/tools/test/src/tiers/worker.js.map +1 -1
- package/dist/tools/test/src/visual/index.js +121 -119
- package/dist/tools/test/src/visual/index.js.map +2 -2
- package/dist/tools/verify/specs/README.md +18 -0
- package/dist/tools/verify/specs/tla/MeshState.cfg +1 -1
- package/dist/tools/verify/specs/tla/MeshState.tla +7 -0
- package/dist/tools/verify/specs/tla/MessageRouter.cfg +4 -2
- package/dist/tools/verify/specs/tla/MessageRouter.tla +45 -10
- package/dist/tools/verify/specs/tla/PeerState.cfg +1 -1
- package/dist/tools/verify/specs/tla/PeerState.tla +7 -0
- package/dist/tools/verify/specs/tla/README.md +1 -1
- package/dist/tools/verify/src/cli.js +258 -202
- package/dist/tools/verify/src/cli.js.map +12 -11
- package/dist/tools/verify/src/config.d.ts +25 -0
- package/dist/tools/verify/src/config.js +18 -16
- package/dist/tools/verify/src/config.js.map +3 -3
- package/dist/tools/verify/src/stryker/index.js +6 -6
- package/dist/tools/verify/src/stryker/index.js.map +1 -1
- package/dist/tools/visualize/src/cli.js +439 -47
- package/dist/tools/visualize/src/cli.js.map +7 -5
- package/package.json +2 -2
|
@@ -19,12 +19,14 @@ var __toESM = (mod, isNodeMode, target) => {
|
|
|
19
19
|
}
|
|
20
20
|
target = mod != null ? __create(__getProtoOf(mod)) : {};
|
|
21
21
|
const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
22
|
+
if (mod && typeof mod === "object" || typeof mod === "function") {
|
|
23
|
+
for (let key of __getOwnPropNames(mod))
|
|
24
|
+
if (!__hasOwnProp.call(to, key))
|
|
25
|
+
__defProp(to, key, {
|
|
26
|
+
get: __accessProp.bind(mod, key),
|
|
27
|
+
enumerable: true
|
|
28
|
+
});
|
|
29
|
+
}
|
|
28
30
|
if (canCache)
|
|
29
31
|
cache.set(mod, to);
|
|
30
32
|
return to;
|
|
@@ -69,8 +71,8 @@ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require
|
|
|
69
71
|
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
70
72
|
});
|
|
71
73
|
|
|
72
|
-
// ../../node_modules/.bun/dompurify@3.4.
|
|
73
|
-
/*! @license DOMPurify 3.4.
|
|
74
|
+
// ../../node_modules/.bun/dompurify@3.4.14/node_modules/dompurify/dist/purify.es.mjs
|
|
75
|
+
/*! @license DOMPurify 3.4.14 | (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.14/LICENSE */
|
|
74
76
|
function _arrayLikeToArray(r, a) {
|
|
75
77
|
(a == null || a > r.length) && (a = r.length);
|
|
76
78
|
for (var e = 0, n = Array(a);e < a; e++)
|
|
@@ -320,7 +322,7 @@ var mathMl$1 = freeze(["math", "menclose", "merror", "mfenced", "mfrac", "mglyph
|
|
|
320
322
|
var mathMlDisallowed = freeze(["maction", "maligngroup", "malignmark", "mlongdiv", "mscarries", "mscarry", "msgroup", "mstack", "msline", "msrow", "semantics", "annotation", "annotation-xml", "mprescripts", "none"]);
|
|
321
323
|
var text = freeze(["#text"]);
|
|
322
324
|
var 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"]);
|
|
323
|
-
var 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"]);
|
|
325
|
+
var 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", "pointer-events", "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", "vector-effect", "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"]);
|
|
324
326
|
var 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"]);
|
|
325
327
|
var xml = freeze(["xlink:href", "xml:id", "xlink:title", "xml:space", "xmlns:xlink"]);
|
|
326
328
|
var MUSTACHE_EXPR = seal(/{{[\w\W]*|^[\w\W]*}}/g);
|
|
@@ -351,6 +353,15 @@ var NODE_TYPE = {
|
|
|
351
353
|
documentFragment: 11,
|
|
352
354
|
notation: 12
|
|
353
355
|
};
|
|
356
|
+
var LITERAL_TEXT_ELEMENT_NAMES = ["style", "script", "xmp", "iframe", "noembed", "noframes", "plaintext", "noscript"];
|
|
357
|
+
var LITERAL_TEXT_ELEMENTS = freeze(addToSet({}, LITERAL_TEXT_ELEMENT_NAMES));
|
|
358
|
+
var LITERAL_TEXT_CLOSE = function() {
|
|
359
|
+
const map = {};
|
|
360
|
+
arrayForEach(LITERAL_TEXT_ELEMENT_NAMES, (name) => {
|
|
361
|
+
map[name] = seal(new RegExp("</" + name + "(?=[\\t\\n\\f\\r />])", "i"));
|
|
362
|
+
});
|
|
363
|
+
return freeze(map);
|
|
364
|
+
}();
|
|
354
365
|
var getGlobal = function getGlobal2() {
|
|
355
366
|
return typeof window === "undefined" ? null : window;
|
|
356
367
|
};
|
|
@@ -394,10 +405,14 @@ var _createHooksMap = function _createHooksMap2() {
|
|
|
394
405
|
var _resolveSetOption = function _resolveSetOption2(cfg, key, fallback, options) {
|
|
395
406
|
return objectHasOwnProperty(cfg, key) && arrayIsArray(cfg[key]) ? addToSet(options.base ? clone(options.base) : {}, cfg[key], options.transform) : fallback;
|
|
396
407
|
};
|
|
408
|
+
var _resolveObjectOption = function _resolveObjectOption2(cfg, key, makeFallback) {
|
|
409
|
+
const value = objectHasOwnProperty(cfg, key) ? cfg[key] : undefined;
|
|
410
|
+
return value && typeof value === "object" ? clone(value) : makeFallback();
|
|
411
|
+
};
|
|
397
412
|
function createDOMPurify() {
|
|
398
413
|
let window2 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : getGlobal();
|
|
399
414
|
const DOMPurify = (root) => createDOMPurify(root);
|
|
400
|
-
DOMPurify.version = "3.4.
|
|
415
|
+
DOMPurify.version = "3.4.14";
|
|
401
416
|
DOMPurify.removed = [];
|
|
402
417
|
if (!window2 || !window2.document || window2.document.nodeType !== NODE_TYPE.document || !window2.Element) {
|
|
403
418
|
DOMPurify.isSupported = false;
|
|
@@ -421,6 +436,13 @@ function createDOMPurify() {
|
|
|
421
436
|
const getAttributes = lookupGetter(ElementPrototype, "attributes");
|
|
422
437
|
const getNodeType = Node && Node.prototype ? lookupGetter(Node.prototype, "nodeType") : null;
|
|
423
438
|
const getNodeName = Node && Node.prototype ? lookupGetter(Node.prototype, "nodeName") : null;
|
|
439
|
+
const getOwnerDocument = Node && Node.prototype ? lookupGetter(Node.prototype, "ownerDocument") : null;
|
|
440
|
+
const _readNodeType = function _readNodeType2(node) {
|
|
441
|
+
return getNodeType ? getNodeType(node) : node.nodeType;
|
|
442
|
+
};
|
|
443
|
+
const _readNodeName = function _readNodeName2(node) {
|
|
444
|
+
return getNodeName ? getNodeName(node) : node.nodeName;
|
|
445
|
+
};
|
|
424
446
|
if (typeof HTMLTemplateElement === "function") {
|
|
425
447
|
const template = document.createElement("template");
|
|
426
448
|
if (template.content && template.content.ownerDocument) {
|
|
@@ -516,6 +538,8 @@ function createDOMPurify() {
|
|
|
516
538
|
let SAFE_FOR_XML = true;
|
|
517
539
|
let WHOLE_DOCUMENT = false;
|
|
518
540
|
let SET_CONFIG = false;
|
|
541
|
+
let SET_CONFIG_ALLOWED_TAGS = null;
|
|
542
|
+
let SET_CONFIG_ALLOWED_ATTR = null;
|
|
519
543
|
let FORCE_BODY = false;
|
|
520
544
|
let RETURN_DOM = false;
|
|
521
545
|
let RETURN_DOM_FRAGMENT = false;
|
|
@@ -635,9 +659,9 @@ function createDOMPurify() {
|
|
|
635
659
|
IN_PLACE = cfg.IN_PLACE || false;
|
|
636
660
|
IS_ALLOWED_URI$1 = isRegex(cfg.ALLOWED_URI_REGEXP) ? cfg.ALLOWED_URI_REGEXP : IS_ALLOWED_URI;
|
|
637
661
|
NAMESPACE = typeof cfg.NAMESPACE === "string" ? cfg.NAMESPACE : HTML_NAMESPACE;
|
|
638
|
-
MATHML_TEXT_INTEGRATION_POINTS =
|
|
639
|
-
HTML_INTEGRATION_POINTS =
|
|
640
|
-
const customElementHandling =
|
|
662
|
+
MATHML_TEXT_INTEGRATION_POINTS = _resolveObjectOption(cfg, "MATHML_TEXT_INTEGRATION_POINTS", () => addToSet({}, DEFAULT_MATHML_TEXT_INTEGRATION_POINTS));
|
|
663
|
+
HTML_INTEGRATION_POINTS = _resolveObjectOption(cfg, "HTML_INTEGRATION_POINTS", () => addToSet({}, DEFAULT_HTML_INTEGRATION_POINTS));
|
|
664
|
+
const customElementHandling = _resolveObjectOption(cfg, "CUSTOM_ELEMENT_HANDLING", () => create(null));
|
|
641
665
|
CUSTOM_ELEMENT_HANDLING = create(null);
|
|
642
666
|
if (objectHasOwnProperty(customElementHandling, "tagNameCheck") && isRegexOrFunction(customElementHandling.tagNameCheck)) {
|
|
643
667
|
CUSTOM_ELEMENT_HANDLING.tagNameCheck = customElementHandling.tagNameCheck;
|
|
@@ -700,15 +724,6 @@ function createDOMPurify() {
|
|
|
700
724
|
addToSet(ALLOWED_ATTR, cfg.ADD_ATTR, transformCaseFunc);
|
|
701
725
|
}
|
|
702
726
|
}
|
|
703
|
-
if (objectHasOwnProperty(cfg, "ADD_URI_SAFE_ATTR") && arrayIsArray(cfg.ADD_URI_SAFE_ATTR)) {
|
|
704
|
-
addToSet(URI_SAFE_ATTRIBUTES, cfg.ADD_URI_SAFE_ATTR, transformCaseFunc);
|
|
705
|
-
}
|
|
706
|
-
if (objectHasOwnProperty(cfg, "FORBID_CONTENTS") && arrayIsArray(cfg.FORBID_CONTENTS)) {
|
|
707
|
-
if (FORBID_CONTENTS === DEFAULT_FORBID_CONTENTS) {
|
|
708
|
-
FORBID_CONTENTS = clone(FORBID_CONTENTS);
|
|
709
|
-
}
|
|
710
|
-
addToSet(FORBID_CONTENTS, cfg.FORBID_CONTENTS, transformCaseFunc);
|
|
711
|
-
}
|
|
712
727
|
if (objectHasOwnProperty(cfg, "ADD_FORBID_CONTENTS") && arrayIsArray(cfg.ADD_FORBID_CONTENTS)) {
|
|
713
728
|
if (FORBID_CONTENTS === DEFAULT_FORBID_CONTENTS) {
|
|
714
729
|
FORBID_CONTENTS = clone(FORBID_CONTENTS);
|
|
@@ -751,12 +766,6 @@ function createDOMPurify() {
|
|
|
751
766
|
emptyHTML = _createTrustedHTML("");
|
|
752
767
|
}
|
|
753
768
|
}
|
|
754
|
-
if ((hooks.uponSanitizeElement.length > 0 || hooks.uponSanitizeAttribute.length > 0) && ALLOWED_TAGS === DEFAULT_ALLOWED_TAGS) {
|
|
755
|
-
ALLOWED_TAGS = clone(ALLOWED_TAGS);
|
|
756
|
-
}
|
|
757
|
-
if (hooks.uponSanitizeAttribute.length > 0 && ALLOWED_ATTR === DEFAULT_ALLOWED_ATTR) {
|
|
758
|
-
ALLOWED_ATTR = clone(ALLOWED_ATTR);
|
|
759
|
-
}
|
|
760
769
|
if (freeze) {
|
|
761
770
|
freeze(cfg);
|
|
762
771
|
}
|
|
@@ -831,7 +840,17 @@ function createDOMPurify() {
|
|
|
831
840
|
}
|
|
832
841
|
}
|
|
833
842
|
};
|
|
843
|
+
const _stripAttributeNode = function _stripAttributeNode2(element, attribute, name) {
|
|
844
|
+
try {
|
|
845
|
+
element.removeAttributeNode(attribute);
|
|
846
|
+
} catch (_) {
|
|
847
|
+
try {
|
|
848
|
+
element.removeAttribute(name);
|
|
849
|
+
} catch (_2) {}
|
|
850
|
+
}
|
|
851
|
+
};
|
|
834
852
|
const _neutralizeRoot = function _neutralizeRoot2(root) {
|
|
853
|
+
_neutralizeSubtree(root);
|
|
835
854
|
const childNodes = getChildNodes(root);
|
|
836
855
|
if (childNodes) {
|
|
837
856
|
const snapshot = [];
|
|
@@ -850,26 +869,34 @@ function createDOMPurify() {
|
|
|
850
869
|
const attribute = attributes[i];
|
|
851
870
|
const name = attribute && attribute.name;
|
|
852
871
|
if (typeof name === "string") {
|
|
853
|
-
|
|
854
|
-
root.removeAttribute(name);
|
|
855
|
-
} catch (_) {}
|
|
872
|
+
_stripAttributeNode(root, attribute, name);
|
|
856
873
|
}
|
|
857
874
|
}
|
|
858
875
|
}
|
|
859
876
|
};
|
|
860
|
-
const _removeAttribute = function _removeAttribute2(name, element) {
|
|
877
|
+
const _removeAttribute = function _removeAttribute2(name, element, attr) {
|
|
878
|
+
if (!attr) {
|
|
879
|
+
try {
|
|
880
|
+
attr = element.getAttributeNode(name);
|
|
881
|
+
} catch (_) {
|
|
882
|
+
attr = null;
|
|
883
|
+
}
|
|
884
|
+
}
|
|
885
|
+
arrayPush(DOMPurify.removed, {
|
|
886
|
+
attribute: attr || null,
|
|
887
|
+
from: element
|
|
888
|
+
});
|
|
861
889
|
try {
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
890
|
+
if (attr) {
|
|
891
|
+
element.removeAttributeNode(attr);
|
|
892
|
+
} else {
|
|
893
|
+
element.removeAttribute(name);
|
|
894
|
+
}
|
|
866
895
|
} catch (_) {
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
});
|
|
896
|
+
try {
|
|
897
|
+
element.removeAttribute(name);
|
|
898
|
+
} catch (_2) {}
|
|
871
899
|
}
|
|
872
|
-
element.removeAttribute(name);
|
|
873
900
|
if (name === "is") {
|
|
874
901
|
if (RETURN_DOM || RETURN_DOM_FRAGMENT) {
|
|
875
902
|
try {
|
|
@@ -893,16 +920,14 @@ function createDOMPurify() {
|
|
|
893
920
|
if (typeof name !== "string" || ALLOWED_ATTR[transformCaseFunc(name)]) {
|
|
894
921
|
continue;
|
|
895
922
|
}
|
|
896
|
-
|
|
897
|
-
element.removeAttribute(name);
|
|
898
|
-
} catch (_) {}
|
|
923
|
+
_stripAttributeNode(element, attribute, name);
|
|
899
924
|
}
|
|
900
925
|
};
|
|
901
926
|
const _neutralizeSubtree = function _neutralizeSubtree2(root) {
|
|
902
927
|
const stack = [root];
|
|
903
928
|
while (stack.length > 0) {
|
|
904
929
|
const node = stack.pop();
|
|
905
|
-
const nodeType =
|
|
930
|
+
const nodeType = _readNodeType(node);
|
|
906
931
|
if (nodeType === NODE_TYPE.element) {
|
|
907
932
|
_stripDisallowedAttributes(node);
|
|
908
933
|
}
|
|
@@ -914,6 +939,49 @@ function createDOMPurify() {
|
|
|
914
939
|
}
|
|
915
940
|
}
|
|
916
941
|
};
|
|
942
|
+
const _isPatchLinkageAttribute = function _isPatchLinkageAttribute2(lcName, lcTag) {
|
|
943
|
+
if (!SAFE_FOR_XML) {
|
|
944
|
+
return false;
|
|
945
|
+
}
|
|
946
|
+
if (lcName === "patchsrc") {
|
|
947
|
+
return true;
|
|
948
|
+
}
|
|
949
|
+
return lcName === "for" && lcTag !== "label" && lcTag !== "output";
|
|
950
|
+
};
|
|
951
|
+
const _neutralizePatchLinkage = function _neutralizePatchLinkage2(root) {
|
|
952
|
+
if (!SAFE_FOR_XML) {
|
|
953
|
+
return;
|
|
954
|
+
}
|
|
955
|
+
const stack = [root];
|
|
956
|
+
while (stack.length > 0) {
|
|
957
|
+
const node = stack.pop();
|
|
958
|
+
const nodeType = _readNodeType(node);
|
|
959
|
+
if (nodeType === NODE_TYPE.processingInstruction || nodeType === NODE_TYPE.comment && regExpTest(COMMENT_MARKUP_PROBE, node.data)) {
|
|
960
|
+
try {
|
|
961
|
+
remove(node);
|
|
962
|
+
} catch (_) {}
|
|
963
|
+
continue;
|
|
964
|
+
}
|
|
965
|
+
if (nodeType === NODE_TYPE.element) {
|
|
966
|
+
const element = node;
|
|
967
|
+
const lcTag = transformCaseFunc(_readNodeName(node));
|
|
968
|
+
try {
|
|
969
|
+
if (element.hasAttribute && element.hasAttribute("patchsrc")) {
|
|
970
|
+
element.removeAttribute("patchsrc");
|
|
971
|
+
}
|
|
972
|
+
if (element.hasAttribute && element.hasAttribute("for") && _isPatchLinkageAttribute("for", lcTag)) {
|
|
973
|
+
element.removeAttribute("for");
|
|
974
|
+
}
|
|
975
|
+
} catch (_) {}
|
|
976
|
+
}
|
|
977
|
+
const childNodes = getChildNodes(node);
|
|
978
|
+
if (childNodes) {
|
|
979
|
+
for (let i = childNodes.length - 1;i >= 0; --i) {
|
|
980
|
+
stack.push(childNodes[i]);
|
|
981
|
+
}
|
|
982
|
+
}
|
|
983
|
+
}
|
|
984
|
+
};
|
|
917
985
|
const _initDocument = function _initDocument2(dirty) {
|
|
918
986
|
let doc = null;
|
|
919
987
|
let leadingWhitespace = null;
|
|
@@ -948,7 +1016,8 @@ function createDOMPurify() {
|
|
|
948
1016
|
return WHOLE_DOCUMENT ? doc.documentElement : body;
|
|
949
1017
|
};
|
|
950
1018
|
const _createNodeIterator = function _createNodeIterator2(root) {
|
|
951
|
-
|
|
1019
|
+
const doc = getOwnerDocument ? getOwnerDocument(root) : root.ownerDocument;
|
|
1020
|
+
return createNodeIterator.call(doc || root, root, NodeFilter.SHOW_ELEMENT | NodeFilter.SHOW_COMMENT | NodeFilter.SHOW_TEXT | NodeFilter.SHOW_PROCESSING_INSTRUCTION | NodeFilter.SHOW_CDATA_SECTION, null);
|
|
952
1021
|
};
|
|
953
1022
|
const _stripTemplateExpressions = function _stripTemplateExpressions2(value) {
|
|
954
1023
|
value = stringReplace(value, MUSTACHE_EXPR$1, " ");
|
|
@@ -959,7 +1028,8 @@ function createDOMPurify() {
|
|
|
959
1028
|
const _scrubTemplateExpressions2 = function _scrubTemplateExpressions(node) {
|
|
960
1029
|
var _node$querySelectorAl;
|
|
961
1030
|
node.normalize();
|
|
962
|
-
const
|
|
1031
|
+
const doc = getOwnerDocument ? getOwnerDocument(node) : node.ownerDocument;
|
|
1032
|
+
const walker = createNodeIterator.call(doc || node, node, NodeFilter.SHOW_TEXT | NodeFilter.SHOW_COMMENT | NodeFilter.SHOW_CDATA_SECTION | NodeFilter.SHOW_PROCESSING_INSTRUCTION, null);
|
|
963
1033
|
let currentNode = walker.nextNode();
|
|
964
1034
|
while (currentNode) {
|
|
965
1035
|
currentNode.data = _stripTemplateExpressions(currentNode.data);
|
|
@@ -1016,7 +1086,7 @@ function createDOMPurify() {
|
|
|
1016
1086
|
if (SAFE_FOR_XML && currentNode.hasChildNodes() && !_isNode(currentNode.firstElementChild) && regExpTest(ELEMENT_MARKUP_PROBE, currentNode.textContent) && regExpTest(ELEMENT_MARKUP_PROBE, currentNode.innerHTML)) {
|
|
1017
1087
|
return true;
|
|
1018
1088
|
}
|
|
1019
|
-
if (SAFE_FOR_XML && currentNode.namespaceURI === HTML_NAMESPACE && tagName === "
|
|
1089
|
+
if (SAFE_FOR_XML && currentNode.namespaceURI === HTML_NAMESPACE && LITERAL_TEXT_ELEMENTS[tagName] && (_isNode(currentNode.firstElementChild) || typeof currentNode.textContent === "string" && regExpTest(LITERAL_TEXT_CLOSE[tagName], currentNode.textContent))) {
|
|
1020
1090
|
return true;
|
|
1021
1091
|
}
|
|
1022
1092
|
if (currentNode.nodeType === NODE_TYPE.processingInstruction) {
|
|
@@ -1027,14 +1097,21 @@ function createDOMPurify() {
|
|
|
1027
1097
|
}
|
|
1028
1098
|
return false;
|
|
1029
1099
|
};
|
|
1030
|
-
const
|
|
1031
|
-
if (
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1100
|
+
const _matchesNameCheck = function _matchesNameCheck2(check, name) {
|
|
1101
|
+
if (check instanceof RegExp) {
|
|
1102
|
+
return regExpTest(check, name);
|
|
1103
|
+
}
|
|
1104
|
+
if (check instanceof Function) {
|
|
1105
|
+
for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2;_key < _len; _key++) {
|
|
1106
|
+
args[_key - 2] = arguments[_key];
|
|
1037
1107
|
}
|
|
1108
|
+
return Boolean(check(name, ...args));
|
|
1109
|
+
}
|
|
1110
|
+
return false;
|
|
1111
|
+
};
|
|
1112
|
+
const _sanitizeDisallowedNode = function _sanitizeDisallowedNode2(currentNode, tagName, root) {
|
|
1113
|
+
if (!FORBID_TAGS[tagName] && _isBasicCustomElement(tagName) && _matchesNameCheck(CUSTOM_ELEMENT_HANDLING.tagNameCheck, tagName)) {
|
|
1114
|
+
return false;
|
|
1038
1115
|
}
|
|
1039
1116
|
if (KEEP_CONTENT && !FORBID_CONTENTS[tagName]) {
|
|
1040
1117
|
const parentNode = getParentNode(currentNode);
|
|
@@ -1042,7 +1119,7 @@ function createDOMPurify() {
|
|
|
1042
1119
|
if (childNodes && parentNode) {
|
|
1043
1120
|
const childCount = childNodes.length;
|
|
1044
1121
|
for (let i = childCount - 1;i >= 0; --i) {
|
|
1045
|
-
const hoisted =
|
|
1122
|
+
const hoisted = currentNode === root ? cloneNode(childNodes[i], true) : childNodes[i];
|
|
1046
1123
|
parentNode.insertBefore(hoisted, getNextSibling(currentNode));
|
|
1047
1124
|
}
|
|
1048
1125
|
}
|
|
@@ -1050,25 +1127,51 @@ function createDOMPurify() {
|
|
|
1050
1127
|
_forceRemove(currentNode);
|
|
1051
1128
|
return true;
|
|
1052
1129
|
};
|
|
1053
|
-
const
|
|
1130
|
+
const _forkSharedAllowlist = function _forkSharedAllowlist2(hookList, set, defaultSet, setConfigSet) {
|
|
1131
|
+
if (hookList.length === 0) {
|
|
1132
|
+
return set;
|
|
1133
|
+
}
|
|
1134
|
+
return set === defaultSet || set === setConfigSet ? clone(set) : set;
|
|
1135
|
+
};
|
|
1136
|
+
const _handleHookDetachedNode = function _handleHookDetachedNode2(currentNode, root) {
|
|
1137
|
+
if (currentNode === root || getParentNode(currentNode) !== null) {
|
|
1138
|
+
return false;
|
|
1139
|
+
}
|
|
1140
|
+
if (IN_PLACE) {
|
|
1141
|
+
_neutralizeSubtree(currentNode);
|
|
1142
|
+
}
|
|
1143
|
+
return true;
|
|
1144
|
+
};
|
|
1145
|
+
const _sanitizeElements = function _sanitizeElements2(currentNode, root) {
|
|
1054
1146
|
_executeHooks(hooks.beforeSanitizeElements, currentNode, null);
|
|
1147
|
+
if (_handleHookDetachedNode(currentNode, root)) {
|
|
1148
|
+
return true;
|
|
1149
|
+
}
|
|
1055
1150
|
if (_isClobbered(currentNode)) {
|
|
1056
1151
|
_forceRemove(currentNode);
|
|
1057
1152
|
return true;
|
|
1058
1153
|
}
|
|
1059
|
-
const tagName = transformCaseFunc(
|
|
1154
|
+
const tagName = transformCaseFunc(_readNodeName(currentNode));
|
|
1155
|
+
ALLOWED_TAGS = _forkSharedAllowlist(hooks.uponSanitizeElement, ALLOWED_TAGS, DEFAULT_ALLOWED_TAGS, SET_CONFIG_ALLOWED_TAGS);
|
|
1060
1156
|
_executeHooks(hooks.uponSanitizeElement, currentNode, {
|
|
1061
1157
|
tagName,
|
|
1062
1158
|
allowedTags: ALLOWED_TAGS
|
|
1063
1159
|
});
|
|
1160
|
+
if (_handleHookDetachedNode(currentNode, root)) {
|
|
1161
|
+
return true;
|
|
1162
|
+
}
|
|
1064
1163
|
if (_isUnsafeNode(currentNode, tagName)) {
|
|
1065
1164
|
_forceRemove(currentNode);
|
|
1066
1165
|
return true;
|
|
1067
1166
|
}
|
|
1068
1167
|
if (FORBID_TAGS[tagName] || !(EXTRA_ELEMENT_HANDLING.tagCheck instanceof Function && EXTRA_ELEMENT_HANDLING.tagCheck(tagName)) && !ALLOWED_TAGS[tagName]) {
|
|
1069
|
-
|
|
1168
|
+
const removed = _sanitizeDisallowedNode(currentNode, tagName, root);
|
|
1169
|
+
if (removed === false) {
|
|
1170
|
+
_executeHooks(hooks.afterSanitizeElements, currentNode, null);
|
|
1171
|
+
}
|
|
1172
|
+
return removed;
|
|
1070
1173
|
}
|
|
1071
|
-
const nt =
|
|
1174
|
+
const nt = _readNodeType(currentNode);
|
|
1072
1175
|
if (nt === NODE_TYPE.element && !_checkValidNamespace(currentNode)) {
|
|
1073
1176
|
_forceRemove(currentNode);
|
|
1074
1177
|
return true;
|
|
@@ -1093,32 +1196,35 @@ function createDOMPurify() {
|
|
|
1093
1196
|
if (FORBID_ATTR[lcName]) {
|
|
1094
1197
|
return false;
|
|
1095
1198
|
}
|
|
1199
|
+
if (_isPatchLinkageAttribute(lcName, lcTag)) {
|
|
1200
|
+
return false;
|
|
1201
|
+
}
|
|
1096
1202
|
if (SANITIZE_DOM && (lcName === "id" || lcName === "name") && ((value in document) || (value in formElement))) {
|
|
1097
1203
|
return false;
|
|
1098
1204
|
}
|
|
1099
1205
|
const nameIsPermitted = ALLOWED_ATTR[lcName] || EXTRA_ELEMENT_HANDLING.attributeCheck instanceof Function && EXTRA_ELEMENT_HANDLING.attributeCheck(lcName, lcTag);
|
|
1100
|
-
if (ALLOW_DATA_ATTR && regExpTest(DATA_ATTR$1, lcName))
|
|
1101
|
-
;
|
|
1102
|
-
else if (ALLOW_ARIA_ATTR && regExpTest(ARIA_ATTR$1, lcName))
|
|
1103
|
-
;
|
|
1104
|
-
else if (!nameIsPermitted) {
|
|
1105
|
-
if (_isBasicCustomElement(lcTag) && (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof RegExp && regExpTest(CUSTOM_ELEMENT_HANDLING.tagNameCheck, lcTag) || CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof Function && CUSTOM_ELEMENT_HANDLING.tagNameCheck(lcTag)) && (CUSTOM_ELEMENT_HANDLING.attributeNameCheck instanceof RegExp && regExpTest(CUSTOM_ELEMENT_HANDLING.attributeNameCheck, lcName) || CUSTOM_ELEMENT_HANDLING.attributeNameCheck instanceof Function && CUSTOM_ELEMENT_HANDLING.attributeNameCheck(lcName, lcTag)) || lcName === "is" && CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements && (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof RegExp && regExpTest(CUSTOM_ELEMENT_HANDLING.tagNameCheck, value) || CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof Function && CUSTOM_ELEMENT_HANDLING.tagNameCheck(value)))
|
|
1106
|
-
;
|
|
1107
|
-
else {
|
|
1108
|
-
return false;
|
|
1109
|
-
}
|
|
1110
|
-
} else if (URI_SAFE_ATTRIBUTES[lcName])
|
|
1111
|
-
;
|
|
1112
|
-
else if (regExpTest(IS_ALLOWED_URI$1, stringReplace(value, ATTR_WHITESPACE$1, "")))
|
|
1113
|
-
;
|
|
1114
|
-
else if ((lcName === "src" || lcName === "xlink:href" || lcName === "href") && lcTag !== "script" && stringIndexOf(value, "data:") === 0 && DATA_URI_TAGS[lcTag])
|
|
1115
|
-
;
|
|
1116
|
-
else if (ALLOW_UNKNOWN_PROTOCOLS && !regExpTest(IS_SCRIPT_OR_DATA$1, stringReplace(value, ATTR_WHITESPACE$1, "")))
|
|
1117
|
-
;
|
|
1118
|
-
else if (value) {
|
|
1119
|
-
return false;
|
|
1206
|
+
if (ALLOW_DATA_ATTR && regExpTest(DATA_ATTR$1, lcName)) {
|
|
1207
|
+
return true;
|
|
1120
1208
|
}
|
|
1121
|
-
|
|
1209
|
+
if (ALLOW_ARIA_ATTR && regExpTest(ARIA_ATTR$1, lcName)) {
|
|
1210
|
+
return true;
|
|
1211
|
+
}
|
|
1212
|
+
if (!nameIsPermitted) {
|
|
1213
|
+
return _isBasicCustomElement(lcTag) && _matchesNameCheck(CUSTOM_ELEMENT_HANDLING.tagNameCheck, lcTag) && _matchesNameCheck(CUSTOM_ELEMENT_HANDLING.attributeNameCheck, lcName, lcTag) || lcName === "is" && CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements && _matchesNameCheck(CUSTOM_ELEMENT_HANDLING.tagNameCheck, value);
|
|
1214
|
+
}
|
|
1215
|
+
if (URI_SAFE_ATTRIBUTES[lcName]) {
|
|
1216
|
+
return true;
|
|
1217
|
+
}
|
|
1218
|
+
if (regExpTest(IS_ALLOWED_URI$1, stringReplace(value, ATTR_WHITESPACE$1, ""))) {
|
|
1219
|
+
return true;
|
|
1220
|
+
}
|
|
1221
|
+
if ((lcName === "src" || lcName === "xlink:href" || lcName === "href") && lcTag !== "script" && stringIndexOf(value, "data:") === 0 && DATA_URI_TAGS[lcTag]) {
|
|
1222
|
+
return true;
|
|
1223
|
+
}
|
|
1224
|
+
if (ALLOW_UNKNOWN_PROTOCOLS && !regExpTest(IS_SCRIPT_OR_DATA$1, stringReplace(value, ATTR_WHITESPACE$1, ""))) {
|
|
1225
|
+
return true;
|
|
1226
|
+
}
|
|
1227
|
+
return !value;
|
|
1122
1228
|
};
|
|
1123
1229
|
const RESERVED_CUSTOM_ELEMENT_NAMES = addToSet({}, ["annotation-xml", "color-profile", "font-face", "font-face-format", "font-face-name", "font-face-src", "font-face-uri", "missing-glyph"]);
|
|
1124
1230
|
const _isBasicCustomElement = function _isBasicCustomElement2(tagName) {
|
|
@@ -1159,6 +1265,7 @@ function createDOMPurify() {
|
|
|
1159
1265
|
if (!attributes || _isClobbered(currentNode)) {
|
|
1160
1266
|
return;
|
|
1161
1267
|
}
|
|
1268
|
+
ALLOWED_ATTR = _forkSharedAllowlist(hooks.uponSanitizeAttribute, ALLOWED_ATTR, DEFAULT_ALLOWED_ATTR, SET_CONFIG_ALLOWED_ATTR);
|
|
1162
1269
|
const hookEvent = {
|
|
1163
1270
|
attrName: "",
|
|
1164
1271
|
attrValue: "",
|
|
@@ -1181,33 +1288,33 @@ function createDOMPurify() {
|
|
|
1181
1288
|
_executeHooks(hooks.uponSanitizeAttribute, currentNode, hookEvent);
|
|
1182
1289
|
value = hookEvent.attrValue;
|
|
1183
1290
|
if (SANITIZE_NAMED_PROPS && (lcName === "id" || lcName === "name") && stringIndexOf(value, SANITIZE_NAMED_PROPS_PREFIX) !== 0) {
|
|
1184
|
-
_removeAttribute(name, currentNode);
|
|
1291
|
+
_removeAttribute(name, currentNode, attr);
|
|
1185
1292
|
value = SANITIZE_NAMED_PROPS_PREFIX + value;
|
|
1186
1293
|
}
|
|
1187
1294
|
if (SAFE_FOR_XML && regExpTest(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i, value)) {
|
|
1188
|
-
_removeAttribute(name, currentNode);
|
|
1295
|
+
_removeAttribute(name, currentNode, attr);
|
|
1189
1296
|
continue;
|
|
1190
1297
|
}
|
|
1191
1298
|
if (lcName === "attributename" && stringMatch(value, "href")) {
|
|
1192
|
-
_removeAttribute(name, currentNode);
|
|
1299
|
+
_removeAttribute(name, currentNode, attr);
|
|
1193
1300
|
continue;
|
|
1194
1301
|
}
|
|
1195
1302
|
if (hookEvent.forceKeepAttr) {
|
|
1196
1303
|
continue;
|
|
1197
1304
|
}
|
|
1198
1305
|
if (!hookEvent.keepAttr) {
|
|
1199
|
-
_removeAttribute(name, currentNode);
|
|
1306
|
+
_removeAttribute(name, currentNode, attr);
|
|
1200
1307
|
continue;
|
|
1201
1308
|
}
|
|
1202
1309
|
if (!ALLOW_SELF_CLOSE_IN_ATTR && regExpTest(SELF_CLOSING_TAG, value)) {
|
|
1203
|
-
_removeAttribute(name, currentNode);
|
|
1310
|
+
_removeAttribute(name, currentNode, attr);
|
|
1204
1311
|
continue;
|
|
1205
1312
|
}
|
|
1206
1313
|
if (SAFE_FOR_TEMPLATES) {
|
|
1207
1314
|
value = _stripTemplateExpressions(value);
|
|
1208
1315
|
}
|
|
1209
1316
|
if (!_isValidAttribute(lcTag, lcName, value)) {
|
|
1210
|
-
_removeAttribute(name, currentNode);
|
|
1317
|
+
_removeAttribute(name, currentNode, attr);
|
|
1211
1318
|
continue;
|
|
1212
1319
|
}
|
|
1213
1320
|
value = _applyTrustedTypesToAttribute(lcTag, lcName, namespaceURI, value);
|
|
@@ -1223,13 +1330,12 @@ function createDOMPurify() {
|
|
|
1223
1330
|
_executeHooks(hooks.beforeSanitizeShadowDOM, fragment, null);
|
|
1224
1331
|
while (shadowNode = shadowIterator.nextNode()) {
|
|
1225
1332
|
_executeHooks(hooks.uponSanitizeShadowNode, shadowNode, null);
|
|
1226
|
-
_sanitizeElements(shadowNode);
|
|
1333
|
+
_sanitizeElements(shadowNode, fragment);
|
|
1227
1334
|
_sanitizeAttributes(shadowNode);
|
|
1228
1335
|
if (_isDocumentFragment(shadowNode.content)) {
|
|
1229
1336
|
_sanitizeShadowDOM2(shadowNode.content);
|
|
1230
1337
|
}
|
|
1231
|
-
|
|
1232
|
-
if (shadowNodeType === NODE_TYPE.element) {
|
|
1338
|
+
if (_readNodeType(shadowNode) === NODE_TYPE.element) {
|
|
1233
1339
|
const innerSr = getShadowRoot(shadowNode);
|
|
1234
1340
|
if (_isDocumentFragment(innerSr)) {
|
|
1235
1341
|
_sanitizeAttachedShadowRoots(innerSr);
|
|
@@ -1251,7 +1357,7 @@ function createDOMPurify() {
|
|
|
1251
1357
|
continue;
|
|
1252
1358
|
}
|
|
1253
1359
|
const node = item.node;
|
|
1254
|
-
const nodeType =
|
|
1360
|
+
const nodeType = _readNodeType(node);
|
|
1255
1361
|
const isElement = nodeType === NODE_TYPE.element;
|
|
1256
1362
|
const childNodes = getChildNodes(node);
|
|
1257
1363
|
if (childNodes) {
|
|
@@ -1307,20 +1413,32 @@ function createDOMPurify() {
|
|
|
1307
1413
|
if (!DOMPurify.isSupported) {
|
|
1308
1414
|
return dirty;
|
|
1309
1415
|
}
|
|
1310
|
-
if (
|
|
1416
|
+
if (SET_CONFIG) {
|
|
1417
|
+
ALLOWED_TAGS = SET_CONFIG_ALLOWED_TAGS;
|
|
1418
|
+
ALLOWED_ATTR = SET_CONFIG_ALLOWED_ATTR;
|
|
1419
|
+
} else {
|
|
1311
1420
|
_parseConfig(cfg);
|
|
1312
1421
|
}
|
|
1422
|
+
if (hooks.uponSanitizeElement.length > 0 || hooks.uponSanitizeAttribute.length > 0) {
|
|
1423
|
+
ALLOWED_TAGS = clone(ALLOWED_TAGS);
|
|
1424
|
+
}
|
|
1425
|
+
if (hooks.uponSanitizeAttribute.length > 0) {
|
|
1426
|
+
ALLOWED_ATTR = clone(ALLOWED_ATTR);
|
|
1427
|
+
}
|
|
1313
1428
|
DOMPurify.removed = [];
|
|
1314
1429
|
const inPlace = IN_PLACE && typeof dirty !== "string" && _isNode(dirty);
|
|
1315
1430
|
if (inPlace) {
|
|
1316
|
-
|
|
1431
|
+
_neutralizePatchLinkage(dirty);
|
|
1432
|
+
const nn = _readNodeName(dirty);
|
|
1317
1433
|
if (typeof nn === "string") {
|
|
1318
1434
|
const tagName = transformCaseFunc(nn);
|
|
1319
1435
|
if (!ALLOWED_TAGS[tagName] || FORBID_TAGS[tagName]) {
|
|
1436
|
+
_neutralizeRoot(dirty);
|
|
1320
1437
|
throw typeErrorCreate("root node is forbidden and cannot be sanitized in-place");
|
|
1321
1438
|
}
|
|
1322
1439
|
}
|
|
1323
1440
|
if (_isClobbered(dirty)) {
|
|
1441
|
+
_neutralizeRoot(dirty);
|
|
1324
1442
|
throw typeErrorCreate("root node is clobbered and cannot be sanitized in-place");
|
|
1325
1443
|
}
|
|
1326
1444
|
try {
|
|
@@ -1352,10 +1470,11 @@ function createDOMPurify() {
|
|
|
1352
1470
|
if (body && FORCE_BODY) {
|
|
1353
1471
|
_forceRemove(body.firstChild);
|
|
1354
1472
|
}
|
|
1355
|
-
const
|
|
1473
|
+
const walkRoot = inPlace ? dirty : body;
|
|
1356
1474
|
try {
|
|
1475
|
+
const nodeIterator = _createNodeIterator(walkRoot);
|
|
1357
1476
|
while (currentNode = nodeIterator.nextNode()) {
|
|
1358
|
-
_sanitizeElements(currentNode);
|
|
1477
|
+
_sanitizeElements(currentNode, walkRoot);
|
|
1359
1478
|
_sanitizeAttributes(currentNode);
|
|
1360
1479
|
if (_isDocumentFragment(currentNode.content)) {
|
|
1361
1480
|
_sanitizeShadowDOM2(currentNode.content);
|
|
@@ -1364,6 +1483,11 @@ function createDOMPurify() {
|
|
|
1364
1483
|
} catch (error) {
|
|
1365
1484
|
if (inPlace) {
|
|
1366
1485
|
_neutralizeRoot(dirty);
|
|
1486
|
+
arrayForEach(DOMPurify.removed, (entry) => {
|
|
1487
|
+
if (entry.element) {
|
|
1488
|
+
_neutralizeSubtree(entry.element);
|
|
1489
|
+
}
|
|
1490
|
+
});
|
|
1367
1491
|
}
|
|
1368
1492
|
throw error;
|
|
1369
1493
|
}
|
|
@@ -1409,10 +1533,14 @@ function createDOMPurify() {
|
|
|
1409
1533
|
let cfg = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
1410
1534
|
_parseConfig(cfg);
|
|
1411
1535
|
SET_CONFIG = true;
|
|
1536
|
+
SET_CONFIG_ALLOWED_TAGS = ALLOWED_TAGS;
|
|
1537
|
+
SET_CONFIG_ALLOWED_ATTR = ALLOWED_ATTR;
|
|
1412
1538
|
};
|
|
1413
1539
|
DOMPurify.clearConfig = function() {
|
|
1414
1540
|
CONFIG = null;
|
|
1415
1541
|
SET_CONFIG = false;
|
|
1542
|
+
SET_CONFIG_ALLOWED_TAGS = null;
|
|
1543
|
+
SET_CONFIG_ALLOWED_ATTR = null;
|
|
1416
1544
|
trustedTypesPolicy = defaultTrustedTypesPolicy;
|
|
1417
1545
|
emptyHTML = "";
|
|
1418
1546
|
};
|
|
@@ -1428,9 +1556,15 @@ function createDOMPurify() {
|
|
|
1428
1556
|
if (typeof hookFunction !== "function") {
|
|
1429
1557
|
return;
|
|
1430
1558
|
}
|
|
1559
|
+
if (!objectHasOwnProperty(hooks, entryPoint)) {
|
|
1560
|
+
return;
|
|
1561
|
+
}
|
|
1431
1562
|
arrayPush(hooks[entryPoint], hookFunction);
|
|
1432
1563
|
};
|
|
1433
1564
|
DOMPurify.removeHook = function(entryPoint, hookFunction) {
|
|
1565
|
+
if (!objectHasOwnProperty(hooks, entryPoint)) {
|
|
1566
|
+
return;
|
|
1567
|
+
}
|
|
1434
1568
|
if (hookFunction !== undefined) {
|
|
1435
1569
|
const index = arrayLastIndexOf(hooks[entryPoint], hookFunction);
|
|
1436
1570
|
return index === -1 ? undefined : arraySplice(hooks[entryPoint], index, 1)[0];
|
|
@@ -1438,6 +1572,9 @@ function createDOMPurify() {
|
|
|
1438
1572
|
return arrayPop(hooks[entryPoint]);
|
|
1439
1573
|
};
|
|
1440
1574
|
DOMPurify.removeHooks = function(entryPoint) {
|
|
1575
|
+
if (!objectHasOwnProperty(hooks, entryPoint)) {
|
|
1576
|
+
return;
|
|
1577
|
+
}
|
|
1441
1578
|
hooks[entryPoint] = [];
|
|
1442
1579
|
};
|
|
1443
1580
|
DOMPurify.removeAllHooks = function() {
|
|
@@ -2788,4 +2925,4 @@ export {
|
|
|
2788
2925
|
renderMarkdown
|
|
2789
2926
|
};
|
|
2790
2927
|
|
|
2791
|
-
//# debugId=
|
|
2928
|
+
//# debugId=395AB57AA9F5395664756E2164756E21
|