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