1 | import "./chunk-V4OQ3NZ2.js";
|
---|
2 |
|
---|
3 | // node_modules/dompurify/dist/purify.es.js
|
---|
4 | function _typeof(obj) {
|
---|
5 | "@babel/helpers - typeof";
|
---|
6 | return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(obj2) {
|
---|
7 | return typeof obj2;
|
---|
8 | } : function(obj2) {
|
---|
9 | return obj2 && "function" == typeof Symbol && obj2.constructor === Symbol && obj2 !== Symbol.prototype ? "symbol" : typeof obj2;
|
---|
10 | }, _typeof(obj);
|
---|
11 | }
|
---|
12 | function _setPrototypeOf(o, p) {
|
---|
13 | _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf2(o2, p2) {
|
---|
14 | o2.__proto__ = p2;
|
---|
15 | return o2;
|
---|
16 | };
|
---|
17 | return _setPrototypeOf(o, p);
|
---|
18 | }
|
---|
19 | function _isNativeReflectConstruct() {
|
---|
20 | if (typeof Reflect === "undefined" || !Reflect.construct) return false;
|
---|
21 | if (Reflect.construct.sham) return false;
|
---|
22 | if (typeof Proxy === "function") return true;
|
---|
23 | try {
|
---|
24 | Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {
|
---|
25 | }));
|
---|
26 | return true;
|
---|
27 | } catch (e) {
|
---|
28 | return false;
|
---|
29 | }
|
---|
30 | }
|
---|
31 | function _construct(Parent, args, Class) {
|
---|
32 | if (_isNativeReflectConstruct()) {
|
---|
33 | _construct = Reflect.construct;
|
---|
34 | } else {
|
---|
35 | _construct = function _construct2(Parent2, args2, Class2) {
|
---|
36 | var a = [null];
|
---|
37 | a.push.apply(a, args2);
|
---|
38 | var Constructor = Function.bind.apply(Parent2, a);
|
---|
39 | var instance = new Constructor();
|
---|
40 | if (Class2) _setPrototypeOf(instance, Class2.prototype);
|
---|
41 | return instance;
|
---|
42 | };
|
---|
43 | }
|
---|
44 | return _construct.apply(null, arguments);
|
---|
45 | }
|
---|
46 | function _toConsumableArray(arr) {
|
---|
47 | return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
|
---|
48 | }
|
---|
49 | function _arrayWithoutHoles(arr) {
|
---|
50 | if (Array.isArray(arr)) return _arrayLikeToArray(arr);
|
---|
51 | }
|
---|
52 | function _iterableToArray(iter) {
|
---|
53 | if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
---|
54 | }
|
---|
55 | function _unsupportedIterableToArray(o, minLen) {
|
---|
56 | if (!o) return;
|
---|
57 | if (typeof o === "string") return _arrayLikeToArray(o, minLen);
|
---|
58 | var n = Object.prototype.toString.call(o).slice(8, -1);
|
---|
59 | if (n === "Object" && o.constructor) n = o.constructor.name;
|
---|
60 | if (n === "Map" || n === "Set") return Array.from(o);
|
---|
61 | if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
|
---|
62 | }
|
---|
63 | function _arrayLikeToArray(arr, len) {
|
---|
64 | if (len == null || len > arr.length) len = arr.length;
|
---|
65 | for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
|
---|
66 | return arr2;
|
---|
67 | }
|
---|
68 | function _nonIterableSpread() {
|
---|
69 | throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
---|
70 | }
|
---|
71 | var hasOwnProperty = Object.hasOwnProperty;
|
---|
72 | var setPrototypeOf = Object.setPrototypeOf;
|
---|
73 | var isFrozen = Object.isFrozen;
|
---|
74 | var getPrototypeOf = Object.getPrototypeOf;
|
---|
75 | var getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
|
---|
76 | var freeze = Object.freeze;
|
---|
77 | var seal = Object.seal;
|
---|
78 | var create = Object.create;
|
---|
79 | var _ref = typeof Reflect !== "undefined" && Reflect;
|
---|
80 | var apply = _ref.apply;
|
---|
81 | var construct = _ref.construct;
|
---|
82 | if (!apply) {
|
---|
83 | apply = function apply2(fun, thisValue, args) {
|
---|
84 | return fun.apply(thisValue, args);
|
---|
85 | };
|
---|
86 | }
|
---|
87 | if (!freeze) {
|
---|
88 | freeze = function freeze2(x) {
|
---|
89 | return x;
|
---|
90 | };
|
---|
91 | }
|
---|
92 | if (!seal) {
|
---|
93 | seal = function seal2(x) {
|
---|
94 | return x;
|
---|
95 | };
|
---|
96 | }
|
---|
97 | if (!construct) {
|
---|
98 | construct = function construct2(Func, args) {
|
---|
99 | return _construct(Func, _toConsumableArray(args));
|
---|
100 | };
|
---|
101 | }
|
---|
102 | var arrayForEach = unapply(Array.prototype.forEach);
|
---|
103 | var arrayPop = unapply(Array.prototype.pop);
|
---|
104 | var arrayPush = unapply(Array.prototype.push);
|
---|
105 | var stringToLowerCase = unapply(String.prototype.toLowerCase);
|
---|
106 | var stringToString = unapply(String.prototype.toString);
|
---|
107 | var stringMatch = unapply(String.prototype.match);
|
---|
108 | var stringReplace = unapply(String.prototype.replace);
|
---|
109 | var stringIndexOf = unapply(String.prototype.indexOf);
|
---|
110 | var stringTrim = unapply(String.prototype.trim);
|
---|
111 | var regExpTest = unapply(RegExp.prototype.test);
|
---|
112 | var typeErrorCreate = unconstruct(TypeError);
|
---|
113 | function unapply(func) {
|
---|
114 | return function(thisArg) {
|
---|
115 | for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
---|
116 | args[_key - 1] = arguments[_key];
|
---|
117 | }
|
---|
118 | return apply(func, thisArg, args);
|
---|
119 | };
|
---|
120 | }
|
---|
121 | function unconstruct(func) {
|
---|
122 | return function() {
|
---|
123 | for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
---|
124 | args[_key2] = arguments[_key2];
|
---|
125 | }
|
---|
126 | return construct(func, args);
|
---|
127 | };
|
---|
128 | }
|
---|
129 | function addToSet(set, array, transformCaseFunc) {
|
---|
130 | var _transformCaseFunc;
|
---|
131 | transformCaseFunc = (_transformCaseFunc = transformCaseFunc) !== null && _transformCaseFunc !== void 0 ? _transformCaseFunc : stringToLowerCase;
|
---|
132 | if (setPrototypeOf) {
|
---|
133 | setPrototypeOf(set, null);
|
---|
134 | }
|
---|
135 | var l = array.length;
|
---|
136 | while (l--) {
|
---|
137 | var element = array[l];
|
---|
138 | if (typeof element === "string") {
|
---|
139 | var lcElement = transformCaseFunc(element);
|
---|
140 | if (lcElement !== element) {
|
---|
141 | if (!isFrozen(array)) {
|
---|
142 | array[l] = lcElement;
|
---|
143 | }
|
---|
144 | element = lcElement;
|
---|
145 | }
|
---|
146 | }
|
---|
147 | set[element] = true;
|
---|
148 | }
|
---|
149 | return set;
|
---|
150 | }
|
---|
151 | function clone(object) {
|
---|
152 | var newObject = create(null);
|
---|
153 | var property;
|
---|
154 | for (property in object) {
|
---|
155 | if (apply(hasOwnProperty, object, [property]) === true) {
|
---|
156 | newObject[property] = object[property];
|
---|
157 | }
|
---|
158 | }
|
---|
159 | return newObject;
|
---|
160 | }
|
---|
161 | function lookupGetter(object, prop) {
|
---|
162 | while (object !== null) {
|
---|
163 | var desc = getOwnPropertyDescriptor(object, prop);
|
---|
164 | if (desc) {
|
---|
165 | if (desc.get) {
|
---|
166 | return unapply(desc.get);
|
---|
167 | }
|
---|
168 | if (typeof desc.value === "function") {
|
---|
169 | return unapply(desc.value);
|
---|
170 | }
|
---|
171 | }
|
---|
172 | object = getPrototypeOf(object);
|
---|
173 | }
|
---|
174 | function fallbackValue(element) {
|
---|
175 | console.warn("fallback value for", element);
|
---|
176 | return null;
|
---|
177 | }
|
---|
178 | return fallbackValue;
|
---|
179 | }
|
---|
180 | var html$1 = freeze(["a", "abbr", "acronym", "address", "area", "article", "aside", "audio", "b", "bdi", "bdo", "big", "blink", "blockquote", "body", "br", "button", "canvas", "caption", "center", "cite", "code", "col", "colgroup", "content", "data", "datalist", "dd", "decorator", "del", "details", "dfn", "dialog", "dir", "div", "dl", "dt", "element", "em", "fieldset", "figcaption", "figure", "font", "footer", "form", "h1", "h2", "h3", "h4", "h5", "h6", "head", "header", "hgroup", "hr", "html", "i", "img", "input", "ins", "kbd", "label", "legend", "li", "main", "map", "mark", "marquee", "menu", "menuitem", "meter", "nav", "nobr", "ol", "optgroup", "option", "output", "p", "picture", "pre", "progress", "q", "rp", "rt", "ruby", "s", "samp", "section", "select", "shadow", "small", "source", "spacer", "span", "strike", "strong", "style", "sub", "summary", "sup", "table", "tbody", "td", "template", "textarea", "tfoot", "th", "thead", "time", "tr", "track", "tt", "u", "ul", "var", "video", "wbr"]);
|
---|
181 | var svg$1 = freeze(["svg", "a", "altglyph", "altglyphdef", "altglyphitem", "animatecolor", "animatemotion", "animatetransform", "circle", "clippath", "defs", "desc", "ellipse", "filter", "font", "g", "glyph", "glyphref", "hkern", "image", "line", "lineargradient", "marker", "mask", "metadata", "mpath", "path", "pattern", "polygon", "polyline", "radialgradient", "rect", "stop", "style", "switch", "symbol", "text", "textpath", "title", "tref", "tspan", "view", "vkern"]);
|
---|
182 | var svgFilters = freeze(["feBlend", "feColorMatrix", "feComponentTransfer", "feComposite", "feConvolveMatrix", "feDiffuseLighting", "feDisplacementMap", "feDistantLight", "feFlood", "feFuncA", "feFuncB", "feFuncG", "feFuncR", "feGaussianBlur", "feImage", "feMerge", "feMergeNode", "feMorphology", "feOffset", "fePointLight", "feSpecularLighting", "feSpotLight", "feTile", "feTurbulence"]);
|
---|
183 | var svgDisallowed = freeze(["animate", "color-profile", "cursor", "discard", "fedropshadow", "font-face", "font-face-format", "font-face-name", "font-face-src", "font-face-uri", "foreignobject", "hatch", "hatchpath", "mesh", "meshgradient", "meshpatch", "meshrow", "missing-glyph", "script", "set", "solidcolor", "unknown", "use"]);
|
---|
184 | var mathMl$1 = freeze(["math", "menclose", "merror", "mfenced", "mfrac", "mglyph", "mi", "mlabeledtr", "mmultiscripts", "mn", "mo", "mover", "mpadded", "mphantom", "mroot", "mrow", "ms", "mspace", "msqrt", "mstyle", "msub", "msup", "msubsup", "mtable", "mtd", "mtext", "mtr", "munder", "munderover"]);
|
---|
185 | var mathMlDisallowed = freeze(["maction", "maligngroup", "malignmark", "mlongdiv", "mscarries", "mscarry", "msgroup", "mstack", "msline", "msrow", "semantics", "annotation", "annotation-xml", "mprescripts", "none"]);
|
---|
186 | var text = freeze(["#text"]);
|
---|
187 | var html = freeze(["accept", "action", "align", "alt", "autocapitalize", "autocomplete", "autopictureinpicture", "autoplay", "background", "bgcolor", "border", "capture", "cellpadding", "cellspacing", "checked", "cite", "class", "clear", "color", "cols", "colspan", "controls", "controlslist", "coords", "crossorigin", "datetime", "decoding", "default", "dir", "disabled", "disablepictureinpicture", "disableremoteplayback", "download", "draggable", "enctype", "enterkeyhint", "face", "for", "headers", "height", "hidden", "high", "href", "hreflang", "id", "inputmode", "integrity", "ismap", "kind", "label", "lang", "list", "loading", "loop", "low", "max", "maxlength", "media", "method", "min", "minlength", "multiple", "muted", "name", "nonce", "noshade", "novalidate", "nowrap", "open", "optimum", "pattern", "placeholder", "playsinline", "poster", "preload", "pubdate", "radiogroup", "readonly", "rel", "required", "rev", "reversed", "role", "rows", "rowspan", "spellcheck", "scope", "selected", "shape", "size", "sizes", "span", "srclang", "start", "src", "srcset", "step", "style", "summary", "tabindex", "title", "translate", "type", "usemap", "valign", "value", "width", "xmlns", "slot"]);
|
---|
188 | var svg = freeze(["accent-height", "accumulate", "additive", "alignment-baseline", "ascent", "attributename", "attributetype", "azimuth", "basefrequency", "baseline-shift", "begin", "bias", "by", "class", "clip", "clippathunits", "clip-path", "clip-rule", "color", "color-interpolation", "color-interpolation-filters", "color-profile", "color-rendering", "cx", "cy", "d", "dx", "dy", "diffuseconstant", "direction", "display", "divisor", "dur", "edgemode", "elevation", "end", "fill", "fill-opacity", "fill-rule", "filter", "filterunits", "flood-color", "flood-opacity", "font-family", "font-size", "font-size-adjust", "font-stretch", "font-style", "font-variant", "font-weight", "fx", "fy", "g1", "g2", "glyph-name", "glyphref", "gradientunits", "gradienttransform", "height", "href", "id", "image-rendering", "in", "in2", "k", "k1", "k2", "k3", "k4", "kerning", "keypoints", "keysplines", "keytimes", "lang", "lengthadjust", "letter-spacing", "kernelmatrix", "kernelunitlength", "lighting-color", "local", "marker-end", "marker-mid", "marker-start", "markerheight", "markerunits", "markerwidth", "maskcontentunits", "maskunits", "max", "mask", "media", "method", "mode", "min", "name", "numoctaves", "offset", "operator", "opacity", "order", "orient", "orientation", "origin", "overflow", "paint-order", "path", "pathlength", "patterncontentunits", "patterntransform", "patternunits", "points", "preservealpha", "preserveaspectratio", "primitiveunits", "r", "rx", "ry", "radius", "refx", "refy", "repeatcount", "repeatdur", "restart", "result", "rotate", "scale", "seed", "shape-rendering", "specularconstant", "specularexponent", "spreadmethod", "startoffset", "stddeviation", "stitchtiles", "stop-color", "stop-opacity", "stroke-dasharray", "stroke-dashoffset", "stroke-linecap", "stroke-linejoin", "stroke-miterlimit", "stroke-opacity", "stroke", "stroke-width", "style", "surfacescale", "systemlanguage", "tabindex", "targetx", "targety", "transform", "transform-origin", "text-anchor", "text-decoration", "text-rendering", "textlength", "type", "u1", "u2", "unicode", "values", "viewbox", "visibility", "version", "vert-adv-y", "vert-origin-x", "vert-origin-y", "width", "word-spacing", "wrap", "writing-mode", "xchannelselector", "ychannelselector", "x", "x1", "x2", "xmlns", "y", "y1", "y2", "z", "zoomandpan"]);
|
---|
189 | var mathMl = freeze(["accent", "accentunder", "align", "bevelled", "close", "columnsalign", "columnlines", "columnspan", "denomalign", "depth", "dir", "display", "displaystyle", "encoding", "fence", "frame", "height", "href", "id", "largeop", "length", "linethickness", "lspace", "lquote", "mathbackground", "mathcolor", "mathsize", "mathvariant", "maxsize", "minsize", "movablelimits", "notation", "numalign", "open", "rowalign", "rowlines", "rowspacing", "rowspan", "rspace", "rquote", "scriptlevel", "scriptminsize", "scriptsizemultiplier", "selection", "separator", "separators", "stretchy", "subscriptshift", "supscriptshift", "symmetric", "voffset", "width", "xmlns"]);
|
---|
190 | var xml = freeze(["xlink:href", "xml:id", "xlink:title", "xml:space", "xmlns:xlink"]);
|
---|
191 | var MUSTACHE_EXPR = seal(/\{\{[\w\W]*|[\w\W]*\}\}/gm);
|
---|
192 | var ERB_EXPR = seal(/<%[\w\W]*|[\w\W]*%>/gm);
|
---|
193 | var TMPLIT_EXPR = seal(/\${[\w\W]*}/gm);
|
---|
194 | var DATA_ATTR = seal(/^data-[\-\w.\u00B7-\uFFFF]+$/);
|
---|
195 | var ARIA_ATTR = seal(/^aria-[\-\w]+$/);
|
---|
196 | var IS_ALLOWED_URI = seal(
|
---|
197 | /^(?:(?:(?:f|ht)tps?|mailto|tel|callto|cid|xmpp):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i
|
---|
198 | // eslint-disable-line no-useless-escape
|
---|
199 | );
|
---|
200 | var IS_SCRIPT_OR_DATA = seal(/^(?:\w+script|data):/i);
|
---|
201 | var ATTR_WHITESPACE = seal(
|
---|
202 | /[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g
|
---|
203 | // eslint-disable-line no-control-regex
|
---|
204 | );
|
---|
205 | var DOCTYPE_NAME = seal(/^html$/i);
|
---|
206 | var CUSTOM_ELEMENT = seal(/^[a-z][.\w]*(-[.\w]+)+$/i);
|
---|
207 | var getGlobal = function getGlobal2() {
|
---|
208 | return typeof window === "undefined" ? null : window;
|
---|
209 | };
|
---|
210 | var _createTrustedTypesPolicy = function _createTrustedTypesPolicy2(trustedTypes, document) {
|
---|
211 | if (_typeof(trustedTypes) !== "object" || typeof trustedTypes.createPolicy !== "function") {
|
---|
212 | return null;
|
---|
213 | }
|
---|
214 | var suffix = null;
|
---|
215 | var ATTR_NAME = "data-tt-policy-suffix";
|
---|
216 | if (document.currentScript && document.currentScript.hasAttribute(ATTR_NAME)) {
|
---|
217 | suffix = document.currentScript.getAttribute(ATTR_NAME);
|
---|
218 | }
|
---|
219 | var policyName = "dompurify" + (suffix ? "#" + suffix : "");
|
---|
220 | try {
|
---|
221 | return trustedTypes.createPolicy(policyName, {
|
---|
222 | createHTML: function createHTML(html2) {
|
---|
223 | return html2;
|
---|
224 | },
|
---|
225 | createScriptURL: function createScriptURL(scriptUrl) {
|
---|
226 | return scriptUrl;
|
---|
227 | }
|
---|
228 | });
|
---|
229 | } catch (_) {
|
---|
230 | console.warn("TrustedTypes policy " + policyName + " could not be created.");
|
---|
231 | return null;
|
---|
232 | }
|
---|
233 | };
|
---|
234 | function createDOMPurify() {
|
---|
235 | var window2 = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : getGlobal();
|
---|
236 | var DOMPurify = function DOMPurify2(root) {
|
---|
237 | return createDOMPurify(root);
|
---|
238 | };
|
---|
239 | DOMPurify.version = "2.5.8";
|
---|
240 | DOMPurify.removed = [];
|
---|
241 | if (!window2 || !window2.document || window2.document.nodeType !== 9) {
|
---|
242 | DOMPurify.isSupported = false;
|
---|
243 | return DOMPurify;
|
---|
244 | }
|
---|
245 | var originalDocument = window2.document;
|
---|
246 | var document = window2.document;
|
---|
247 | var DocumentFragment = window2.DocumentFragment, HTMLTemplateElement = window2.HTMLTemplateElement, Node = window2.Node, Element = window2.Element, NodeFilter = window2.NodeFilter, _window$NamedNodeMap = window2.NamedNodeMap, NamedNodeMap = _window$NamedNodeMap === void 0 ? window2.NamedNodeMap || window2.MozNamedAttrMap : _window$NamedNodeMap, HTMLFormElement = window2.HTMLFormElement, DOMParser = window2.DOMParser, trustedTypes = window2.trustedTypes;
|
---|
248 | var ElementPrototype = Element.prototype;
|
---|
249 | var cloneNode = lookupGetter(ElementPrototype, "cloneNode");
|
---|
250 | var getNextSibling = lookupGetter(ElementPrototype, "nextSibling");
|
---|
251 | var getChildNodes = lookupGetter(ElementPrototype, "childNodes");
|
---|
252 | var getParentNode = lookupGetter(ElementPrototype, "parentNode");
|
---|
253 | if (typeof HTMLTemplateElement === "function") {
|
---|
254 | var template = document.createElement("template");
|
---|
255 | if (template.content && template.content.ownerDocument) {
|
---|
256 | document = template.content.ownerDocument;
|
---|
257 | }
|
---|
258 | }
|
---|
259 | var trustedTypesPolicy = _createTrustedTypesPolicy(trustedTypes, originalDocument);
|
---|
260 | var emptyHTML = trustedTypesPolicy ? trustedTypesPolicy.createHTML("") : "";
|
---|
261 | var _document = document, implementation = _document.implementation, createNodeIterator = _document.createNodeIterator, createDocumentFragment = _document.createDocumentFragment, getElementsByTagName = _document.getElementsByTagName;
|
---|
262 | var importNode = originalDocument.importNode;
|
---|
263 | var documentMode = {};
|
---|
264 | try {
|
---|
265 | documentMode = clone(document).documentMode ? document.documentMode : {};
|
---|
266 | } catch (_) {
|
---|
267 | }
|
---|
268 | var hooks = {};
|
---|
269 | DOMPurify.isSupported = typeof getParentNode === "function" && implementation && implementation.createHTMLDocument !== void 0 && documentMode !== 9;
|
---|
270 | var MUSTACHE_EXPR$1 = MUSTACHE_EXPR, ERB_EXPR$1 = ERB_EXPR, TMPLIT_EXPR$1 = TMPLIT_EXPR, DATA_ATTR$1 = DATA_ATTR, ARIA_ATTR$1 = ARIA_ATTR, IS_SCRIPT_OR_DATA$1 = IS_SCRIPT_OR_DATA, ATTR_WHITESPACE$1 = ATTR_WHITESPACE, CUSTOM_ELEMENT$1 = CUSTOM_ELEMENT;
|
---|
271 | var IS_ALLOWED_URI$1 = IS_ALLOWED_URI;
|
---|
272 | var ALLOWED_TAGS = null;
|
---|
273 | var DEFAULT_ALLOWED_TAGS = addToSet({}, [].concat(_toConsumableArray(html$1), _toConsumableArray(svg$1), _toConsumableArray(svgFilters), _toConsumableArray(mathMl$1), _toConsumableArray(text)));
|
---|
274 | var ALLOWED_ATTR = null;
|
---|
275 | var DEFAULT_ALLOWED_ATTR = addToSet({}, [].concat(_toConsumableArray(html), _toConsumableArray(svg), _toConsumableArray(mathMl), _toConsumableArray(xml)));
|
---|
276 | var CUSTOM_ELEMENT_HANDLING = Object.seal(Object.create(null, {
|
---|
277 | tagNameCheck: {
|
---|
278 | writable: true,
|
---|
279 | configurable: false,
|
---|
280 | enumerable: true,
|
---|
281 | value: null
|
---|
282 | },
|
---|
283 | attributeNameCheck: {
|
---|
284 | writable: true,
|
---|
285 | configurable: false,
|
---|
286 | enumerable: true,
|
---|
287 | value: null
|
---|
288 | },
|
---|
289 | allowCustomizedBuiltInElements: {
|
---|
290 | writable: true,
|
---|
291 | configurable: false,
|
---|
292 | enumerable: true,
|
---|
293 | value: false
|
---|
294 | }
|
---|
295 | }));
|
---|
296 | var FORBID_TAGS = null;
|
---|
297 | var FORBID_ATTR = null;
|
---|
298 | var ALLOW_ARIA_ATTR = true;
|
---|
299 | var ALLOW_DATA_ATTR = true;
|
---|
300 | var ALLOW_UNKNOWN_PROTOCOLS = false;
|
---|
301 | var ALLOW_SELF_CLOSE_IN_ATTR = true;
|
---|
302 | var SAFE_FOR_TEMPLATES = false;
|
---|
303 | var SAFE_FOR_XML = true;
|
---|
304 | var WHOLE_DOCUMENT = false;
|
---|
305 | var SET_CONFIG = false;
|
---|
306 | var FORCE_BODY = false;
|
---|
307 | var RETURN_DOM = false;
|
---|
308 | var RETURN_DOM_FRAGMENT = false;
|
---|
309 | var RETURN_TRUSTED_TYPE = false;
|
---|
310 | var SANITIZE_DOM = true;
|
---|
311 | var SANITIZE_NAMED_PROPS = false;
|
---|
312 | var SANITIZE_NAMED_PROPS_PREFIX = "user-content-";
|
---|
313 | var KEEP_CONTENT = true;
|
---|
314 | var IN_PLACE = false;
|
---|
315 | var USE_PROFILES = {};
|
---|
316 | var FORBID_CONTENTS = null;
|
---|
317 | var DEFAULT_FORBID_CONTENTS = addToSet({}, ["annotation-xml", "audio", "colgroup", "desc", "foreignobject", "head", "iframe", "math", "mi", "mn", "mo", "ms", "mtext", "noembed", "noframes", "noscript", "plaintext", "script", "style", "svg", "template", "thead", "title", "video", "xmp"]);
|
---|
318 | var DATA_URI_TAGS = null;
|
---|
319 | var DEFAULT_DATA_URI_TAGS = addToSet({}, ["audio", "video", "img", "source", "image", "track"]);
|
---|
320 | var URI_SAFE_ATTRIBUTES = null;
|
---|
321 | var DEFAULT_URI_SAFE_ATTRIBUTES = addToSet({}, ["alt", "class", "for", "id", "label", "name", "pattern", "placeholder", "role", "summary", "title", "value", "style", "xmlns"]);
|
---|
322 | var MATHML_NAMESPACE = "http://www.w3.org/1998/Math/MathML";
|
---|
323 | var SVG_NAMESPACE = "http://www.w3.org/2000/svg";
|
---|
324 | var HTML_NAMESPACE = "http://www.w3.org/1999/xhtml";
|
---|
325 | var NAMESPACE = HTML_NAMESPACE;
|
---|
326 | var IS_EMPTY_INPUT = false;
|
---|
327 | var ALLOWED_NAMESPACES = null;
|
---|
328 | var DEFAULT_ALLOWED_NAMESPACES = addToSet({}, [MATHML_NAMESPACE, SVG_NAMESPACE, HTML_NAMESPACE], stringToString);
|
---|
329 | var PARSER_MEDIA_TYPE;
|
---|
330 | var SUPPORTED_PARSER_MEDIA_TYPES = ["application/xhtml+xml", "text/html"];
|
---|
331 | var DEFAULT_PARSER_MEDIA_TYPE = "text/html";
|
---|
332 | var transformCaseFunc;
|
---|
333 | var CONFIG = null;
|
---|
334 | var formElement = document.createElement("form");
|
---|
335 | var isRegexOrFunction = function isRegexOrFunction2(testValue) {
|
---|
336 | return testValue instanceof RegExp || testValue instanceof Function;
|
---|
337 | };
|
---|
338 | var _parseConfig = function _parseConfig2(cfg) {
|
---|
339 | if (CONFIG && CONFIG === cfg) {
|
---|
340 | return;
|
---|
341 | }
|
---|
342 | if (!cfg || _typeof(cfg) !== "object") {
|
---|
343 | cfg = {};
|
---|
344 | }
|
---|
345 | cfg = clone(cfg);
|
---|
346 | PARSER_MEDIA_TYPE = // eslint-disable-next-line unicorn/prefer-includes
|
---|
347 | SUPPORTED_PARSER_MEDIA_TYPES.indexOf(cfg.PARSER_MEDIA_TYPE) === -1 ? PARSER_MEDIA_TYPE = DEFAULT_PARSER_MEDIA_TYPE : PARSER_MEDIA_TYPE = cfg.PARSER_MEDIA_TYPE;
|
---|
348 | transformCaseFunc = PARSER_MEDIA_TYPE === "application/xhtml+xml" ? stringToString : stringToLowerCase;
|
---|
349 | ALLOWED_TAGS = "ALLOWED_TAGS" in cfg ? addToSet({}, cfg.ALLOWED_TAGS, transformCaseFunc) : DEFAULT_ALLOWED_TAGS;
|
---|
350 | ALLOWED_ATTR = "ALLOWED_ATTR" in cfg ? addToSet({}, cfg.ALLOWED_ATTR, transformCaseFunc) : DEFAULT_ALLOWED_ATTR;
|
---|
351 | ALLOWED_NAMESPACES = "ALLOWED_NAMESPACES" in cfg ? addToSet({}, cfg.ALLOWED_NAMESPACES, stringToString) : DEFAULT_ALLOWED_NAMESPACES;
|
---|
352 | URI_SAFE_ATTRIBUTES = "ADD_URI_SAFE_ATTR" in cfg ? addToSet(
|
---|
353 | clone(DEFAULT_URI_SAFE_ATTRIBUTES),
|
---|
354 | // eslint-disable-line indent
|
---|
355 | cfg.ADD_URI_SAFE_ATTR,
|
---|
356 | // eslint-disable-line indent
|
---|
357 | transformCaseFunc
|
---|
358 | // eslint-disable-line indent
|
---|
359 | ) : DEFAULT_URI_SAFE_ATTRIBUTES;
|
---|
360 | DATA_URI_TAGS = "ADD_DATA_URI_TAGS" in cfg ? addToSet(
|
---|
361 | clone(DEFAULT_DATA_URI_TAGS),
|
---|
362 | // eslint-disable-line indent
|
---|
363 | cfg.ADD_DATA_URI_TAGS,
|
---|
364 | // eslint-disable-line indent
|
---|
365 | transformCaseFunc
|
---|
366 | // eslint-disable-line indent
|
---|
367 | ) : DEFAULT_DATA_URI_TAGS;
|
---|
368 | FORBID_CONTENTS = "FORBID_CONTENTS" in cfg ? addToSet({}, cfg.FORBID_CONTENTS, transformCaseFunc) : DEFAULT_FORBID_CONTENTS;
|
---|
369 | FORBID_TAGS = "FORBID_TAGS" in cfg ? addToSet({}, cfg.FORBID_TAGS, transformCaseFunc) : {};
|
---|
370 | FORBID_ATTR = "FORBID_ATTR" in cfg ? addToSet({}, cfg.FORBID_ATTR, transformCaseFunc) : {};
|
---|
371 | USE_PROFILES = "USE_PROFILES" in cfg ? cfg.USE_PROFILES : false;
|
---|
372 | ALLOW_ARIA_ATTR = cfg.ALLOW_ARIA_ATTR !== false;
|
---|
373 | ALLOW_DATA_ATTR = cfg.ALLOW_DATA_ATTR !== false;
|
---|
374 | ALLOW_UNKNOWN_PROTOCOLS = cfg.ALLOW_UNKNOWN_PROTOCOLS || false;
|
---|
375 | ALLOW_SELF_CLOSE_IN_ATTR = cfg.ALLOW_SELF_CLOSE_IN_ATTR !== false;
|
---|
376 | SAFE_FOR_TEMPLATES = cfg.SAFE_FOR_TEMPLATES || false;
|
---|
377 | SAFE_FOR_XML = cfg.SAFE_FOR_XML !== false;
|
---|
378 | WHOLE_DOCUMENT = cfg.WHOLE_DOCUMENT || false;
|
---|
379 | RETURN_DOM = cfg.RETURN_DOM || false;
|
---|
380 | RETURN_DOM_FRAGMENT = cfg.RETURN_DOM_FRAGMENT || false;
|
---|
381 | RETURN_TRUSTED_TYPE = cfg.RETURN_TRUSTED_TYPE || false;
|
---|
382 | FORCE_BODY = cfg.FORCE_BODY || false;
|
---|
383 | SANITIZE_DOM = cfg.SANITIZE_DOM !== false;
|
---|
384 | SANITIZE_NAMED_PROPS = cfg.SANITIZE_NAMED_PROPS || false;
|
---|
385 | KEEP_CONTENT = cfg.KEEP_CONTENT !== false;
|
---|
386 | IN_PLACE = cfg.IN_PLACE || false;
|
---|
387 | IS_ALLOWED_URI$1 = cfg.ALLOWED_URI_REGEXP || IS_ALLOWED_URI$1;
|
---|
388 | NAMESPACE = cfg.NAMESPACE || HTML_NAMESPACE;
|
---|
389 | CUSTOM_ELEMENT_HANDLING = cfg.CUSTOM_ELEMENT_HANDLING || {};
|
---|
390 | if (cfg.CUSTOM_ELEMENT_HANDLING && isRegexOrFunction(cfg.CUSTOM_ELEMENT_HANDLING.tagNameCheck)) {
|
---|
391 | CUSTOM_ELEMENT_HANDLING.tagNameCheck = cfg.CUSTOM_ELEMENT_HANDLING.tagNameCheck;
|
---|
392 | }
|
---|
393 | if (cfg.CUSTOM_ELEMENT_HANDLING && isRegexOrFunction(cfg.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)) {
|
---|
394 | CUSTOM_ELEMENT_HANDLING.attributeNameCheck = cfg.CUSTOM_ELEMENT_HANDLING.attributeNameCheck;
|
---|
395 | }
|
---|
396 | if (cfg.CUSTOM_ELEMENT_HANDLING && typeof cfg.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements === "boolean") {
|
---|
397 | CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements = cfg.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements;
|
---|
398 | }
|
---|
399 | if (SAFE_FOR_TEMPLATES) {
|
---|
400 | ALLOW_DATA_ATTR = false;
|
---|
401 | }
|
---|
402 | if (RETURN_DOM_FRAGMENT) {
|
---|
403 | RETURN_DOM = true;
|
---|
404 | }
|
---|
405 | if (USE_PROFILES) {
|
---|
406 | ALLOWED_TAGS = addToSet({}, _toConsumableArray(text));
|
---|
407 | ALLOWED_ATTR = [];
|
---|
408 | if (USE_PROFILES.html === true) {
|
---|
409 | addToSet(ALLOWED_TAGS, html$1);
|
---|
410 | addToSet(ALLOWED_ATTR, html);
|
---|
411 | }
|
---|
412 | if (USE_PROFILES.svg === true) {
|
---|
413 | addToSet(ALLOWED_TAGS, svg$1);
|
---|
414 | addToSet(ALLOWED_ATTR, svg);
|
---|
415 | addToSet(ALLOWED_ATTR, xml);
|
---|
416 | }
|
---|
417 | if (USE_PROFILES.svgFilters === true) {
|
---|
418 | addToSet(ALLOWED_TAGS, svgFilters);
|
---|
419 | addToSet(ALLOWED_ATTR, svg);
|
---|
420 | addToSet(ALLOWED_ATTR, xml);
|
---|
421 | }
|
---|
422 | if (USE_PROFILES.mathMl === true) {
|
---|
423 | addToSet(ALLOWED_TAGS, mathMl$1);
|
---|
424 | addToSet(ALLOWED_ATTR, mathMl);
|
---|
425 | addToSet(ALLOWED_ATTR, xml);
|
---|
426 | }
|
---|
427 | }
|
---|
428 | if (cfg.ADD_TAGS) {
|
---|
429 | if (ALLOWED_TAGS === DEFAULT_ALLOWED_TAGS) {
|
---|
430 | ALLOWED_TAGS = clone(ALLOWED_TAGS);
|
---|
431 | }
|
---|
432 | addToSet(ALLOWED_TAGS, cfg.ADD_TAGS, transformCaseFunc);
|
---|
433 | }
|
---|
434 | if (cfg.ADD_ATTR) {
|
---|
435 | if (ALLOWED_ATTR === DEFAULT_ALLOWED_ATTR) {
|
---|
436 | ALLOWED_ATTR = clone(ALLOWED_ATTR);
|
---|
437 | }
|
---|
438 | addToSet(ALLOWED_ATTR, cfg.ADD_ATTR, transformCaseFunc);
|
---|
439 | }
|
---|
440 | if (cfg.ADD_URI_SAFE_ATTR) {
|
---|
441 | addToSet(URI_SAFE_ATTRIBUTES, cfg.ADD_URI_SAFE_ATTR, transformCaseFunc);
|
---|
442 | }
|
---|
443 | if (cfg.FORBID_CONTENTS) {
|
---|
444 | if (FORBID_CONTENTS === DEFAULT_FORBID_CONTENTS) {
|
---|
445 | FORBID_CONTENTS = clone(FORBID_CONTENTS);
|
---|
446 | }
|
---|
447 | addToSet(FORBID_CONTENTS, cfg.FORBID_CONTENTS, transformCaseFunc);
|
---|
448 | }
|
---|
449 | if (KEEP_CONTENT) {
|
---|
450 | ALLOWED_TAGS["#text"] = true;
|
---|
451 | }
|
---|
452 | if (WHOLE_DOCUMENT) {
|
---|
453 | addToSet(ALLOWED_TAGS, ["html", "head", "body"]);
|
---|
454 | }
|
---|
455 | if (ALLOWED_TAGS.table) {
|
---|
456 | addToSet(ALLOWED_TAGS, ["tbody"]);
|
---|
457 | delete FORBID_TAGS.tbody;
|
---|
458 | }
|
---|
459 | if (freeze) {
|
---|
460 | freeze(cfg);
|
---|
461 | }
|
---|
462 | CONFIG = cfg;
|
---|
463 | };
|
---|
464 | var MATHML_TEXT_INTEGRATION_POINTS = addToSet({}, ["mi", "mo", "mn", "ms", "mtext"]);
|
---|
465 | var HTML_INTEGRATION_POINTS = addToSet({}, ["annotation-xml"]);
|
---|
466 | var COMMON_SVG_AND_HTML_ELEMENTS = addToSet({}, ["title", "style", "font", "a", "script"]);
|
---|
467 | var ALL_SVG_TAGS = addToSet({}, svg$1);
|
---|
468 | addToSet(ALL_SVG_TAGS, svgFilters);
|
---|
469 | addToSet(ALL_SVG_TAGS, svgDisallowed);
|
---|
470 | var ALL_MATHML_TAGS = addToSet({}, mathMl$1);
|
---|
471 | addToSet(ALL_MATHML_TAGS, mathMlDisallowed);
|
---|
472 | var _checkValidNamespace = function _checkValidNamespace2(element) {
|
---|
473 | var parent = getParentNode(element);
|
---|
474 | if (!parent || !parent.tagName) {
|
---|
475 | parent = {
|
---|
476 | namespaceURI: NAMESPACE,
|
---|
477 | tagName: "template"
|
---|
478 | };
|
---|
479 | }
|
---|
480 | var tagName = stringToLowerCase(element.tagName);
|
---|
481 | var parentTagName = stringToLowerCase(parent.tagName);
|
---|
482 | if (!ALLOWED_NAMESPACES[element.namespaceURI]) {
|
---|
483 | return false;
|
---|
484 | }
|
---|
485 | if (element.namespaceURI === SVG_NAMESPACE) {
|
---|
486 | if (parent.namespaceURI === HTML_NAMESPACE) {
|
---|
487 | return tagName === "svg";
|
---|
488 | }
|
---|
489 | if (parent.namespaceURI === MATHML_NAMESPACE) {
|
---|
490 | return tagName === "svg" && (parentTagName === "annotation-xml" || MATHML_TEXT_INTEGRATION_POINTS[parentTagName]);
|
---|
491 | }
|
---|
492 | return Boolean(ALL_SVG_TAGS[tagName]);
|
---|
493 | }
|
---|
494 | if (element.namespaceURI === MATHML_NAMESPACE) {
|
---|
495 | if (parent.namespaceURI === HTML_NAMESPACE) {
|
---|
496 | return tagName === "math";
|
---|
497 | }
|
---|
498 | if (parent.namespaceURI === SVG_NAMESPACE) {
|
---|
499 | return tagName === "math" && HTML_INTEGRATION_POINTS[parentTagName];
|
---|
500 | }
|
---|
501 | return Boolean(ALL_MATHML_TAGS[tagName]);
|
---|
502 | }
|
---|
503 | if (element.namespaceURI === HTML_NAMESPACE) {
|
---|
504 | if (parent.namespaceURI === SVG_NAMESPACE && !HTML_INTEGRATION_POINTS[parentTagName]) {
|
---|
505 | return false;
|
---|
506 | }
|
---|
507 | if (parent.namespaceURI === MATHML_NAMESPACE && !MATHML_TEXT_INTEGRATION_POINTS[parentTagName]) {
|
---|
508 | return false;
|
---|
509 | }
|
---|
510 | return !ALL_MATHML_TAGS[tagName] && (COMMON_SVG_AND_HTML_ELEMENTS[tagName] || !ALL_SVG_TAGS[tagName]);
|
---|
511 | }
|
---|
512 | if (PARSER_MEDIA_TYPE === "application/xhtml+xml" && ALLOWED_NAMESPACES[element.namespaceURI]) {
|
---|
513 | return true;
|
---|
514 | }
|
---|
515 | return false;
|
---|
516 | };
|
---|
517 | var _forceRemove = function _forceRemove2(node) {
|
---|
518 | arrayPush(DOMPurify.removed, {
|
---|
519 | element: node
|
---|
520 | });
|
---|
521 | try {
|
---|
522 | node.parentNode.removeChild(node);
|
---|
523 | } catch (_) {
|
---|
524 | try {
|
---|
525 | node.outerHTML = emptyHTML;
|
---|
526 | } catch (_2) {
|
---|
527 | node.remove();
|
---|
528 | }
|
---|
529 | }
|
---|
530 | };
|
---|
531 | var _removeAttribute = function _removeAttribute2(name, node) {
|
---|
532 | try {
|
---|
533 | arrayPush(DOMPurify.removed, {
|
---|
534 | attribute: node.getAttributeNode(name),
|
---|
535 | from: node
|
---|
536 | });
|
---|
537 | } catch (_) {
|
---|
538 | arrayPush(DOMPurify.removed, {
|
---|
539 | attribute: null,
|
---|
540 | from: node
|
---|
541 | });
|
---|
542 | }
|
---|
543 | node.removeAttribute(name);
|
---|
544 | if (name === "is" && !ALLOWED_ATTR[name]) {
|
---|
545 | if (RETURN_DOM || RETURN_DOM_FRAGMENT) {
|
---|
546 | try {
|
---|
547 | _forceRemove(node);
|
---|
548 | } catch (_) {
|
---|
549 | }
|
---|
550 | } else {
|
---|
551 | try {
|
---|
552 | node.setAttribute(name, "");
|
---|
553 | } catch (_) {
|
---|
554 | }
|
---|
555 | }
|
---|
556 | }
|
---|
557 | };
|
---|
558 | var _initDocument = function _initDocument2(dirty) {
|
---|
559 | var doc;
|
---|
560 | var leadingWhitespace;
|
---|
561 | if (FORCE_BODY) {
|
---|
562 | dirty = "<remove></remove>" + dirty;
|
---|
563 | } else {
|
---|
564 | var matches = stringMatch(dirty, /^[\r\n\t ]+/);
|
---|
565 | leadingWhitespace = matches && matches[0];
|
---|
566 | }
|
---|
567 | if (PARSER_MEDIA_TYPE === "application/xhtml+xml" && NAMESPACE === HTML_NAMESPACE) {
|
---|
568 | dirty = '<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>' + dirty + "</body></html>";
|
---|
569 | }
|
---|
570 | var dirtyPayload = trustedTypesPolicy ? trustedTypesPolicy.createHTML(dirty) : dirty;
|
---|
571 | if (NAMESPACE === HTML_NAMESPACE) {
|
---|
572 | try {
|
---|
573 | doc = new DOMParser().parseFromString(dirtyPayload, PARSER_MEDIA_TYPE);
|
---|
574 | } catch (_) {
|
---|
575 | }
|
---|
576 | }
|
---|
577 | if (!doc || !doc.documentElement) {
|
---|
578 | doc = implementation.createDocument(NAMESPACE, "template", null);
|
---|
579 | try {
|
---|
580 | doc.documentElement.innerHTML = IS_EMPTY_INPUT ? emptyHTML : dirtyPayload;
|
---|
581 | } catch (_) {
|
---|
582 | }
|
---|
583 | }
|
---|
584 | var body = doc.body || doc.documentElement;
|
---|
585 | if (dirty && leadingWhitespace) {
|
---|
586 | body.insertBefore(document.createTextNode(leadingWhitespace), body.childNodes[0] || null);
|
---|
587 | }
|
---|
588 | if (NAMESPACE === HTML_NAMESPACE) {
|
---|
589 | return getElementsByTagName.call(doc, WHOLE_DOCUMENT ? "html" : "body")[0];
|
---|
590 | }
|
---|
591 | return WHOLE_DOCUMENT ? doc.documentElement : body;
|
---|
592 | };
|
---|
593 | var _createIterator = function _createIterator2(root) {
|
---|
594 | return createNodeIterator.call(
|
---|
595 | root.ownerDocument || root,
|
---|
596 | root,
|
---|
597 | // eslint-disable-next-line no-bitwise
|
---|
598 | NodeFilter.SHOW_ELEMENT | NodeFilter.SHOW_COMMENT | NodeFilter.SHOW_TEXT | NodeFilter.SHOW_PROCESSING_INSTRUCTION | NodeFilter.SHOW_CDATA_SECTION,
|
---|
599 | null,
|
---|
600 | false
|
---|
601 | );
|
---|
602 | };
|
---|
603 | var _isClobbered = function _isClobbered2(elm) {
|
---|
604 | return elm instanceof HTMLFormElement && (typeof elm.nodeName !== "string" || typeof elm.textContent !== "string" || typeof elm.removeChild !== "function" || !(elm.attributes instanceof NamedNodeMap) || typeof elm.removeAttribute !== "function" || typeof elm.setAttribute !== "function" || typeof elm.namespaceURI !== "string" || typeof elm.insertBefore !== "function" || typeof elm.hasChildNodes !== "function");
|
---|
605 | };
|
---|
606 | var _isNode = function _isNode2(object) {
|
---|
607 | return _typeof(Node) === "object" ? object instanceof Node : object && _typeof(object) === "object" && typeof object.nodeType === "number" && typeof object.nodeName === "string";
|
---|
608 | };
|
---|
609 | var _executeHook = function _executeHook2(entryPoint, currentNode, data) {
|
---|
610 | if (!hooks[entryPoint]) {
|
---|
611 | return;
|
---|
612 | }
|
---|
613 | arrayForEach(hooks[entryPoint], function(hook) {
|
---|
614 | hook.call(DOMPurify, currentNode, data, CONFIG);
|
---|
615 | });
|
---|
616 | };
|
---|
617 | var _sanitizeElements = function _sanitizeElements2(currentNode) {
|
---|
618 | var content;
|
---|
619 | _executeHook("beforeSanitizeElements", currentNode, null);
|
---|
620 | if (_isClobbered(currentNode)) {
|
---|
621 | _forceRemove(currentNode);
|
---|
622 | return true;
|
---|
623 | }
|
---|
624 | if (regExpTest(/[\u0080-\uFFFF]/, currentNode.nodeName)) {
|
---|
625 | _forceRemove(currentNode);
|
---|
626 | return true;
|
---|
627 | }
|
---|
628 | var tagName = transformCaseFunc(currentNode.nodeName);
|
---|
629 | _executeHook("uponSanitizeElement", currentNode, {
|
---|
630 | tagName,
|
---|
631 | allowedTags: ALLOWED_TAGS
|
---|
632 | });
|
---|
633 | if (currentNode.hasChildNodes() && !_isNode(currentNode.firstElementChild) && (!_isNode(currentNode.content) || !_isNode(currentNode.content.firstElementChild)) && regExpTest(/<[/\w]/g, currentNode.innerHTML) && regExpTest(/<[/\w]/g, currentNode.textContent)) {
|
---|
634 | _forceRemove(currentNode);
|
---|
635 | return true;
|
---|
636 | }
|
---|
637 | if (tagName === "select" && regExpTest(/<template/i, currentNode.innerHTML)) {
|
---|
638 | _forceRemove(currentNode);
|
---|
639 | return true;
|
---|
640 | }
|
---|
641 | if (currentNode.nodeType === 7) {
|
---|
642 | _forceRemove(currentNode);
|
---|
643 | return true;
|
---|
644 | }
|
---|
645 | if (SAFE_FOR_XML && currentNode.nodeType === 8 && regExpTest(/<[/\w]/g, currentNode.data)) {
|
---|
646 | _forceRemove(currentNode);
|
---|
647 | return true;
|
---|
648 | }
|
---|
649 | if (!ALLOWED_TAGS[tagName] || FORBID_TAGS[tagName]) {
|
---|
650 | if (!FORBID_TAGS[tagName] && _basicCustomElementTest(tagName)) {
|
---|
651 | if (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof RegExp && regExpTest(CUSTOM_ELEMENT_HANDLING.tagNameCheck, tagName)) return false;
|
---|
652 | if (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof Function && CUSTOM_ELEMENT_HANDLING.tagNameCheck(tagName)) return false;
|
---|
653 | }
|
---|
654 | if (KEEP_CONTENT && !FORBID_CONTENTS[tagName]) {
|
---|
655 | var parentNode = getParentNode(currentNode) || currentNode.parentNode;
|
---|
656 | var childNodes = getChildNodes(currentNode) || currentNode.childNodes;
|
---|
657 | if (childNodes && parentNode) {
|
---|
658 | var childCount = childNodes.length;
|
---|
659 | for (var i = childCount - 1; i >= 0; --i) {
|
---|
660 | var childClone = cloneNode(childNodes[i], true);
|
---|
661 | childClone.__removalCount = (currentNode.__removalCount || 0) + 1;
|
---|
662 | parentNode.insertBefore(childClone, getNextSibling(currentNode));
|
---|
663 | }
|
---|
664 | }
|
---|
665 | }
|
---|
666 | _forceRemove(currentNode);
|
---|
667 | return true;
|
---|
668 | }
|
---|
669 | if (currentNode instanceof Element && !_checkValidNamespace(currentNode)) {
|
---|
670 | _forceRemove(currentNode);
|
---|
671 | return true;
|
---|
672 | }
|
---|
673 | if ((tagName === "noscript" || tagName === "noembed" || tagName === "noframes") && regExpTest(/<\/no(script|embed|frames)/i, currentNode.innerHTML)) {
|
---|
674 | _forceRemove(currentNode);
|
---|
675 | return true;
|
---|
676 | }
|
---|
677 | if (SAFE_FOR_TEMPLATES && currentNode.nodeType === 3) {
|
---|
678 | content = currentNode.textContent;
|
---|
679 | content = stringReplace(content, MUSTACHE_EXPR$1, " ");
|
---|
680 | content = stringReplace(content, ERB_EXPR$1, " ");
|
---|
681 | content = stringReplace(content, TMPLIT_EXPR$1, " ");
|
---|
682 | if (currentNode.textContent !== content) {
|
---|
683 | arrayPush(DOMPurify.removed, {
|
---|
684 | element: currentNode.cloneNode()
|
---|
685 | });
|
---|
686 | currentNode.textContent = content;
|
---|
687 | }
|
---|
688 | }
|
---|
689 | _executeHook("afterSanitizeElements", currentNode, null);
|
---|
690 | return false;
|
---|
691 | };
|
---|
692 | var _isValidAttribute = function _isValidAttribute2(lcTag, lcName, value) {
|
---|
693 | if (SANITIZE_DOM && (lcName === "id" || lcName === "name") && (value in document || value in formElement)) {
|
---|
694 | return false;
|
---|
695 | }
|
---|
696 | if (ALLOW_DATA_ATTR && !FORBID_ATTR[lcName] && regExpTest(DATA_ATTR$1, lcName)) ;
|
---|
697 | else if (ALLOW_ARIA_ATTR && regExpTest(ARIA_ATTR$1, lcName)) ;
|
---|
698 | else if (!ALLOWED_ATTR[lcName] || FORBID_ATTR[lcName]) {
|
---|
699 | if (
|
---|
700 | // First condition does a very basic check if a) it's basically a valid custom element tagname AND
|
---|
701 | // b) if the tagName passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.tagNameCheck
|
---|
702 | // and c) if the attribute name passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.attributeNameCheck
|
---|
703 | _basicCustomElementTest(lcTag) && (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof RegExp && regExpTest(CUSTOM_ELEMENT_HANDLING.tagNameCheck, lcTag) || CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof Function && CUSTOM_ELEMENT_HANDLING.tagNameCheck(lcTag)) && (CUSTOM_ELEMENT_HANDLING.attributeNameCheck instanceof RegExp && regExpTest(CUSTOM_ELEMENT_HANDLING.attributeNameCheck, lcName) || CUSTOM_ELEMENT_HANDLING.attributeNameCheck instanceof Function && CUSTOM_ELEMENT_HANDLING.attributeNameCheck(lcName)) || // Alternative, second condition checks if it's an `is`-attribute, AND
|
---|
704 | // the value passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.tagNameCheck
|
---|
705 | 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))
|
---|
706 | ) ;
|
---|
707 | else {
|
---|
708 | return false;
|
---|
709 | }
|
---|
710 | } else if (URI_SAFE_ATTRIBUTES[lcName]) ;
|
---|
711 | else if (regExpTest(IS_ALLOWED_URI$1, stringReplace(value, ATTR_WHITESPACE$1, ""))) ;
|
---|
712 | else if ((lcName === "src" || lcName === "xlink:href" || lcName === "href") && lcTag !== "script" && stringIndexOf(value, "data:") === 0 && DATA_URI_TAGS[lcTag]) ;
|
---|
713 | else if (ALLOW_UNKNOWN_PROTOCOLS && !regExpTest(IS_SCRIPT_OR_DATA$1, stringReplace(value, ATTR_WHITESPACE$1, ""))) ;
|
---|
714 | else if (value) {
|
---|
715 | return false;
|
---|
716 | } else ;
|
---|
717 | return true;
|
---|
718 | };
|
---|
719 | var _basicCustomElementTest = function _basicCustomElementTest2(tagName) {
|
---|
720 | return tagName !== "annotation-xml" && stringMatch(tagName, CUSTOM_ELEMENT$1);
|
---|
721 | };
|
---|
722 | var _sanitizeAttributes = function _sanitizeAttributes2(currentNode) {
|
---|
723 | var attr;
|
---|
724 | var value;
|
---|
725 | var lcName;
|
---|
726 | var l;
|
---|
727 | _executeHook("beforeSanitizeAttributes", currentNode, null);
|
---|
728 | var attributes = currentNode.attributes;
|
---|
729 | if (!attributes || _isClobbered(currentNode)) {
|
---|
730 | return;
|
---|
731 | }
|
---|
732 | var hookEvent = {
|
---|
733 | attrName: "",
|
---|
734 | attrValue: "",
|
---|
735 | keepAttr: true,
|
---|
736 | allowedAttributes: ALLOWED_ATTR
|
---|
737 | };
|
---|
738 | l = attributes.length;
|
---|
739 | while (l--) {
|
---|
740 | attr = attributes[l];
|
---|
741 | var _attr = attr, name = _attr.name, namespaceURI = _attr.namespaceURI;
|
---|
742 | value = name === "value" ? attr.value : stringTrim(attr.value);
|
---|
743 | lcName = transformCaseFunc(name);
|
---|
744 | hookEvent.attrName = lcName;
|
---|
745 | hookEvent.attrValue = value;
|
---|
746 | hookEvent.keepAttr = true;
|
---|
747 | hookEvent.forceKeepAttr = void 0;
|
---|
748 | _executeHook("uponSanitizeAttribute", currentNode, hookEvent);
|
---|
749 | value = hookEvent.attrValue;
|
---|
750 | if (hookEvent.forceKeepAttr) {
|
---|
751 | continue;
|
---|
752 | }
|
---|
753 | _removeAttribute(name, currentNode);
|
---|
754 | if (!hookEvent.keepAttr) {
|
---|
755 | continue;
|
---|
756 | }
|
---|
757 | if (!ALLOW_SELF_CLOSE_IN_ATTR && regExpTest(/\/>/i, value)) {
|
---|
758 | _removeAttribute(name, currentNode);
|
---|
759 | continue;
|
---|
760 | }
|
---|
761 | if (SAFE_FOR_TEMPLATES) {
|
---|
762 | value = stringReplace(value, MUSTACHE_EXPR$1, " ");
|
---|
763 | value = stringReplace(value, ERB_EXPR$1, " ");
|
---|
764 | value = stringReplace(value, TMPLIT_EXPR$1, " ");
|
---|
765 | }
|
---|
766 | var lcTag = transformCaseFunc(currentNode.nodeName);
|
---|
767 | if (!_isValidAttribute(lcTag, lcName, value)) {
|
---|
768 | continue;
|
---|
769 | }
|
---|
770 | if (SANITIZE_NAMED_PROPS && (lcName === "id" || lcName === "name")) {
|
---|
771 | _removeAttribute(name, currentNode);
|
---|
772 | value = SANITIZE_NAMED_PROPS_PREFIX + value;
|
---|
773 | }
|
---|
774 | if (SAFE_FOR_XML && regExpTest(/((--!?|])>)|<\/(style|title)/i, value)) {
|
---|
775 | _removeAttribute(name, currentNode);
|
---|
776 | continue;
|
---|
777 | }
|
---|
778 | if (trustedTypesPolicy && _typeof(trustedTypes) === "object" && typeof trustedTypes.getAttributeType === "function") {
|
---|
779 | if (namespaceURI) ;
|
---|
780 | else {
|
---|
781 | switch (trustedTypes.getAttributeType(lcTag, lcName)) {
|
---|
782 | case "TrustedHTML": {
|
---|
783 | value = trustedTypesPolicy.createHTML(value);
|
---|
784 | break;
|
---|
785 | }
|
---|
786 | case "TrustedScriptURL": {
|
---|
787 | value = trustedTypesPolicy.createScriptURL(value);
|
---|
788 | break;
|
---|
789 | }
|
---|
790 | }
|
---|
791 | }
|
---|
792 | }
|
---|
793 | try {
|
---|
794 | if (namespaceURI) {
|
---|
795 | currentNode.setAttributeNS(namespaceURI, name, value);
|
---|
796 | } else {
|
---|
797 | currentNode.setAttribute(name, value);
|
---|
798 | }
|
---|
799 | if (_isClobbered(currentNode)) {
|
---|
800 | _forceRemove(currentNode);
|
---|
801 | } else {
|
---|
802 | arrayPop(DOMPurify.removed);
|
---|
803 | }
|
---|
804 | } catch (_) {
|
---|
805 | }
|
---|
806 | }
|
---|
807 | _executeHook("afterSanitizeAttributes", currentNode, null);
|
---|
808 | };
|
---|
809 | var _sanitizeShadowDOM = function _sanitizeShadowDOM2(fragment) {
|
---|
810 | var shadowNode;
|
---|
811 | var shadowIterator = _createIterator(fragment);
|
---|
812 | _executeHook("beforeSanitizeShadowDOM", fragment, null);
|
---|
813 | while (shadowNode = shadowIterator.nextNode()) {
|
---|
814 | _executeHook("uponSanitizeShadowNode", shadowNode, null);
|
---|
815 | _sanitizeElements(shadowNode);
|
---|
816 | _sanitizeAttributes(shadowNode);
|
---|
817 | if (shadowNode.content instanceof DocumentFragment) {
|
---|
818 | _sanitizeShadowDOM2(shadowNode.content);
|
---|
819 | }
|
---|
820 | }
|
---|
821 | _executeHook("afterSanitizeShadowDOM", fragment, null);
|
---|
822 | };
|
---|
823 | DOMPurify.sanitize = function(dirty) {
|
---|
824 | var cfg = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
|
---|
825 | var body;
|
---|
826 | var importedNode;
|
---|
827 | var currentNode;
|
---|
828 | var oldNode;
|
---|
829 | var returnNode;
|
---|
830 | IS_EMPTY_INPUT = !dirty;
|
---|
831 | if (IS_EMPTY_INPUT) {
|
---|
832 | dirty = "<!-->";
|
---|
833 | }
|
---|
834 | if (typeof dirty !== "string" && !_isNode(dirty)) {
|
---|
835 | if (typeof dirty.toString === "function") {
|
---|
836 | dirty = dirty.toString();
|
---|
837 | if (typeof dirty !== "string") {
|
---|
838 | throw typeErrorCreate("dirty is not a string, aborting");
|
---|
839 | }
|
---|
840 | } else {
|
---|
841 | throw typeErrorCreate("toString is not a function");
|
---|
842 | }
|
---|
843 | }
|
---|
844 | if (!DOMPurify.isSupported) {
|
---|
845 | if (_typeof(window2.toStaticHTML) === "object" || typeof window2.toStaticHTML === "function") {
|
---|
846 | if (typeof dirty === "string") {
|
---|
847 | return window2.toStaticHTML(dirty);
|
---|
848 | }
|
---|
849 | if (_isNode(dirty)) {
|
---|
850 | return window2.toStaticHTML(dirty.outerHTML);
|
---|
851 | }
|
---|
852 | }
|
---|
853 | return dirty;
|
---|
854 | }
|
---|
855 | if (!SET_CONFIG) {
|
---|
856 | _parseConfig(cfg);
|
---|
857 | }
|
---|
858 | DOMPurify.removed = [];
|
---|
859 | if (typeof dirty === "string") {
|
---|
860 | IN_PLACE = false;
|
---|
861 | }
|
---|
862 | if (IN_PLACE) {
|
---|
863 | if (dirty.nodeName) {
|
---|
864 | var tagName = transformCaseFunc(dirty.nodeName);
|
---|
865 | if (!ALLOWED_TAGS[tagName] || FORBID_TAGS[tagName]) {
|
---|
866 | throw typeErrorCreate("root node is forbidden and cannot be sanitized in-place");
|
---|
867 | }
|
---|
868 | }
|
---|
869 | } else if (dirty instanceof Node) {
|
---|
870 | body = _initDocument("<!---->");
|
---|
871 | importedNode = body.ownerDocument.importNode(dirty, true);
|
---|
872 | if (importedNode.nodeType === 1 && importedNode.nodeName === "BODY") {
|
---|
873 | body = importedNode;
|
---|
874 | } else if (importedNode.nodeName === "HTML") {
|
---|
875 | body = importedNode;
|
---|
876 | } else {
|
---|
877 | body.appendChild(importedNode);
|
---|
878 | }
|
---|
879 | } else {
|
---|
880 | if (!RETURN_DOM && !SAFE_FOR_TEMPLATES && !WHOLE_DOCUMENT && // eslint-disable-next-line unicorn/prefer-includes
|
---|
881 | dirty.indexOf("<") === -1) {
|
---|
882 | return trustedTypesPolicy && RETURN_TRUSTED_TYPE ? trustedTypesPolicy.createHTML(dirty) : dirty;
|
---|
883 | }
|
---|
884 | body = _initDocument(dirty);
|
---|
885 | if (!body) {
|
---|
886 | return RETURN_DOM ? null : RETURN_TRUSTED_TYPE ? emptyHTML : "";
|
---|
887 | }
|
---|
888 | }
|
---|
889 | if (body && FORCE_BODY) {
|
---|
890 | _forceRemove(body.firstChild);
|
---|
891 | }
|
---|
892 | var nodeIterator = _createIterator(IN_PLACE ? dirty : body);
|
---|
893 | while (currentNode = nodeIterator.nextNode()) {
|
---|
894 | if (currentNode.nodeType === 3 && currentNode === oldNode) {
|
---|
895 | continue;
|
---|
896 | }
|
---|
897 | _sanitizeElements(currentNode);
|
---|
898 | _sanitizeAttributes(currentNode);
|
---|
899 | if (currentNode.content instanceof DocumentFragment) {
|
---|
900 | _sanitizeShadowDOM(currentNode.content);
|
---|
901 | }
|
---|
902 | oldNode = currentNode;
|
---|
903 | }
|
---|
904 | oldNode = null;
|
---|
905 | if (IN_PLACE) {
|
---|
906 | return dirty;
|
---|
907 | }
|
---|
908 | if (RETURN_DOM) {
|
---|
909 | if (RETURN_DOM_FRAGMENT) {
|
---|
910 | returnNode = createDocumentFragment.call(body.ownerDocument);
|
---|
911 | while (body.firstChild) {
|
---|
912 | returnNode.appendChild(body.firstChild);
|
---|
913 | }
|
---|
914 | } else {
|
---|
915 | returnNode = body;
|
---|
916 | }
|
---|
917 | if (ALLOWED_ATTR.shadowroot || ALLOWED_ATTR.shadowrootmod) {
|
---|
918 | returnNode = importNode.call(originalDocument, returnNode, true);
|
---|
919 | }
|
---|
920 | return returnNode;
|
---|
921 | }
|
---|
922 | var serializedHTML = WHOLE_DOCUMENT ? body.outerHTML : body.innerHTML;
|
---|
923 | if (WHOLE_DOCUMENT && ALLOWED_TAGS["!doctype"] && body.ownerDocument && body.ownerDocument.doctype && body.ownerDocument.doctype.name && regExpTest(DOCTYPE_NAME, body.ownerDocument.doctype.name)) {
|
---|
924 | serializedHTML = "<!DOCTYPE " + body.ownerDocument.doctype.name + ">\n" + serializedHTML;
|
---|
925 | }
|
---|
926 | if (SAFE_FOR_TEMPLATES) {
|
---|
927 | serializedHTML = stringReplace(serializedHTML, MUSTACHE_EXPR$1, " ");
|
---|
928 | serializedHTML = stringReplace(serializedHTML, ERB_EXPR$1, " ");
|
---|
929 | serializedHTML = stringReplace(serializedHTML, TMPLIT_EXPR$1, " ");
|
---|
930 | }
|
---|
931 | return trustedTypesPolicy && RETURN_TRUSTED_TYPE ? trustedTypesPolicy.createHTML(serializedHTML) : serializedHTML;
|
---|
932 | };
|
---|
933 | DOMPurify.setConfig = function(cfg) {
|
---|
934 | _parseConfig(cfg);
|
---|
935 | SET_CONFIG = true;
|
---|
936 | };
|
---|
937 | DOMPurify.clearConfig = function() {
|
---|
938 | CONFIG = null;
|
---|
939 | SET_CONFIG = false;
|
---|
940 | };
|
---|
941 | DOMPurify.isValidAttribute = function(tag, attr, value) {
|
---|
942 | if (!CONFIG) {
|
---|
943 | _parseConfig({});
|
---|
944 | }
|
---|
945 | var lcTag = transformCaseFunc(tag);
|
---|
946 | var lcName = transformCaseFunc(attr);
|
---|
947 | return _isValidAttribute(lcTag, lcName, value);
|
---|
948 | };
|
---|
949 | DOMPurify.addHook = function(entryPoint, hookFunction) {
|
---|
950 | if (typeof hookFunction !== "function") {
|
---|
951 | return;
|
---|
952 | }
|
---|
953 | hooks[entryPoint] = hooks[entryPoint] || [];
|
---|
954 | arrayPush(hooks[entryPoint], hookFunction);
|
---|
955 | };
|
---|
956 | DOMPurify.removeHook = function(entryPoint) {
|
---|
957 | if (hooks[entryPoint]) {
|
---|
958 | return arrayPop(hooks[entryPoint]);
|
---|
959 | }
|
---|
960 | };
|
---|
961 | DOMPurify.removeHooks = function(entryPoint) {
|
---|
962 | if (hooks[entryPoint]) {
|
---|
963 | hooks[entryPoint] = [];
|
---|
964 | }
|
---|
965 | };
|
---|
966 | DOMPurify.removeAllHooks = function() {
|
---|
967 | hooks = {};
|
---|
968 | };
|
---|
969 | return DOMPurify;
|
---|
970 | }
|
---|
971 | var purify = createDOMPurify();
|
---|
972 | export {
|
---|
973 | purify as default
|
---|
974 | };
|
---|
975 | /*! Bundled license information:
|
---|
976 |
|
---|
977 | dompurify/dist/purify.es.js:
|
---|
978 | (*! @license DOMPurify 2.5.8 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/2.5.8/LICENSE *)
|
---|
979 | */
|
---|
980 | //# sourceMappingURL=purify.es-25GRGOID.js.map
|
---|