@vaadin/bundles 25.3.0 → 25.4.0-alpha2
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/package.json +135 -135
- package/vaadin-bundle.json +4160 -4113
- package/vaadin.js +7643 -5807
- package/vaadin.js.map +1 -1
- package/vendors-node_modules_vaadin_markdown_node_modules_dompurify_dist_purify_es_mjs.js +2384 -2140
- package/vendors-node_modules_vaadin_markdown_node_modules_dompurify_dist_purify_es_mjs.js.map +1 -1
|
@@ -8,97 +8,133 @@
|
|
|
8
8
|
|
|
9
9
|
__webpack_require__.r(__webpack_exports__);
|
|
10
10
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
11
|
-
/* harmony export */ "default": () => (/* binding */
|
|
11
|
+
/* harmony export */ "default": () => (/* binding */ purify_default)
|
|
12
12
|
/* harmony export */ });
|
|
13
|
-
/*! @license DOMPurify 3.4.
|
|
14
|
-
|
|
13
|
+
/*! @license DOMPurify 3.4.16 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.4.16/LICENSE */
|
|
14
|
+
function _OverloadYield(e, d) {
|
|
15
|
+
this.v = e, this.k = d;
|
|
16
|
+
}
|
|
15
17
|
function _arrayLikeToArray(r, a) {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
18
|
+
(null == a || a > r.length) && (a = r.length);
|
|
19
|
+
for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
|
|
20
|
+
return n;
|
|
19
21
|
}
|
|
20
22
|
function _arrayWithHoles(r) {
|
|
21
|
-
|
|
23
|
+
if (Array.isArray(r)) return r;
|
|
22
24
|
}
|
|
23
25
|
function _iterableToArrayLimit(r, l) {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
}
|
|
44
|
-
return a;
|
|
45
|
-
}
|
|
26
|
+
var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
|
|
27
|
+
if (null != t) {
|
|
28
|
+
var e, n, i, u, a = [], f = !0, o = !1;
|
|
29
|
+
try {
|
|
30
|
+
if (i = (t = t.call(r)).next, 0 === l) {
|
|
31
|
+
if (Object(t) !== t) return;
|
|
32
|
+
f = !1;
|
|
33
|
+
} else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0);
|
|
34
|
+
} catch (r) {
|
|
35
|
+
o = !0, n = r;
|
|
36
|
+
} finally {
|
|
37
|
+
try {
|
|
38
|
+
if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return;
|
|
39
|
+
} finally {
|
|
40
|
+
if (o) throw n;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
return a;
|
|
44
|
+
}
|
|
46
45
|
}
|
|
47
46
|
function _nonIterableRest() {
|
|
48
|
-
|
|
47
|
+
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
49
48
|
}
|
|
49
|
+
/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */
|
|
50
50
|
function _slicedToArray(r, e) {
|
|
51
|
-
|
|
51
|
+
return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest();
|
|
52
52
|
}
|
|
53
53
|
function _unsupportedIterableToArray(r, a) {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
const entries = Object.entries,
|
|
62
|
-
setPrototypeOf = Object.setPrototypeOf,
|
|
63
|
-
isFrozen = Object.isFrozen,
|
|
64
|
-
getPrototypeOf = Object.getPrototypeOf,
|
|
65
|
-
getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
|
|
66
|
-
let freeze = Object.freeze,
|
|
67
|
-
seal = Object.seal,
|
|
68
|
-
create = Object.create; // eslint-disable-line import/no-mutable-exports
|
|
69
|
-
let _ref = typeof Reflect !== 'undefined' && Reflect,
|
|
70
|
-
apply = _ref.apply,
|
|
71
|
-
construct = _ref.construct;
|
|
72
|
-
if (!freeze) {
|
|
73
|
-
freeze = function freeze(x) {
|
|
74
|
-
return x;
|
|
75
|
-
};
|
|
76
|
-
}
|
|
77
|
-
if (!seal) {
|
|
78
|
-
seal = function seal(x) {
|
|
79
|
-
return x;
|
|
80
|
-
};
|
|
54
|
+
if (r) {
|
|
55
|
+
if ("string" == typeof r) return _arrayLikeToArray(r, a);
|
|
56
|
+
var t = {}.toString.call(r).slice(8, -1);
|
|
57
|
+
return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0;
|
|
58
|
+
}
|
|
81
59
|
}
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
if (!
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
60
|
+
function AsyncGenerator(e) {
|
|
61
|
+
var t, n;
|
|
62
|
+
function resume(t, n) {
|
|
63
|
+
try {
|
|
64
|
+
var r = e[t](n), o = r.value, u = o instanceof _OverloadYield;
|
|
65
|
+
Promise.resolve(u ? o.v : o).then(function(n) {
|
|
66
|
+
if (u) {
|
|
67
|
+
var i = "return" === t && o.k ? t : "next";
|
|
68
|
+
if (!o.k || n.done) return resume(i, n);
|
|
69
|
+
n = e[i](n).value;
|
|
70
|
+
}
|
|
71
|
+
settle(!!r.done, n);
|
|
72
|
+
}, function(e) {
|
|
73
|
+
resume("throw", e);
|
|
74
|
+
});
|
|
75
|
+
} catch (e) {
|
|
76
|
+
settle(2, e);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
function settle(e, r) {
|
|
80
|
+
2 === e ? t.reject(r) : t.resolve({
|
|
81
|
+
value: r,
|
|
82
|
+
done: e
|
|
83
|
+
}), (t = t.next) ? resume(t.key, t.arg) : n = null;
|
|
84
|
+
}
|
|
85
|
+
this._invoke = function(e, r) {
|
|
86
|
+
return new Promise(function(o, u) {
|
|
87
|
+
var i = {
|
|
88
|
+
key: e,
|
|
89
|
+
arg: r,
|
|
90
|
+
resolve: o,
|
|
91
|
+
reject: u,
|
|
92
|
+
next: null
|
|
93
|
+
};
|
|
94
|
+
n ? n = n.next = i : (t = n = i, resume(e, r));
|
|
95
|
+
});
|
|
96
|
+
}, "function" != typeof e.return && (this.return = void 0);
|
|
97
97
|
}
|
|
98
|
+
AsyncGenerator.prototype["function" == typeof Symbol && Symbol.asyncIterator || "@@asyncIterator"] = function() {
|
|
99
|
+
return this;
|
|
100
|
+
}, AsyncGenerator.prototype.next = function(e) {
|
|
101
|
+
return this._invoke("next", e);
|
|
102
|
+
}, AsyncGenerator.prototype.throw = function(e) {
|
|
103
|
+
return this._invoke("throw", e);
|
|
104
|
+
}, AsyncGenerator.prototype.return = function(e) {
|
|
105
|
+
return this._invoke("return", e);
|
|
106
|
+
};
|
|
107
|
+
const entries = Object.entries;
|
|
108
|
+
const setPrototypeOf = Object.setPrototypeOf;
|
|
109
|
+
const isFrozen = Object.isFrozen;
|
|
110
|
+
const getPrototypeOf = Object.getPrototypeOf;
|
|
111
|
+
const getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
|
|
112
|
+
let freeze = Object.freeze;
|
|
113
|
+
let seal = Object.seal;
|
|
114
|
+
let create = Object.create;
|
|
115
|
+
let _ref = typeof Reflect !== "undefined" && Reflect;
|
|
116
|
+
let apply = _ref.apply;
|
|
117
|
+
let construct = _ref.construct;
|
|
118
|
+
if (!freeze) freeze = function freeze(x) {
|
|
119
|
+
return x;
|
|
120
|
+
};
|
|
121
|
+
if (!seal) seal = function seal(x) {
|
|
122
|
+
return x;
|
|
123
|
+
};
|
|
124
|
+
if (!apply) apply = function apply(func, thisArg) {
|
|
125
|
+
for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) args[_key - 2] = arguments[_key];
|
|
126
|
+
return func.apply(thisArg, args);
|
|
127
|
+
};
|
|
128
|
+
if (!construct) construct = function construct(Func) {
|
|
129
|
+
for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) args[_key2 - 1] = arguments[_key2];
|
|
130
|
+
return new Func(...args);
|
|
131
|
+
};
|
|
98
132
|
const arrayForEach = unapply(Array.prototype.forEach);
|
|
133
|
+
Array.prototype.indexOf;
|
|
99
134
|
const arrayLastIndexOf = unapply(Array.prototype.lastIndexOf);
|
|
100
135
|
const arrayPop = unapply(Array.prototype.pop);
|
|
101
136
|
const arrayPush = unapply(Array.prototype.push);
|
|
137
|
+
Array.prototype.slice;
|
|
102
138
|
const arraySplice = unapply(Array.prototype.splice);
|
|
103
139
|
const arrayIsArray = Array.isArray;
|
|
104
140
|
const stringToLowerCase = unapply(String.prototype.toLowerCase);
|
|
@@ -109,2128 +145,2336 @@ const stringIndexOf = unapply(String.prototype.indexOf);
|
|
|
109
145
|
const stringTrim = unapply(String.prototype.trim);
|
|
110
146
|
const numberToString = unapply(Number.prototype.toString);
|
|
111
147
|
const booleanToString = unapply(Boolean.prototype.toString);
|
|
112
|
-
const bigintToString = typeof BigInt ===
|
|
113
|
-
const symbolToString = typeof Symbol ===
|
|
148
|
+
const bigintToString = typeof BigInt === "undefined" ? null : unapply(BigInt.prototype.toString);
|
|
149
|
+
const symbolToString = typeof Symbol === "undefined" ? null : unapply(Symbol.prototype.toString);
|
|
114
150
|
const objectHasOwnProperty = unapply(Object.prototype.hasOwnProperty);
|
|
115
151
|
const objectToString = unapply(Object.prototype.toString);
|
|
116
152
|
const regExpTest = unapply(RegExp.prototype.test);
|
|
117
153
|
const typeErrorCreate = unconstruct(TypeError);
|
|
118
154
|
/**
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
155
|
+
* Creates a new function that calls the given function with a specified thisArg and arguments.
|
|
156
|
+
*
|
|
157
|
+
* @param func - The function to be wrapped and called.
|
|
158
|
+
* @returns A new function that calls the given function with a specified thisArg and arguments.
|
|
159
|
+
*/
|
|
124
160
|
function unapply(func) {
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
args[_key3 - 1] = arguments[_key3];
|
|
131
|
-
}
|
|
132
|
-
return apply(func, thisArg, args);
|
|
133
|
-
};
|
|
161
|
+
return function(thisArg) {
|
|
162
|
+
if (thisArg instanceof RegExp) thisArg.lastIndex = 0;
|
|
163
|
+
for (var _len3 = arguments.length, args = new Array(_len3 > 1 ? _len3 - 1 : 0), _key3 = 1; _key3 < _len3; _key3++) args[_key3 - 1] = arguments[_key3];
|
|
164
|
+
return apply(func, thisArg, args);
|
|
165
|
+
};
|
|
134
166
|
}
|
|
135
167
|
/**
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
168
|
+
* Creates a new function that constructs an instance of the given constructor function with the provided arguments.
|
|
169
|
+
*
|
|
170
|
+
* @param func - The constructor function to be wrapped and called.
|
|
171
|
+
* @returns A new function that constructs an instance of the given constructor function with the provided arguments.
|
|
172
|
+
*/
|
|
141
173
|
function unconstruct(Func) {
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
return construct(Func, args);
|
|
147
|
-
};
|
|
174
|
+
return function() {
|
|
175
|
+
for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) args[_key4] = arguments[_key4];
|
|
176
|
+
return construct(Func, args);
|
|
177
|
+
};
|
|
148
178
|
}
|
|
149
179
|
/**
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
180
|
+
* Add properties to a lookup table
|
|
181
|
+
*
|
|
182
|
+
* @param set - The set to which elements will be added.
|
|
183
|
+
* @param array - The array containing elements to be added to the set.
|
|
184
|
+
* @param transformCaseFunc - An optional function to transform the case of each element before adding to the set.
|
|
185
|
+
* @returns The modified set with added elements.
|
|
186
|
+
*/
|
|
157
187
|
function addToSet(set, array) {
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
// Config presets (e.g. tags.js, attrs.js) are immutable.
|
|
175
|
-
if (!isFrozen(array)) {
|
|
176
|
-
array[l] = lcElement;
|
|
177
|
-
}
|
|
178
|
-
element = lcElement;
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
set[element] = true;
|
|
182
|
-
}
|
|
183
|
-
return set;
|
|
188
|
+
let transformCaseFunc = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : stringToLowerCase;
|
|
189
|
+
if (setPrototypeOf) setPrototypeOf(set, null);
|
|
190
|
+
if (!arrayIsArray(array)) return set;
|
|
191
|
+
let l = array.length;
|
|
192
|
+
while (l--) {
|
|
193
|
+
let element = array[l];
|
|
194
|
+
if (typeof element === "string") {
|
|
195
|
+
const lcElement = transformCaseFunc(element);
|
|
196
|
+
if (lcElement !== element) {
|
|
197
|
+
if (!isFrozen(array)) array[l] = lcElement;
|
|
198
|
+
element = lcElement;
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
set[element] = true;
|
|
202
|
+
}
|
|
203
|
+
return set;
|
|
184
204
|
}
|
|
185
205
|
/**
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
206
|
+
* Clean up an array to harden against CSPP
|
|
207
|
+
*
|
|
208
|
+
* @param array - The array to be cleaned.
|
|
209
|
+
* @returns The cleaned version of the array
|
|
210
|
+
*/
|
|
191
211
|
function cleanArray(array) {
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
if (!isPropertyExist) {
|
|
195
|
-
array[index] = null;
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
return array;
|
|
212
|
+
for (let index = 0; index < array.length; index++) if (!objectHasOwnProperty(array, index)) array[index] = null;
|
|
213
|
+
return array;
|
|
199
214
|
}
|
|
200
215
|
/**
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
216
|
+
* Shallow clone an object
|
|
217
|
+
*
|
|
218
|
+
* @param object - The object to be cloned.
|
|
219
|
+
* @returns A new object that copies the original.
|
|
220
|
+
*/
|
|
206
221
|
function clone(object) {
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
newObject[property] = value;
|
|
220
|
-
}
|
|
221
|
-
}
|
|
222
|
-
}
|
|
223
|
-
return newObject;
|
|
222
|
+
const newObject = create(null);
|
|
223
|
+
for (const _ref2 of entries(object)) {
|
|
224
|
+
var _ref3 = _slicedToArray(_ref2, 2);
|
|
225
|
+
const property = _ref3[0];
|
|
226
|
+
const value = _ref3[1];
|
|
227
|
+
if (objectHasOwnProperty(object, property)) {
|
|
228
|
+
if (arrayIsArray(value)) newObject[property] = cleanArray(value);
|
|
229
|
+
else if (value && typeof value === "object" && value.constructor === Object) newObject[property] = clone(value);
|
|
230
|
+
else newObject[property] = value;
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
return newObject;
|
|
224
234
|
}
|
|
225
235
|
/**
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
236
|
+
* Convert non-node values into strings without depending on direct property access.
|
|
237
|
+
*
|
|
238
|
+
* @param value - The value to stringify.
|
|
239
|
+
* @returns A string representation of the provided value.
|
|
240
|
+
*/
|
|
231
241
|
function stringifyValue(value) {
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
}
|
|
253
|
-
case 'undefined':
|
|
254
|
-
{
|
|
255
|
-
return objectToString(value);
|
|
256
|
-
}
|
|
257
|
-
case 'function':
|
|
258
|
-
case 'object':
|
|
259
|
-
{
|
|
260
|
-
if (value === null) {
|
|
261
|
-
return objectToString(value);
|
|
262
|
-
}
|
|
263
|
-
const valueAsRecord = value;
|
|
264
|
-
const valueToString = lookupGetter(valueAsRecord, 'toString');
|
|
265
|
-
if (typeof valueToString === 'function') {
|
|
266
|
-
const stringified = valueToString(valueAsRecord);
|
|
267
|
-
return typeof stringified === 'string' ? stringified : objectToString(stringified);
|
|
268
|
-
}
|
|
269
|
-
return objectToString(value);
|
|
270
|
-
}
|
|
271
|
-
default:
|
|
272
|
-
{
|
|
273
|
-
return objectToString(value);
|
|
274
|
-
}
|
|
275
|
-
}
|
|
242
|
+
switch (typeof value) {
|
|
243
|
+
case "string": return value;
|
|
244
|
+
case "number": return numberToString(value);
|
|
245
|
+
case "boolean": return booleanToString(value);
|
|
246
|
+
case "bigint": return bigintToString ? bigintToString(value) : "0";
|
|
247
|
+
case "symbol": return symbolToString ? symbolToString(value) : "Symbol()";
|
|
248
|
+
case "undefined": return objectToString(value);
|
|
249
|
+
case "function":
|
|
250
|
+
case "object": {
|
|
251
|
+
if (value === null) return objectToString(value);
|
|
252
|
+
const valueAsRecord = value;
|
|
253
|
+
const valueToString = lookupGetter(valueAsRecord, "toString");
|
|
254
|
+
if (typeof valueToString === "function") {
|
|
255
|
+
const stringified = valueToString(valueAsRecord);
|
|
256
|
+
return typeof stringified === "string" ? stringified : objectToString(stringified);
|
|
257
|
+
}
|
|
258
|
+
return objectToString(value);
|
|
259
|
+
}
|
|
260
|
+
default: return objectToString(value);
|
|
261
|
+
}
|
|
276
262
|
}
|
|
277
263
|
/**
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
264
|
+
* This method automatically checks if the prop is function or getter and behaves accordingly.
|
|
265
|
+
*
|
|
266
|
+
* @param object - The object to look up the getter function in its prototype chain.
|
|
267
|
+
* @param prop - The property name for which to find the getter function.
|
|
268
|
+
* @returns The getter function found in the prototype chain or a fallback function.
|
|
269
|
+
*/
|
|
284
270
|
function lookupGetter(object, prop) {
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
function fallbackValue() {
|
|
298
|
-
return null;
|
|
299
|
-
}
|
|
300
|
-
return fallbackValue;
|
|
271
|
+
while (object !== null) {
|
|
272
|
+
const desc = getOwnPropertyDescriptor(object, prop);
|
|
273
|
+
if (desc) {
|
|
274
|
+
if (desc.get) return unapply(desc.get);
|
|
275
|
+
if (typeof desc.value === "function") return unapply(desc.value);
|
|
276
|
+
}
|
|
277
|
+
object = getPrototypeOf(object);
|
|
278
|
+
}
|
|
279
|
+
function fallbackValue() {
|
|
280
|
+
return null;
|
|
281
|
+
}
|
|
282
|
+
return fallbackValue;
|
|
301
283
|
}
|
|
302
284
|
function isRegex(value) {
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
285
|
+
try {
|
|
286
|
+
regExpTest(value, "");
|
|
287
|
+
return true;
|
|
288
|
+
} catch (_unused) {
|
|
289
|
+
return false;
|
|
290
|
+
}
|
|
309
291
|
}
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
292
|
+
const html$1 = freeze([
|
|
293
|
+
"a",
|
|
294
|
+
"abbr",
|
|
295
|
+
"acronym",
|
|
296
|
+
"address",
|
|
297
|
+
"area",
|
|
298
|
+
"article",
|
|
299
|
+
"aside",
|
|
300
|
+
"audio",
|
|
301
|
+
"b",
|
|
302
|
+
"bdi",
|
|
303
|
+
"bdo",
|
|
304
|
+
"big",
|
|
305
|
+
"blink",
|
|
306
|
+
"blockquote",
|
|
307
|
+
"body",
|
|
308
|
+
"br",
|
|
309
|
+
"button",
|
|
310
|
+
"canvas",
|
|
311
|
+
"caption",
|
|
312
|
+
"center",
|
|
313
|
+
"cite",
|
|
314
|
+
"code",
|
|
315
|
+
"col",
|
|
316
|
+
"colgroup",
|
|
317
|
+
"content",
|
|
318
|
+
"data",
|
|
319
|
+
"datalist",
|
|
320
|
+
"dd",
|
|
321
|
+
"decorator",
|
|
322
|
+
"del",
|
|
323
|
+
"details",
|
|
324
|
+
"dfn",
|
|
325
|
+
"dialog",
|
|
326
|
+
"dir",
|
|
327
|
+
"div",
|
|
328
|
+
"dl",
|
|
329
|
+
"dt",
|
|
330
|
+
"element",
|
|
331
|
+
"em",
|
|
332
|
+
"fieldset",
|
|
333
|
+
"figcaption",
|
|
334
|
+
"figure",
|
|
335
|
+
"font",
|
|
336
|
+
"footer",
|
|
337
|
+
"form",
|
|
338
|
+
"h1",
|
|
339
|
+
"h2",
|
|
340
|
+
"h3",
|
|
341
|
+
"h4",
|
|
342
|
+
"h5",
|
|
343
|
+
"h6",
|
|
344
|
+
"head",
|
|
345
|
+
"header",
|
|
346
|
+
"hgroup",
|
|
347
|
+
"hr",
|
|
348
|
+
"html",
|
|
349
|
+
"i",
|
|
350
|
+
"img",
|
|
351
|
+
"input",
|
|
352
|
+
"ins",
|
|
353
|
+
"kbd",
|
|
354
|
+
"label",
|
|
355
|
+
"legend",
|
|
356
|
+
"li",
|
|
357
|
+
"main",
|
|
358
|
+
"map",
|
|
359
|
+
"mark",
|
|
360
|
+
"marquee",
|
|
361
|
+
"menu",
|
|
362
|
+
"menuitem",
|
|
363
|
+
"meter",
|
|
364
|
+
"nav",
|
|
365
|
+
"nobr",
|
|
366
|
+
"ol",
|
|
367
|
+
"optgroup",
|
|
368
|
+
"option",
|
|
369
|
+
"output",
|
|
370
|
+
"p",
|
|
371
|
+
"picture",
|
|
372
|
+
"pre",
|
|
373
|
+
"progress",
|
|
374
|
+
"q",
|
|
375
|
+
"rp",
|
|
376
|
+
"rt",
|
|
377
|
+
"ruby",
|
|
378
|
+
"s",
|
|
379
|
+
"samp",
|
|
380
|
+
"search",
|
|
381
|
+
"section",
|
|
382
|
+
"select",
|
|
383
|
+
"shadow",
|
|
384
|
+
"slot",
|
|
385
|
+
"small",
|
|
386
|
+
"source",
|
|
387
|
+
"spacer",
|
|
388
|
+
"span",
|
|
389
|
+
"strike",
|
|
390
|
+
"strong",
|
|
391
|
+
"style",
|
|
392
|
+
"sub",
|
|
393
|
+
"summary",
|
|
394
|
+
"sup",
|
|
395
|
+
"table",
|
|
396
|
+
"tbody",
|
|
397
|
+
"td",
|
|
398
|
+
"template",
|
|
399
|
+
"textarea",
|
|
400
|
+
"tfoot",
|
|
401
|
+
"th",
|
|
402
|
+
"thead",
|
|
403
|
+
"time",
|
|
404
|
+
"tr",
|
|
405
|
+
"track",
|
|
406
|
+
"tt",
|
|
407
|
+
"u",
|
|
408
|
+
"ul",
|
|
409
|
+
"var",
|
|
410
|
+
"video",
|
|
411
|
+
"wbr"
|
|
412
|
+
]);
|
|
413
|
+
const svg$1 = freeze([
|
|
414
|
+
"svg",
|
|
415
|
+
"a",
|
|
416
|
+
"altglyph",
|
|
417
|
+
"altglyphdef",
|
|
418
|
+
"altglyphitem",
|
|
419
|
+
"animatecolor",
|
|
420
|
+
"animatemotion",
|
|
421
|
+
"animatetransform",
|
|
422
|
+
"circle",
|
|
423
|
+
"clippath",
|
|
424
|
+
"defs",
|
|
425
|
+
"desc",
|
|
426
|
+
"ellipse",
|
|
427
|
+
"enterkeyhint",
|
|
428
|
+
"exportparts",
|
|
429
|
+
"filter",
|
|
430
|
+
"font",
|
|
431
|
+
"g",
|
|
432
|
+
"glyph",
|
|
433
|
+
"glyphref",
|
|
434
|
+
"hkern",
|
|
435
|
+
"image",
|
|
436
|
+
"inputmode",
|
|
437
|
+
"line",
|
|
438
|
+
"lineargradient",
|
|
439
|
+
"marker",
|
|
440
|
+
"mask",
|
|
441
|
+
"metadata",
|
|
442
|
+
"mpath",
|
|
443
|
+
"part",
|
|
444
|
+
"path",
|
|
445
|
+
"pattern",
|
|
446
|
+
"polygon",
|
|
447
|
+
"polyline",
|
|
448
|
+
"radialgradient",
|
|
449
|
+
"rect",
|
|
450
|
+
"stop",
|
|
451
|
+
"style",
|
|
452
|
+
"switch",
|
|
453
|
+
"symbol",
|
|
454
|
+
"text",
|
|
455
|
+
"textpath",
|
|
456
|
+
"title",
|
|
457
|
+
"tref",
|
|
458
|
+
"tspan",
|
|
459
|
+
"view",
|
|
460
|
+
"vkern"
|
|
461
|
+
]);
|
|
462
|
+
const svgFilters = freeze([
|
|
463
|
+
"feBlend",
|
|
464
|
+
"feColorMatrix",
|
|
465
|
+
"feComponentTransfer",
|
|
466
|
+
"feComposite",
|
|
467
|
+
"feConvolveMatrix",
|
|
468
|
+
"feDiffuseLighting",
|
|
469
|
+
"feDisplacementMap",
|
|
470
|
+
"feDistantLight",
|
|
471
|
+
"feDropShadow",
|
|
472
|
+
"feFlood",
|
|
473
|
+
"feFuncA",
|
|
474
|
+
"feFuncB",
|
|
475
|
+
"feFuncG",
|
|
476
|
+
"feFuncR",
|
|
477
|
+
"feGaussianBlur",
|
|
478
|
+
"feImage",
|
|
479
|
+
"feMerge",
|
|
480
|
+
"feMergeNode",
|
|
481
|
+
"feMorphology",
|
|
482
|
+
"feOffset",
|
|
483
|
+
"fePointLight",
|
|
484
|
+
"feSpecularLighting",
|
|
485
|
+
"feSpotLight",
|
|
486
|
+
"feTile",
|
|
487
|
+
"feTurbulence"
|
|
488
|
+
]);
|
|
489
|
+
const svgDisallowed = freeze([
|
|
490
|
+
"animate",
|
|
491
|
+
"color-profile",
|
|
492
|
+
"cursor",
|
|
493
|
+
"discard",
|
|
494
|
+
"font-face",
|
|
495
|
+
"font-face-format",
|
|
496
|
+
"font-face-name",
|
|
497
|
+
"font-face-src",
|
|
498
|
+
"font-face-uri",
|
|
499
|
+
"foreignobject",
|
|
500
|
+
"hatch",
|
|
501
|
+
"hatchpath",
|
|
502
|
+
"mesh",
|
|
503
|
+
"meshgradient",
|
|
504
|
+
"meshpatch",
|
|
505
|
+
"meshrow",
|
|
506
|
+
"missing-glyph",
|
|
507
|
+
"script",
|
|
508
|
+
"set",
|
|
509
|
+
"solidcolor",
|
|
510
|
+
"unknown",
|
|
511
|
+
"use"
|
|
512
|
+
]);
|
|
513
|
+
const mathMl$1 = freeze([
|
|
514
|
+
"math",
|
|
515
|
+
"menclose",
|
|
516
|
+
"merror",
|
|
517
|
+
"mfenced",
|
|
518
|
+
"mfrac",
|
|
519
|
+
"mglyph",
|
|
520
|
+
"mi",
|
|
521
|
+
"mlabeledtr",
|
|
522
|
+
"mmultiscripts",
|
|
523
|
+
"mn",
|
|
524
|
+
"mo",
|
|
525
|
+
"mover",
|
|
526
|
+
"mpadded",
|
|
527
|
+
"mphantom",
|
|
528
|
+
"mroot",
|
|
529
|
+
"mrow",
|
|
530
|
+
"ms",
|
|
531
|
+
"mspace",
|
|
532
|
+
"msqrt",
|
|
533
|
+
"mstyle",
|
|
534
|
+
"msub",
|
|
535
|
+
"msup",
|
|
536
|
+
"msubsup",
|
|
537
|
+
"mtable",
|
|
538
|
+
"mtd",
|
|
539
|
+
"mtext",
|
|
540
|
+
"mtr",
|
|
541
|
+
"munder",
|
|
542
|
+
"munderover",
|
|
543
|
+
"mprescripts"
|
|
544
|
+
]);
|
|
545
|
+
const mathMlDisallowed = freeze([
|
|
546
|
+
"maction",
|
|
547
|
+
"maligngroup",
|
|
548
|
+
"malignmark",
|
|
549
|
+
"mlongdiv",
|
|
550
|
+
"mscarries",
|
|
551
|
+
"mscarry",
|
|
552
|
+
"msgroup",
|
|
553
|
+
"mstack",
|
|
554
|
+
"msline",
|
|
555
|
+
"msrow",
|
|
556
|
+
"semantics",
|
|
557
|
+
"annotation",
|
|
558
|
+
"annotation-xml",
|
|
559
|
+
"mprescripts",
|
|
560
|
+
"none"
|
|
561
|
+
]);
|
|
562
|
+
const text = freeze(["#text"]);
|
|
563
|
+
const html = freeze([
|
|
564
|
+
"accept",
|
|
565
|
+
"action",
|
|
566
|
+
"align",
|
|
567
|
+
"alt",
|
|
568
|
+
"autocapitalize",
|
|
569
|
+
"autocomplete",
|
|
570
|
+
"autopictureinpicture",
|
|
571
|
+
"autoplay",
|
|
572
|
+
"background",
|
|
573
|
+
"bgcolor",
|
|
574
|
+
"border",
|
|
575
|
+
"capture",
|
|
576
|
+
"cellpadding",
|
|
577
|
+
"cellspacing",
|
|
578
|
+
"checked",
|
|
579
|
+
"cite",
|
|
580
|
+
"class",
|
|
581
|
+
"clear",
|
|
582
|
+
"color",
|
|
583
|
+
"cols",
|
|
584
|
+
"colspan",
|
|
585
|
+
"command",
|
|
586
|
+
"commandfor",
|
|
587
|
+
"controls",
|
|
588
|
+
"controlslist",
|
|
589
|
+
"coords",
|
|
590
|
+
"crossorigin",
|
|
591
|
+
"datetime",
|
|
592
|
+
"decoding",
|
|
593
|
+
"default",
|
|
594
|
+
"dir",
|
|
595
|
+
"disabled",
|
|
596
|
+
"disablepictureinpicture",
|
|
597
|
+
"disableremoteplayback",
|
|
598
|
+
"download",
|
|
599
|
+
"draggable",
|
|
600
|
+
"enctype",
|
|
601
|
+
"enterkeyhint",
|
|
602
|
+
"exportparts",
|
|
603
|
+
"face",
|
|
604
|
+
"for",
|
|
605
|
+
"headers",
|
|
606
|
+
"height",
|
|
607
|
+
"hidden",
|
|
608
|
+
"high",
|
|
609
|
+
"href",
|
|
610
|
+
"hreflang",
|
|
611
|
+
"id",
|
|
612
|
+
"inert",
|
|
613
|
+
"inputmode",
|
|
614
|
+
"integrity",
|
|
615
|
+
"ismap",
|
|
616
|
+
"kind",
|
|
617
|
+
"label",
|
|
618
|
+
"lang",
|
|
619
|
+
"list",
|
|
620
|
+
"loading",
|
|
621
|
+
"loop",
|
|
622
|
+
"low",
|
|
623
|
+
"max",
|
|
624
|
+
"maxlength",
|
|
625
|
+
"media",
|
|
626
|
+
"method",
|
|
627
|
+
"min",
|
|
628
|
+
"minlength",
|
|
629
|
+
"multiple",
|
|
630
|
+
"muted",
|
|
631
|
+
"name",
|
|
632
|
+
"nonce",
|
|
633
|
+
"noshade",
|
|
634
|
+
"novalidate",
|
|
635
|
+
"nowrap",
|
|
636
|
+
"open",
|
|
637
|
+
"optimum",
|
|
638
|
+
"part",
|
|
639
|
+
"pattern",
|
|
640
|
+
"placeholder",
|
|
641
|
+
"playsinline",
|
|
642
|
+
"popover",
|
|
643
|
+
"popovertarget",
|
|
644
|
+
"popovertargetaction",
|
|
645
|
+
"poster",
|
|
646
|
+
"preload",
|
|
647
|
+
"pubdate",
|
|
648
|
+
"radiogroup",
|
|
649
|
+
"readonly",
|
|
650
|
+
"rel",
|
|
651
|
+
"required",
|
|
652
|
+
"rev",
|
|
653
|
+
"reversed",
|
|
654
|
+
"role",
|
|
655
|
+
"rows",
|
|
656
|
+
"rowspan",
|
|
657
|
+
"spellcheck",
|
|
658
|
+
"scope",
|
|
659
|
+
"selected",
|
|
660
|
+
"shape",
|
|
661
|
+
"size",
|
|
662
|
+
"sizes",
|
|
663
|
+
"slot",
|
|
664
|
+
"span",
|
|
665
|
+
"srclang",
|
|
666
|
+
"start",
|
|
667
|
+
"src",
|
|
668
|
+
"srcset",
|
|
669
|
+
"step",
|
|
670
|
+
"style",
|
|
671
|
+
"summary",
|
|
672
|
+
"tabindex",
|
|
673
|
+
"title",
|
|
674
|
+
"translate",
|
|
675
|
+
"type",
|
|
676
|
+
"usemap",
|
|
677
|
+
"valign",
|
|
678
|
+
"value",
|
|
679
|
+
"width",
|
|
680
|
+
"wrap",
|
|
681
|
+
"xmlns"
|
|
682
|
+
]);
|
|
683
|
+
const svg = freeze([
|
|
684
|
+
"accent-height",
|
|
685
|
+
"accumulate",
|
|
686
|
+
"additive",
|
|
687
|
+
"alignment-baseline",
|
|
688
|
+
"amplitude",
|
|
689
|
+
"ascent",
|
|
690
|
+
"attributename",
|
|
691
|
+
"attributetype",
|
|
692
|
+
"azimuth",
|
|
693
|
+
"basefrequency",
|
|
694
|
+
"baseline-shift",
|
|
695
|
+
"begin",
|
|
696
|
+
"bias",
|
|
697
|
+
"by",
|
|
698
|
+
"class",
|
|
699
|
+
"clip",
|
|
700
|
+
"clippathunits",
|
|
701
|
+
"clip-path",
|
|
702
|
+
"clip-rule",
|
|
703
|
+
"color",
|
|
704
|
+
"color-interpolation",
|
|
705
|
+
"color-interpolation-filters",
|
|
706
|
+
"color-profile",
|
|
707
|
+
"color-rendering",
|
|
708
|
+
"cx",
|
|
709
|
+
"cy",
|
|
710
|
+
"d",
|
|
711
|
+
"dx",
|
|
712
|
+
"dy",
|
|
713
|
+
"diffuseconstant",
|
|
714
|
+
"direction",
|
|
715
|
+
"display",
|
|
716
|
+
"divisor",
|
|
717
|
+
"dominant-baseline",
|
|
718
|
+
"dur",
|
|
719
|
+
"edgemode",
|
|
720
|
+
"elevation",
|
|
721
|
+
"end",
|
|
722
|
+
"exponent",
|
|
723
|
+
"fill",
|
|
724
|
+
"fill-opacity",
|
|
725
|
+
"fill-rule",
|
|
726
|
+
"filter",
|
|
727
|
+
"filterunits",
|
|
728
|
+
"flood-color",
|
|
729
|
+
"flood-opacity",
|
|
730
|
+
"font-family",
|
|
731
|
+
"font-size",
|
|
732
|
+
"font-size-adjust",
|
|
733
|
+
"font-stretch",
|
|
734
|
+
"font-style",
|
|
735
|
+
"font-variant",
|
|
736
|
+
"font-weight",
|
|
737
|
+
"fx",
|
|
738
|
+
"fy",
|
|
739
|
+
"g1",
|
|
740
|
+
"g2",
|
|
741
|
+
"glyph-name",
|
|
742
|
+
"glyphref",
|
|
743
|
+
"gradientunits",
|
|
744
|
+
"gradienttransform",
|
|
745
|
+
"height",
|
|
746
|
+
"href",
|
|
747
|
+
"id",
|
|
748
|
+
"image-rendering",
|
|
749
|
+
"in",
|
|
750
|
+
"in2",
|
|
751
|
+
"intercept",
|
|
752
|
+
"k",
|
|
753
|
+
"k1",
|
|
754
|
+
"k2",
|
|
755
|
+
"k3",
|
|
756
|
+
"k4",
|
|
757
|
+
"kerning",
|
|
758
|
+
"keypoints",
|
|
759
|
+
"keysplines",
|
|
760
|
+
"keytimes",
|
|
761
|
+
"lang",
|
|
762
|
+
"lengthadjust",
|
|
763
|
+
"letter-spacing",
|
|
764
|
+
"kernelmatrix",
|
|
765
|
+
"kernelunitlength",
|
|
766
|
+
"lighting-color",
|
|
767
|
+
"local",
|
|
768
|
+
"marker-end",
|
|
769
|
+
"marker-mid",
|
|
770
|
+
"marker-start",
|
|
771
|
+
"markerheight",
|
|
772
|
+
"markerunits",
|
|
773
|
+
"markerwidth",
|
|
774
|
+
"maskcontentunits",
|
|
775
|
+
"maskunits",
|
|
776
|
+
"max",
|
|
777
|
+
"mask",
|
|
778
|
+
"mask-type",
|
|
779
|
+
"media",
|
|
780
|
+
"method",
|
|
781
|
+
"mode",
|
|
782
|
+
"min",
|
|
783
|
+
"name",
|
|
784
|
+
"numoctaves",
|
|
785
|
+
"offset",
|
|
786
|
+
"operator",
|
|
787
|
+
"opacity",
|
|
788
|
+
"order",
|
|
789
|
+
"orient",
|
|
790
|
+
"orientation",
|
|
791
|
+
"origin",
|
|
792
|
+
"overflow",
|
|
793
|
+
"paint-order",
|
|
794
|
+
"path",
|
|
795
|
+
"pathlength",
|
|
796
|
+
"patterncontentunits",
|
|
797
|
+
"patterntransform",
|
|
798
|
+
"patternunits",
|
|
799
|
+
"pointer-events",
|
|
800
|
+
"points",
|
|
801
|
+
"preservealpha",
|
|
802
|
+
"preserveaspectratio",
|
|
803
|
+
"primitiveunits",
|
|
804
|
+
"r",
|
|
805
|
+
"rx",
|
|
806
|
+
"ry",
|
|
807
|
+
"radius",
|
|
808
|
+
"refx",
|
|
809
|
+
"refy",
|
|
810
|
+
"repeatcount",
|
|
811
|
+
"repeatdur",
|
|
812
|
+
"restart",
|
|
813
|
+
"result",
|
|
814
|
+
"rotate",
|
|
815
|
+
"scale",
|
|
816
|
+
"seed",
|
|
817
|
+
"shape-rendering",
|
|
818
|
+
"slope",
|
|
819
|
+
"specularconstant",
|
|
820
|
+
"specularexponent",
|
|
821
|
+
"spreadmethod",
|
|
822
|
+
"startoffset",
|
|
823
|
+
"stddeviation",
|
|
824
|
+
"stitchtiles",
|
|
825
|
+
"stop-color",
|
|
826
|
+
"stop-opacity",
|
|
827
|
+
"stroke-dasharray",
|
|
828
|
+
"stroke-dashoffset",
|
|
829
|
+
"stroke-linecap",
|
|
830
|
+
"stroke-linejoin",
|
|
831
|
+
"stroke-miterlimit",
|
|
832
|
+
"stroke-opacity",
|
|
833
|
+
"stroke",
|
|
834
|
+
"stroke-width",
|
|
835
|
+
"style",
|
|
836
|
+
"surfacescale",
|
|
837
|
+
"systemlanguage",
|
|
838
|
+
"tabindex",
|
|
839
|
+
"tablevalues",
|
|
840
|
+
"targetx",
|
|
841
|
+
"targety",
|
|
842
|
+
"transform",
|
|
843
|
+
"transform-origin",
|
|
844
|
+
"text-anchor",
|
|
845
|
+
"text-decoration",
|
|
846
|
+
"text-orientation",
|
|
847
|
+
"text-rendering",
|
|
848
|
+
"textlength",
|
|
849
|
+
"type",
|
|
850
|
+
"u1",
|
|
851
|
+
"u2",
|
|
852
|
+
"unicode",
|
|
853
|
+
"values",
|
|
854
|
+
"vector-effect",
|
|
855
|
+
"viewbox",
|
|
856
|
+
"visibility",
|
|
857
|
+
"version",
|
|
858
|
+
"vert-adv-y",
|
|
859
|
+
"vert-origin-x",
|
|
860
|
+
"vert-origin-y",
|
|
861
|
+
"width",
|
|
862
|
+
"word-spacing",
|
|
863
|
+
"wrap",
|
|
864
|
+
"writing-mode",
|
|
865
|
+
"xchannelselector",
|
|
866
|
+
"ychannelselector",
|
|
867
|
+
"x",
|
|
868
|
+
"x1",
|
|
869
|
+
"x2",
|
|
870
|
+
"xmlns",
|
|
871
|
+
"y",
|
|
872
|
+
"y1",
|
|
873
|
+
"y2",
|
|
874
|
+
"z",
|
|
875
|
+
"zoomandpan"
|
|
876
|
+
]);
|
|
877
|
+
const mathMl = freeze([
|
|
878
|
+
"accent",
|
|
879
|
+
"accentunder",
|
|
880
|
+
"align",
|
|
881
|
+
"bevelled",
|
|
882
|
+
"close",
|
|
883
|
+
"columnalign",
|
|
884
|
+
"columnlines",
|
|
885
|
+
"columnspacing",
|
|
886
|
+
"columnspan",
|
|
887
|
+
"denomalign",
|
|
888
|
+
"depth",
|
|
889
|
+
"dir",
|
|
890
|
+
"display",
|
|
891
|
+
"displaystyle",
|
|
892
|
+
"encoding",
|
|
893
|
+
"fence",
|
|
894
|
+
"frame",
|
|
895
|
+
"height",
|
|
896
|
+
"href",
|
|
897
|
+
"id",
|
|
898
|
+
"largeop",
|
|
899
|
+
"length",
|
|
900
|
+
"linethickness",
|
|
901
|
+
"lquote",
|
|
902
|
+
"lspace",
|
|
903
|
+
"mathbackground",
|
|
904
|
+
"mathcolor",
|
|
905
|
+
"mathsize",
|
|
906
|
+
"mathvariant",
|
|
907
|
+
"maxsize",
|
|
908
|
+
"minsize",
|
|
909
|
+
"movablelimits",
|
|
910
|
+
"notation",
|
|
911
|
+
"numalign",
|
|
912
|
+
"open",
|
|
913
|
+
"rowalign",
|
|
914
|
+
"rowlines",
|
|
915
|
+
"rowspacing",
|
|
916
|
+
"rowspan",
|
|
917
|
+
"rspace",
|
|
918
|
+
"rquote",
|
|
919
|
+
"scriptlevel",
|
|
920
|
+
"scriptminsize",
|
|
921
|
+
"scriptsizemultiplier",
|
|
922
|
+
"selection",
|
|
923
|
+
"separator",
|
|
924
|
+
"separators",
|
|
925
|
+
"stretchy",
|
|
926
|
+
"subscriptshift",
|
|
927
|
+
"supscriptshift",
|
|
928
|
+
"symmetric",
|
|
929
|
+
"voffset",
|
|
930
|
+
"width",
|
|
931
|
+
"xmlns"
|
|
932
|
+
]);
|
|
933
|
+
const xml = freeze([
|
|
934
|
+
"xlink:href",
|
|
935
|
+
"xml:id",
|
|
936
|
+
"xlink:title",
|
|
937
|
+
"xml:space",
|
|
938
|
+
"xmlns:xlink"
|
|
939
|
+
]);
|
|
330
940
|
const MUSTACHE_EXPR = seal(/{{[\w\W]*|^[\w\W]*}}/g);
|
|
331
941
|
const ERB_EXPR = seal(/<%[\w\W]*|^[\w\W]*%>/g);
|
|
332
942
|
const TMPLIT_EXPR = seal(/\${[\w\W]*/g);
|
|
333
|
-
const DATA_ATTR = seal(/^data-[\-\w.\u00B7-\uFFFF]+$/);
|
|
334
|
-
const ARIA_ATTR = seal(/^aria-[\-\w]+$/);
|
|
335
|
-
const IS_ALLOWED_URI = seal(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i
|
|
336
|
-
);
|
|
943
|
+
const DATA_ATTR = seal(/^data-[\-\w.\u00B7-\uFFFF]+$/);
|
|
944
|
+
const ARIA_ATTR = seal(/^aria-[\-\w]+$/);
|
|
945
|
+
const IS_ALLOWED_URI = seal(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i);
|
|
337
946
|
const IS_SCRIPT_OR_DATA = seal(/^(?:\w+script|data):/i);
|
|
338
|
-
const ATTR_WHITESPACE = seal(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g
|
|
339
|
-
);
|
|
947
|
+
const ATTR_WHITESPACE = seal(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g);
|
|
340
948
|
const DOCTYPE_NAME = seal(/^html$/i);
|
|
341
949
|
const CUSTOM_ELEMENT = seal(/^[a-z][.\w]*(-[.\w]+)+$/i);
|
|
342
|
-
// Markup-significant character probes used by _sanitizeElements.
|
|
343
|
-
// Shared module-level instances are safe despite the sticky /g flags:
|
|
344
|
-
// unapply() resets lastIndex for RegExp receivers before every call.
|
|
345
950
|
const ELEMENT_MARKUP_PROBE = seal(/<[/\w!]/g);
|
|
346
951
|
const COMMENT_MARKUP_PROBE = seal(/<[/\w]/g);
|
|
347
952
|
const FALLBACK_TAG_CLOSE = seal(/<\/no(script|embed|frames)/i);
|
|
348
953
|
const SELF_CLOSING_TAG = seal(/\/>/i);
|
|
349
|
-
|
|
350
|
-
/* eslint-disable @typescript-eslint/indent */
|
|
351
|
-
// https://developer.mozilla.org/en-US/docs/Web/API/Node/nodeType
|
|
352
954
|
const NODE_TYPE = {
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
documentFragment: 11,
|
|
366
|
-
notation: 12 // Deprecated
|
|
955
|
+
element: 1,
|
|
956
|
+
attribute: 2,
|
|
957
|
+
text: 3,
|
|
958
|
+
cdataSection: 4,
|
|
959
|
+
entityReference: 5,
|
|
960
|
+
entityNode: 6,
|
|
961
|
+
processingInstruction: 7,
|
|
962
|
+
comment: 8,
|
|
963
|
+
document: 9,
|
|
964
|
+
documentType: 10,
|
|
965
|
+
documentFragment: 11,
|
|
966
|
+
notation: 12
|
|
367
967
|
};
|
|
968
|
+
const LITERAL_TEXT_ELEMENT_NAMES = [
|
|
969
|
+
"style",
|
|
970
|
+
"script",
|
|
971
|
+
"xmp",
|
|
972
|
+
"iframe",
|
|
973
|
+
"noembed",
|
|
974
|
+
"noframes",
|
|
975
|
+
"plaintext",
|
|
976
|
+
"noscript"
|
|
977
|
+
];
|
|
978
|
+
const LITERAL_TEXT_ELEMENTS = freeze(addToSet({}, LITERAL_TEXT_ELEMENT_NAMES));
|
|
979
|
+
const LITERAL_TEXT_CLOSE = function() {
|
|
980
|
+
const map = {};
|
|
981
|
+
arrayForEach(LITERAL_TEXT_ELEMENT_NAMES, (name) => {
|
|
982
|
+
map[name] = seal(new RegExp("</" + name + "(?=[\\t\\n\\f\\r />])", "i"));
|
|
983
|
+
});
|
|
984
|
+
return freeze(map);
|
|
985
|
+
}();
|
|
368
986
|
const getGlobal = function getGlobal() {
|
|
369
|
-
|
|
987
|
+
return typeof window === "undefined" ? null : window;
|
|
370
988
|
};
|
|
371
989
|
/**
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
990
|
+
* Creates a no-op policy for internal use only.
|
|
991
|
+
* Don't export this function outside this module!
|
|
992
|
+
* @param trustedTypes The policy factory.
|
|
993
|
+
* @param purifyHostElement The Script element used to load DOMPurify (to determine policy name suffix).
|
|
994
|
+
* @return The policy created (or null, if Trusted Types
|
|
995
|
+
* are not supported or creating the policy failed).
|
|
996
|
+
*/
|
|
379
997
|
const _createTrustedTypesPolicy = function _createTrustedTypesPolicy(trustedTypes, purifyHostElement) {
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
return scriptUrl;
|
|
399
|
-
}
|
|
400
|
-
});
|
|
401
|
-
} catch (_) {
|
|
402
|
-
// Policy creation failed (most likely another DOMPurify script has
|
|
403
|
-
// already run). Skip creating the policy, as this will only cause errors
|
|
404
|
-
// if TT are enforced.
|
|
405
|
-
console.warn('TrustedTypes policy ' + policyName + ' could not be created.');
|
|
406
|
-
return null;
|
|
407
|
-
}
|
|
998
|
+
if (typeof trustedTypes !== "object" || typeof trustedTypes.createPolicy !== "function") return null;
|
|
999
|
+
let suffix = null;
|
|
1000
|
+
const ATTR_NAME = "data-tt-policy-suffix";
|
|
1001
|
+
if (purifyHostElement && purifyHostElement.hasAttribute(ATTR_NAME)) suffix = purifyHostElement.getAttribute(ATTR_NAME);
|
|
1002
|
+
const policyName = "dompurify" + (suffix ? "#" + suffix : "");
|
|
1003
|
+
try {
|
|
1004
|
+
return trustedTypes.createPolicy(policyName, {
|
|
1005
|
+
createHTML(html) {
|
|
1006
|
+
return html;
|
|
1007
|
+
},
|
|
1008
|
+
createScriptURL(scriptUrl) {
|
|
1009
|
+
return scriptUrl;
|
|
1010
|
+
}
|
|
1011
|
+
});
|
|
1012
|
+
} catch (_) {
|
|
1013
|
+
console.warn("TrustedTypes policy " + policyName + " could not be created.");
|
|
1014
|
+
return null;
|
|
1015
|
+
}
|
|
408
1016
|
};
|
|
409
1017
|
const _createHooksMap = function _createHooksMap() {
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
1018
|
+
return {
|
|
1019
|
+
afterSanitizeAttributes: [],
|
|
1020
|
+
afterSanitizeElements: [],
|
|
1021
|
+
afterSanitizeShadowDOM: [],
|
|
1022
|
+
beforeSanitizeAttributes: [],
|
|
1023
|
+
beforeSanitizeElements: [],
|
|
1024
|
+
beforeSanitizeShadowDOM: [],
|
|
1025
|
+
uponSanitizeAttribute: [],
|
|
1026
|
+
uponSanitizeElement: [],
|
|
1027
|
+
uponSanitizeShadowNode: []
|
|
1028
|
+
};
|
|
421
1029
|
};
|
|
422
1030
|
/**
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
1031
|
+
* Resolve a set-valued configuration option: a fresh set built from
|
|
1032
|
+
* cfg[key] when it is an own array property (seeded with a clone of
|
|
1033
|
+
* options.base when given, case-normalized via options.transform),
|
|
1034
|
+
* the fallback set otherwise.
|
|
1035
|
+
*
|
|
1036
|
+
* @param cfg the cloned, prototype-free configuration object
|
|
1037
|
+
* @param key the configuration property to read
|
|
1038
|
+
* @param fallback the set to use when the option is absent or not an array
|
|
1039
|
+
* @param options transform and optional base set to merge into
|
|
1040
|
+
* @returns the resolved set
|
|
1041
|
+
*/
|
|
434
1042
|
const _resolveSetOption = function _resolveSetOption(cfg, key, fallback, options) {
|
|
435
|
-
|
|
1043
|
+
return objectHasOwnProperty(cfg, key) && arrayIsArray(cfg[key]) ? addToSet(options.base ? clone(options.base) : {}, cfg[key], options.transform) : fallback;
|
|
1044
|
+
};
|
|
1045
|
+
/**
|
|
1046
|
+
* Resolve an object-valued configuration option: a prototype-free clone
|
|
1047
|
+
* of cfg[key] when it is an own, truthy object property, else a fresh
|
|
1048
|
+
* fallback built by makeFallback (fresh on every parse, so a previous
|
|
1049
|
+
* parse can never leak state into the next one).
|
|
1050
|
+
*
|
|
1051
|
+
* @param cfg the cloned, prototype-free configuration object
|
|
1052
|
+
* @param key the configuration property to read
|
|
1053
|
+
* @param makeFallback builds the fallback value when the option is absent
|
|
1054
|
+
* @returns the resolved object
|
|
1055
|
+
*/
|
|
1056
|
+
const _resolveObjectOption = function _resolveObjectOption(cfg, key, makeFallback) {
|
|
1057
|
+
const value = objectHasOwnProperty(cfg, key) ? cfg[key] : void 0;
|
|
1058
|
+
return value && typeof value === "object" ? clone(value) : makeFallback();
|
|
436
1059
|
};
|
|
437
1060
|
function createDOMPurify() {
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
|
|
1821
|
-
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
|
|
1839
|
-
|
|
1840
|
-
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
while (shadowNode = shadowIterator.nextNode()) {
|
|
1850
|
-
/* Execute a hook if present */
|
|
1851
|
-
_executeHooks(hooks.uponSanitizeShadowNode, shadowNode, null);
|
|
1852
|
-
/* Sanitize tags and elements */
|
|
1853
|
-
_sanitizeElements(shadowNode);
|
|
1854
|
-
/* Check attributes next */
|
|
1855
|
-
_sanitizeAttributes(shadowNode);
|
|
1856
|
-
/* Deep shadow DOM detected.
|
|
1857
|
-
Realm-safe check (GHSA-hpcv-96wg-7vj8): use nodeType against the
|
|
1858
|
-
DOCUMENT_FRAGMENT_NODE constant rather than instanceof, so we
|
|
1859
|
-
recurse into <template>.content from foreign realms too. */
|
|
1860
|
-
if (_isDocumentFragment(shadowNode.content)) {
|
|
1861
|
-
_sanitizeShadowDOM2(shadowNode.content);
|
|
1862
|
-
}
|
|
1863
|
-
/* An element iterated here may itself host an attached
|
|
1864
|
-
shadow root. The default NodeIterator does not enter shadow
|
|
1865
|
-
trees, so a shadow root nested inside template.content was
|
|
1866
|
-
previously reached by no walk at all (the pre-pass at
|
|
1867
|
-
_sanitizeAttachedShadowRoots descends via childNodes, which
|
|
1868
|
-
doesn't enter template.content; the template-content recursion
|
|
1869
|
-
above iterates the content but never inspected shadowRoot).
|
|
1870
|
-
Walk it explicitly. The nodeType guard avoids reading
|
|
1871
|
-
shadowRoot off text / comment / CDATA / PI nodes that the
|
|
1872
|
-
iterator also surfaces. */
|
|
1873
|
-
const shadowNodeType = getNodeType ? getNodeType(shadowNode) : shadowNode.nodeType;
|
|
1874
|
-
if (shadowNodeType === NODE_TYPE.element) {
|
|
1875
|
-
const innerSr = getShadowRoot(shadowNode);
|
|
1876
|
-
if (_isDocumentFragment(innerSr)) {
|
|
1877
|
-
_sanitizeAttachedShadowRoots(innerSr);
|
|
1878
|
-
_sanitizeShadowDOM2(innerSr);
|
|
1879
|
-
}
|
|
1880
|
-
}
|
|
1881
|
-
}
|
|
1882
|
-
/* Execute a hook if present */
|
|
1883
|
-
_executeHooks(hooks.afterSanitizeShadowDOM, fragment, null);
|
|
1884
|
-
};
|
|
1885
|
-
/**
|
|
1886
|
-
* _sanitizeAttachedShadowRoots
|
|
1887
|
-
*
|
|
1888
|
-
* Walks `root` and feeds every attached shadow root we encounter into
|
|
1889
|
-
* the existing _sanitizeShadowDOM pipeline. The default node iterator
|
|
1890
|
-
* does not descend into shadow trees, so nodes inside an attached
|
|
1891
|
-
* shadow root would otherwise be skipped entirely.
|
|
1892
|
-
*
|
|
1893
|
-
* Two real input paths put attached shadow roots in front of us:
|
|
1894
|
-
* 1. IN_PLACE on a DOM node that already has shadow roots attached.
|
|
1895
|
-
* 2. DOM-node input where importNode(dirty, true) deep-clones the
|
|
1896
|
-
* shadow root because it was created with `clonable: true`.
|
|
1897
|
-
*
|
|
1898
|
-
* This pass runs once, up front, so the main iteration loop (and the
|
|
1899
|
-
* existing _sanitizeShadowDOM template-content recursion) stay
|
|
1900
|
-
* untouched — string-input paths are not affected.
|
|
1901
|
-
*
|
|
1902
|
-
* @param root the subtree root to walk for attached shadow roots
|
|
1903
|
-
*/
|
|
1904
|
-
const _sanitizeAttachedShadowRoots = function _sanitizeAttachedShadowRoots(root) {
|
|
1905
|
-
/* Iterative (explicit stack) rather than per-child recursion. DOM APIs
|
|
1906
|
-
impose no depth cap, so an attacker-shaped tree (JSON/CRDT/editor data
|
|
1907
|
-
built straight into the DOM — the IN_PLACE surface) deeper than the JS
|
|
1908
|
-
call-stack budget would otherwise overflow native recursion here and
|
|
1909
|
-
throw at the IN_PLACE entry pre-pass, before a single node is
|
|
1910
|
-
sanitized, leaving the caller's live tree untouched (fail-open). See
|
|
1911
|
-
campaign-3 F4. A heap stack keeps depth off the call stack.
|
|
1912
|
-
Each work item is either a node to descend into, or a deferred
|
|
1913
|
-
`_sanitizeShadowDOM` for an already-walked shadow root. The deferred
|
|
1914
|
-
form preserves the original post-order discipline: a shadow root's
|
|
1915
|
-
nested shadow roots are discovered before the outer shadow is
|
|
1916
|
-
sanitized (which may remove hosts). Pushes are in reverse of the
|
|
1917
|
-
desired processing order (LIFO): template content, then children, then
|
|
1918
|
-
the shadow-sanitize, then the shadow walk — so the order matches the
|
|
1919
|
-
previous recursion exactly. */
|
|
1920
|
-
const stack = [{
|
|
1921
|
-
node: root,
|
|
1922
|
-
shadow: null
|
|
1923
|
-
}];
|
|
1924
|
-
while (stack.length > 0) {
|
|
1925
|
-
const item = stack.pop();
|
|
1926
|
-
/* Deferred shadow-DOM sanitisation: runs after its subtree was walked. */
|
|
1927
|
-
if (item.shadow) {
|
|
1928
|
-
_sanitizeShadowDOM2(item.shadow);
|
|
1929
|
-
continue;
|
|
1930
|
-
}
|
|
1931
|
-
const node = item.node;
|
|
1932
|
-
const nodeType = getNodeType ? getNodeType(node) : node.nodeType;
|
|
1933
|
-
const isElement = nodeType === NODE_TYPE.element;
|
|
1934
|
-
/* (pushed last → processed first) Children, snapshotted in reverse so
|
|
1935
|
-
the first child is processed first. Snapshotting matters because a
|
|
1936
|
-
hook may detach siblings mid-walk. */
|
|
1937
|
-
const childNodes = getChildNodes(node);
|
|
1938
|
-
if (childNodes) {
|
|
1939
|
-
for (let i = childNodes.length - 1; i >= 0; --i) {
|
|
1940
|
-
stack.push({
|
|
1941
|
-
node: childNodes[i],
|
|
1942
|
-
shadow: null
|
|
1943
|
-
});
|
|
1944
|
-
}
|
|
1945
|
-
}
|
|
1946
|
-
/* (pushed before children → processed after them, matching the old
|
|
1947
|
-
"template content last" order) When the node is a <template>,
|
|
1948
|
-
descend into its content. */
|
|
1949
|
-
if (isElement) {
|
|
1950
|
-
const rootName = getNodeName ? getNodeName(node) : null;
|
|
1951
|
-
if (typeof rootName === 'string' && transformCaseFunc(rootName) === 'template') {
|
|
1952
|
-
const content = node.content;
|
|
1953
|
-
if (_isDocumentFragment(content)) {
|
|
1954
|
-
stack.push({
|
|
1955
|
-
node: content,
|
|
1956
|
-
shadow: null
|
|
1957
|
-
});
|
|
1958
|
-
}
|
|
1959
|
-
}
|
|
1960
|
-
}
|
|
1961
|
-
/* Shadow root (processed first): walk its subtree, then sanitise it.
|
|
1962
|
-
Realm-safe check (GHSA-hpcv-96wg-7vj8): nodeType-based detection
|
|
1963
|
-
rather than `instanceof DocumentFragment`, which is realm-bound and
|
|
1964
|
-
silently skipped foreign-realm shadow roots (e.g.
|
|
1965
|
-
iframe.contentDocument attachShadow). */
|
|
1966
|
-
if (isElement) {
|
|
1967
|
-
const sr = getShadowRoot(node);
|
|
1968
|
-
if (_isDocumentFragment(sr)) {
|
|
1969
|
-
/* Push the deferred sanitise first so it pops after the shadow
|
|
1970
|
-
walk we push next, i.e. nested shadow roots are discovered
|
|
1971
|
-
before this one is sanitised. */
|
|
1972
|
-
stack.push({
|
|
1973
|
-
node: null,
|
|
1974
|
-
shadow: sr
|
|
1975
|
-
}, {
|
|
1976
|
-
node: sr,
|
|
1977
|
-
shadow: null
|
|
1978
|
-
});
|
|
1979
|
-
}
|
|
1980
|
-
}
|
|
1981
|
-
}
|
|
1982
|
-
};
|
|
1983
|
-
// eslint-disable-next-line complexity
|
|
1984
|
-
DOMPurify.sanitize = function (dirty) {
|
|
1985
|
-
let cfg = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
1986
|
-
let body = null;
|
|
1987
|
-
let importedNode = null;
|
|
1988
|
-
let currentNode = null;
|
|
1989
|
-
let returnNode = null;
|
|
1990
|
-
/* Make sure we have a string to sanitize.
|
|
1991
|
-
DO NOT return early, as this will return the wrong type if
|
|
1992
|
-
the user has requested a DOM object rather than a string */
|
|
1993
|
-
IS_EMPTY_INPUT = !dirty;
|
|
1994
|
-
if (IS_EMPTY_INPUT) {
|
|
1995
|
-
dirty = '<!-->';
|
|
1996
|
-
}
|
|
1997
|
-
/* Stringify, in case dirty is an object */
|
|
1998
|
-
if (typeof dirty !== 'string' && !_isNode(dirty)) {
|
|
1999
|
-
dirty = stringifyValue(dirty);
|
|
2000
|
-
if (typeof dirty !== 'string') {
|
|
2001
|
-
throw typeErrorCreate('dirty is not a string, aborting');
|
|
2002
|
-
}
|
|
2003
|
-
}
|
|
2004
|
-
/* Return dirty HTML if DOMPurify cannot run */
|
|
2005
|
-
if (!DOMPurify.isSupported) {
|
|
2006
|
-
return dirty;
|
|
2007
|
-
}
|
|
2008
|
-
/* Assign config vars */
|
|
2009
|
-
if (!SET_CONFIG) {
|
|
2010
|
-
_parseConfig(cfg);
|
|
2011
|
-
}
|
|
2012
|
-
/* Clean up removed elements */
|
|
2013
|
-
DOMPurify.removed = [];
|
|
2014
|
-
/* Resolve IN_PLACE for this call without mutating persistent config.
|
|
2015
|
-
Writing the IN_PLACE closure variable here leaks under setConfig(),
|
|
2016
|
-
where _parseConfig is skipped on later calls: a single string call would
|
|
2017
|
-
disable in-place mode for every subsequent node call, returning a
|
|
2018
|
-
sanitized copy while leaving the caller's node — which in-place callers
|
|
2019
|
-
keep using and whose return value they ignore — unsanitized. REPORT-2. */
|
|
2020
|
-
const inPlace = IN_PLACE && typeof dirty !== 'string' && _isNode(dirty);
|
|
2021
|
-
if (inPlace) {
|
|
2022
|
-
/* Do some early pre-sanitization to avoid unsafe root nodes.
|
|
2023
|
-
Read nodeName through the cached prototype getter — a clobbering
|
|
2024
|
-
child named "nodeName" on the form root would otherwise shadow
|
|
2025
|
-
the property and let this check skip the root-allowlist
|
|
2026
|
-
validation entirely. */
|
|
2027
|
-
const nn = getNodeName ? getNodeName(dirty) : dirty.nodeName;
|
|
2028
|
-
if (typeof nn === 'string') {
|
|
2029
|
-
const tagName = transformCaseFunc(nn);
|
|
2030
|
-
if (!ALLOWED_TAGS[tagName] || FORBID_TAGS[tagName]) {
|
|
2031
|
-
throw typeErrorCreate('root node is forbidden and cannot be sanitized in-place');
|
|
2032
|
-
}
|
|
2033
|
-
}
|
|
2034
|
-
/* Pre-flight the root through _isClobbered. The iterator-driven
|
|
2035
|
-
removal path can not detach a parent-less root: _forceRemove
|
|
2036
|
-
falls through to Element.prototype.remove(), which per spec
|
|
2037
|
-
is a no-op on a node with no parent. A clobbered root would
|
|
2038
|
-
then survive the main loop with its attributes uninspected,
|
|
2039
|
-
because _sanitizeAttributes early-returns on _isClobbered. The
|
|
2040
|
-
result would be an attacker-controlled form, complete with any
|
|
2041
|
-
event-handler attributes the caller passed in, handed back to
|
|
2042
|
-
the application unsanitized. Refuse to sanitize such a root
|
|
2043
|
-
the same way we refuse a forbidden tag. GHSA-r47g-fvhr-h676. */
|
|
2044
|
-
if (_isClobbered(dirty)) {
|
|
2045
|
-
throw typeErrorCreate('root node is clobbered and cannot be sanitized in-place');
|
|
2046
|
-
}
|
|
2047
|
-
/* Sanitize attached shadow roots before the main iterator runs.
|
|
2048
|
-
The iterator does not descend into shadow trees. Same fail-closed
|
|
2049
|
-
barrier as the main walk (campaign-3 F2): a custom-element reaction
|
|
2050
|
-
inside a shadow root could abort this pre-pass before the walk runs,
|
|
2051
|
-
which would otherwise leave the entire live tree unsanitized. */
|
|
2052
|
-
try {
|
|
2053
|
-
_sanitizeAttachedShadowRoots(dirty);
|
|
2054
|
-
} catch (error) {
|
|
2055
|
-
_neutralizeRoot(dirty);
|
|
2056
|
-
throw error;
|
|
2057
|
-
}
|
|
2058
|
-
} else if (_isNode(dirty)) {
|
|
2059
|
-
/* If dirty is a DOM element, append to an empty document to avoid
|
|
2060
|
-
elements being stripped by the parser */
|
|
2061
|
-
body = _initDocument('<!---->');
|
|
2062
|
-
importedNode = body.ownerDocument.importNode(dirty, true);
|
|
2063
|
-
if (importedNode.nodeType === NODE_TYPE.element && importedNode.nodeName === 'BODY') {
|
|
2064
|
-
/* Node is already a body, use as is */
|
|
2065
|
-
body = importedNode;
|
|
2066
|
-
} else if (importedNode.nodeName === 'HTML') {
|
|
2067
|
-
body = importedNode;
|
|
2068
|
-
} else {
|
|
2069
|
-
// eslint-disable-next-line unicorn/prefer-dom-node-append
|
|
2070
|
-
body.appendChild(importedNode);
|
|
2071
|
-
}
|
|
2072
|
-
/* Clonable shadow roots are deep-cloned by importNode(); sanitize
|
|
2073
|
-
them before the main iterator runs, since the iterator does not
|
|
2074
|
-
descend into shadow trees. The walk routes every read through a
|
|
2075
|
-
cached prototype getter so clobbering descendants on a form root
|
|
2076
|
-
cannot hide a shadow host from this pass. */
|
|
2077
|
-
_sanitizeAttachedShadowRoots(importedNode);
|
|
2078
|
-
} else {
|
|
2079
|
-
/* Exit directly if we have nothing to do */
|
|
2080
|
-
if (!RETURN_DOM && !SAFE_FOR_TEMPLATES && !WHOLE_DOCUMENT &&
|
|
2081
|
-
// eslint-disable-next-line unicorn/prefer-includes
|
|
2082
|
-
dirty.indexOf('<') === -1) {
|
|
2083
|
-
return trustedTypesPolicy && RETURN_TRUSTED_TYPE ? _createTrustedHTML(dirty) : dirty;
|
|
2084
|
-
}
|
|
2085
|
-
/* Initialize the document to work on */
|
|
2086
|
-
body = _initDocument(dirty);
|
|
2087
|
-
/* Check we have a DOM node from the data */
|
|
2088
|
-
if (!body) {
|
|
2089
|
-
return RETURN_DOM ? null : RETURN_TRUSTED_TYPE ? emptyHTML : '';
|
|
2090
|
-
}
|
|
2091
|
-
}
|
|
2092
|
-
/* Remove first element node (ours) if FORCE_BODY is set */
|
|
2093
|
-
if (body && FORCE_BODY) {
|
|
2094
|
-
_forceRemove(body.firstChild);
|
|
2095
|
-
}
|
|
2096
|
-
/* Get node iterator */
|
|
2097
|
-
const nodeIterator = _createNodeIterator(inPlace ? dirty : body);
|
|
2098
|
-
/* Now start iterating over the created document.
|
|
2099
|
-
The walk runs inside an exception barrier (campaign-3 F2): a re-entrant
|
|
2100
|
-
engine/custom-element mutation can detach a node mid-walk so
|
|
2101
|
-
`_forceRemove`'s parentless guard throws, aborting the loop. Without the
|
|
2102
|
-
barrier the caller's in-place tree would be left half-sanitized with the
|
|
2103
|
-
unvisited tail still armed. On any throw we fail closed — strip the
|
|
2104
|
-
in-place root bare — then rethrow so the existing throw contract is
|
|
2105
|
-
preserved. (String/DOM-copy paths never return the partial body, so the
|
|
2106
|
-
propagating throw is already fail-closed there.) */
|
|
2107
|
-
try {
|
|
2108
|
-
while (currentNode = nodeIterator.nextNode()) {
|
|
2109
|
-
/* Sanitize tags and elements */
|
|
2110
|
-
_sanitizeElements(currentNode);
|
|
2111
|
-
/* Check attributes next */
|
|
2112
|
-
_sanitizeAttributes(currentNode);
|
|
2113
|
-
/* Shadow DOM detected, sanitize it.
|
|
2114
|
-
Realm-safe check (GHSA-hpcv-96wg-7vj8): nodeType-based detection
|
|
2115
|
-
instead of instanceof, so foreign-realm <template>.content is
|
|
2116
|
-
walked correctly. */
|
|
2117
|
-
if (_isDocumentFragment(currentNode.content)) {
|
|
2118
|
-
_sanitizeShadowDOM2(currentNode.content);
|
|
2119
|
-
}
|
|
2120
|
-
}
|
|
2121
|
-
} catch (error) {
|
|
2122
|
-
if (inPlace) {
|
|
2123
|
-
_neutralizeRoot(dirty);
|
|
2124
|
-
}
|
|
2125
|
-
throw error;
|
|
2126
|
-
}
|
|
2127
|
-
/* If we sanitized `dirty` in-place, return it. */
|
|
2128
|
-
if (inPlace) {
|
|
2129
|
-
/* Fail-closed completion of the audit-5 F1 fix: every node removed from
|
|
2130
|
-
the caller's live tree is detached but may still hold a queued
|
|
2131
|
-
resource-event handler that fires in page scope after we return. The
|
|
2132
|
-
move-hoist covers only disallowed-tag KEEP_CONTENT removals; strip the
|
|
2133
|
-
non-allow-listed attributes off every other removed subtree (clobber,
|
|
2134
|
-
mXSS, namespace, comments, KEEP_CONTENT:false, …) so those handlers are
|
|
2135
|
-
cancelled before any event can fire. Runs synchronously, pre-return. */
|
|
2136
|
-
arrayForEach(DOMPurify.removed, entry => {
|
|
2137
|
-
if (entry.element) {
|
|
2138
|
-
_neutralizeSubtree(entry.element);
|
|
2139
|
-
}
|
|
2140
|
-
});
|
|
2141
|
-
if (SAFE_FOR_TEMPLATES) {
|
|
2142
|
-
_scrubTemplateExpressions2(dirty);
|
|
2143
|
-
}
|
|
2144
|
-
return dirty;
|
|
2145
|
-
}
|
|
2146
|
-
/* Return sanitized string or DOM */
|
|
2147
|
-
if (RETURN_DOM) {
|
|
2148
|
-
if (SAFE_FOR_TEMPLATES) {
|
|
2149
|
-
_scrubTemplateExpressions2(body);
|
|
2150
|
-
}
|
|
2151
|
-
if (RETURN_DOM_FRAGMENT) {
|
|
2152
|
-
returnNode = createDocumentFragment.call(body.ownerDocument);
|
|
2153
|
-
while (body.firstChild) {
|
|
2154
|
-
// eslint-disable-next-line unicorn/prefer-dom-node-append
|
|
2155
|
-
returnNode.appendChild(body.firstChild);
|
|
2156
|
-
}
|
|
2157
|
-
} else {
|
|
2158
|
-
returnNode = body;
|
|
2159
|
-
}
|
|
2160
|
-
if (ALLOWED_ATTR.shadowroot || ALLOWED_ATTR.shadowrootmode) {
|
|
2161
|
-
/*
|
|
2162
|
-
AdoptNode() is not used because internal state is not reset
|
|
2163
|
-
(e.g. the past names map of a HTMLFormElement), this is safe
|
|
2164
|
-
in theory but we would rather not risk another attack vector.
|
|
2165
|
-
The state that is cloned by importNode() is explicitly defined
|
|
2166
|
-
by the specs.
|
|
2167
|
-
*/
|
|
2168
|
-
returnNode = importNode.call(originalDocument, returnNode, true);
|
|
2169
|
-
}
|
|
2170
|
-
return returnNode;
|
|
2171
|
-
}
|
|
2172
|
-
let serializedHTML = WHOLE_DOCUMENT ? body.outerHTML : body.innerHTML;
|
|
2173
|
-
/* Serialize doctype if allowed */
|
|
2174
|
-
if (WHOLE_DOCUMENT && ALLOWED_TAGS['!doctype'] && body.ownerDocument && body.ownerDocument.doctype && body.ownerDocument.doctype.name && regExpTest(DOCTYPE_NAME, body.ownerDocument.doctype.name)) {
|
|
2175
|
-
serializedHTML = '<!DOCTYPE ' + body.ownerDocument.doctype.name + '>\n' + serializedHTML;
|
|
2176
|
-
}
|
|
2177
|
-
/* Sanitize final string template-safe */
|
|
2178
|
-
if (SAFE_FOR_TEMPLATES) {
|
|
2179
|
-
serializedHTML = _stripTemplateExpressions(serializedHTML);
|
|
2180
|
-
}
|
|
2181
|
-
return trustedTypesPolicy && RETURN_TRUSTED_TYPE ? _createTrustedHTML(serializedHTML) : serializedHTML;
|
|
2182
|
-
};
|
|
2183
|
-
DOMPurify.setConfig = function () {
|
|
2184
|
-
let cfg = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
2185
|
-
_parseConfig(cfg);
|
|
2186
|
-
SET_CONFIG = true;
|
|
2187
|
-
};
|
|
2188
|
-
DOMPurify.clearConfig = function () {
|
|
2189
|
-
CONFIG = null;
|
|
2190
|
-
SET_CONFIG = false;
|
|
2191
|
-
// Drop any caller-supplied Trusted Types policy so it cannot poison later
|
|
2192
|
-
// `RETURN_TRUSTED_TYPE` output. The internal default policy (cached, and
|
|
2193
|
-
// never recreated — Trusted Types throws on duplicate names) is restored by
|
|
2194
|
-
// the next `_parseConfig`. See GHSA-vxr8-fq34-vvx9.
|
|
2195
|
-
trustedTypesPolicy = defaultTrustedTypesPolicy;
|
|
2196
|
-
emptyHTML = '';
|
|
2197
|
-
};
|
|
2198
|
-
DOMPurify.isValidAttribute = function (tag, attr, value) {
|
|
2199
|
-
/* Initialize shared config vars if necessary. */
|
|
2200
|
-
if (!CONFIG) {
|
|
2201
|
-
_parseConfig({});
|
|
2202
|
-
}
|
|
2203
|
-
const lcTag = transformCaseFunc(tag);
|
|
2204
|
-
const lcName = transformCaseFunc(attr);
|
|
2205
|
-
return _isValidAttribute(lcTag, lcName, value);
|
|
2206
|
-
};
|
|
2207
|
-
DOMPurify.addHook = function (entryPoint, hookFunction) {
|
|
2208
|
-
if (typeof hookFunction !== 'function') {
|
|
2209
|
-
return;
|
|
2210
|
-
}
|
|
2211
|
-
arrayPush(hooks[entryPoint], hookFunction);
|
|
2212
|
-
};
|
|
2213
|
-
DOMPurify.removeHook = function (entryPoint, hookFunction) {
|
|
2214
|
-
if (hookFunction !== undefined) {
|
|
2215
|
-
const index = arrayLastIndexOf(hooks[entryPoint], hookFunction);
|
|
2216
|
-
return index === -1 ? undefined : arraySplice(hooks[entryPoint], index, 1)[0];
|
|
2217
|
-
}
|
|
2218
|
-
return arrayPop(hooks[entryPoint]);
|
|
2219
|
-
};
|
|
2220
|
-
DOMPurify.removeHooks = function (entryPoint) {
|
|
2221
|
-
hooks[entryPoint] = [];
|
|
2222
|
-
};
|
|
2223
|
-
DOMPurify.removeAllHooks = function () {
|
|
2224
|
-
hooks = _createHooksMap();
|
|
2225
|
-
};
|
|
2226
|
-
return DOMPurify;
|
|
1061
|
+
let window = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : getGlobal();
|
|
1062
|
+
const DOMPurify = (root) => createDOMPurify(root);
|
|
1063
|
+
DOMPurify.version = "3.4.16";
|
|
1064
|
+
DOMPurify.removed = [];
|
|
1065
|
+
if (!window || !window.document || window.document.nodeType !== NODE_TYPE.document || !window.Element) {
|
|
1066
|
+
DOMPurify.isSupported = false;
|
|
1067
|
+
return DOMPurify;
|
|
1068
|
+
}
|
|
1069
|
+
let document = window.document;
|
|
1070
|
+
const originalDocument = document;
|
|
1071
|
+
const currentScript = originalDocument.currentScript;
|
|
1072
|
+
window.DocumentFragment;
|
|
1073
|
+
const HTMLTemplateElement = window.HTMLTemplateElement, Node = window.Node, Element = window.Element, NodeFilter = window.NodeFilter;
|
|
1074
|
+
window.NamedNodeMap === void 0 && (window.NamedNodeMap || window.MozNamedAttrMap);
|
|
1075
|
+
window.HTMLFormElement;
|
|
1076
|
+
const DOMParser = window.DOMParser, trustedTypes = window.trustedTypes;
|
|
1077
|
+
const ElementPrototype = Element.prototype;
|
|
1078
|
+
const cloneNode = lookupGetter(ElementPrototype, "cloneNode");
|
|
1079
|
+
const remove = lookupGetter(ElementPrototype, "remove");
|
|
1080
|
+
const removeAttributeNode = lookupGetter(ElementPrototype, "removeAttributeNode");
|
|
1081
|
+
const getNextSibling = lookupGetter(ElementPrototype, "nextSibling");
|
|
1082
|
+
const getChildNodes = lookupGetter(ElementPrototype, "childNodes");
|
|
1083
|
+
const getParentNode = lookupGetter(ElementPrototype, "parentNode");
|
|
1084
|
+
const getShadowRoot = lookupGetter(ElementPrototype, "shadowRoot");
|
|
1085
|
+
const getAttributes = lookupGetter(ElementPrototype, "attributes");
|
|
1086
|
+
const getNodeType = Node && Node.prototype ? lookupGetter(Node.prototype, "nodeType") : null;
|
|
1087
|
+
const getNodeName = Node && Node.prototype ? lookupGetter(Node.prototype, "nodeName") : null;
|
|
1088
|
+
const getOwnerDocument = Node && Node.prototype ? lookupGetter(Node.prototype, "ownerDocument") : null;
|
|
1089
|
+
const _readNodeType = function _readNodeType(node) {
|
|
1090
|
+
return getNodeType ? getNodeType(node) : node.nodeType;
|
|
1091
|
+
};
|
|
1092
|
+
const _readNodeName = function _readNodeName(node) {
|
|
1093
|
+
return getNodeName ? getNodeName(node) : node.nodeName;
|
|
1094
|
+
};
|
|
1095
|
+
if (typeof HTMLTemplateElement === "function") {
|
|
1096
|
+
const template = document.createElement("template");
|
|
1097
|
+
if (template.content && template.content.ownerDocument) document = template.content.ownerDocument;
|
|
1098
|
+
}
|
|
1099
|
+
let trustedTypesPolicy;
|
|
1100
|
+
let emptyHTML = "";
|
|
1101
|
+
let defaultTrustedTypesPolicy;
|
|
1102
|
+
let defaultTrustedTypesPolicyResolved = false;
|
|
1103
|
+
let IN_TRUSTED_TYPES_POLICY = 0;
|
|
1104
|
+
const _assertNotInTrustedTypesPolicy = function _assertNotInTrustedTypesPolicy() {
|
|
1105
|
+
if (IN_TRUSTED_TYPES_POLICY > 0) throw typeErrorCreate("A configured TRUSTED_TYPES_POLICY callback (createHTML or createScriptURL) must not call DOMPurify.sanitize, as that causes infinite recursion. Do not pass a policy whose callbacks wrap DOMPurify as TRUSTED_TYPES_POLICY; see the \"DOMPurify and Trusted Types\" section of the README.");
|
|
1106
|
+
};
|
|
1107
|
+
const _createTrustedHTML = function _createTrustedHTML(html) {
|
|
1108
|
+
_assertNotInTrustedTypesPolicy();
|
|
1109
|
+
IN_TRUSTED_TYPES_POLICY++;
|
|
1110
|
+
try {
|
|
1111
|
+
return trustedTypesPolicy.createHTML(html);
|
|
1112
|
+
} finally {
|
|
1113
|
+
IN_TRUSTED_TYPES_POLICY--;
|
|
1114
|
+
}
|
|
1115
|
+
};
|
|
1116
|
+
const _createTrustedScriptURL = function _createTrustedScriptURL(scriptUrl) {
|
|
1117
|
+
_assertNotInTrustedTypesPolicy();
|
|
1118
|
+
IN_TRUSTED_TYPES_POLICY++;
|
|
1119
|
+
try {
|
|
1120
|
+
return trustedTypesPolicy.createScriptURL(scriptUrl);
|
|
1121
|
+
} finally {
|
|
1122
|
+
IN_TRUSTED_TYPES_POLICY--;
|
|
1123
|
+
}
|
|
1124
|
+
};
|
|
1125
|
+
const _getDefaultTrustedTypesPolicy = function _getDefaultTrustedTypesPolicy() {
|
|
1126
|
+
if (!defaultTrustedTypesPolicyResolved) {
|
|
1127
|
+
defaultTrustedTypesPolicy = _createTrustedTypesPolicy(trustedTypes, currentScript);
|
|
1128
|
+
defaultTrustedTypesPolicyResolved = true;
|
|
1129
|
+
}
|
|
1130
|
+
return defaultTrustedTypesPolicy;
|
|
1131
|
+
};
|
|
1132
|
+
const _document = document, implementation = _document.implementation, createNodeIterator = _document.createNodeIterator, createDocumentFragment = _document.createDocumentFragment, getElementsByTagName = _document.getElementsByTagName;
|
|
1133
|
+
const importNode = originalDocument.importNode;
|
|
1134
|
+
let hooks = _createHooksMap();
|
|
1135
|
+
/**
|
|
1136
|
+
* Expose whether this browser supports running the full DOMPurify.
|
|
1137
|
+
*/
|
|
1138
|
+
DOMPurify.isSupported = typeof entries === "function" && typeof getParentNode === "function" && implementation && implementation.createHTMLDocument !== void 0;
|
|
1139
|
+
const 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;
|
|
1140
|
+
let IS_ALLOWED_URI$1 = IS_ALLOWED_URI;
|
|
1141
|
+
/**
|
|
1142
|
+
* We consider the elements and attributes below to be safe. Ideally
|
|
1143
|
+
* don't add any new ones but feel free to remove unwanted ones.
|
|
1144
|
+
*/
|
|
1145
|
+
let ALLOWED_TAGS = null;
|
|
1146
|
+
const DEFAULT_ALLOWED_TAGS = addToSet({}, [
|
|
1147
|
+
...html$1,
|
|
1148
|
+
...svg$1,
|
|
1149
|
+
...svgFilters,
|
|
1150
|
+
...mathMl$1,
|
|
1151
|
+
...text
|
|
1152
|
+
]);
|
|
1153
|
+
let ALLOWED_ATTR = null;
|
|
1154
|
+
const DEFAULT_ALLOWED_ATTR = addToSet({}, [
|
|
1155
|
+
...html,
|
|
1156
|
+
...svg,
|
|
1157
|
+
...mathMl,
|
|
1158
|
+
...xml
|
|
1159
|
+
]);
|
|
1160
|
+
let CUSTOM_ELEMENT_HANDLING = Object.seal(create(null, {
|
|
1161
|
+
tagNameCheck: {
|
|
1162
|
+
writable: true,
|
|
1163
|
+
configurable: false,
|
|
1164
|
+
enumerable: true,
|
|
1165
|
+
value: null
|
|
1166
|
+
},
|
|
1167
|
+
attributeNameCheck: {
|
|
1168
|
+
writable: true,
|
|
1169
|
+
configurable: false,
|
|
1170
|
+
enumerable: true,
|
|
1171
|
+
value: null
|
|
1172
|
+
},
|
|
1173
|
+
allowCustomizedBuiltInElements: {
|
|
1174
|
+
writable: true,
|
|
1175
|
+
configurable: false,
|
|
1176
|
+
enumerable: true,
|
|
1177
|
+
value: false
|
|
1178
|
+
}
|
|
1179
|
+
}));
|
|
1180
|
+
let FORBID_TAGS = null;
|
|
1181
|
+
let FORBID_ATTR = null;
|
|
1182
|
+
const EXTRA_ELEMENT_HANDLING = Object.seal(create(null, {
|
|
1183
|
+
tagCheck: {
|
|
1184
|
+
writable: true,
|
|
1185
|
+
configurable: false,
|
|
1186
|
+
enumerable: true,
|
|
1187
|
+
value: null
|
|
1188
|
+
},
|
|
1189
|
+
attributeCheck: {
|
|
1190
|
+
writable: true,
|
|
1191
|
+
configurable: false,
|
|
1192
|
+
enumerable: true,
|
|
1193
|
+
value: null
|
|
1194
|
+
}
|
|
1195
|
+
}));
|
|
1196
|
+
let ALLOW_ARIA_ATTR = true;
|
|
1197
|
+
let ALLOW_DATA_ATTR = true;
|
|
1198
|
+
let ALLOW_UNKNOWN_PROTOCOLS = false;
|
|
1199
|
+
let ALLOW_SELF_CLOSE_IN_ATTR = true;
|
|
1200
|
+
let SAFE_FOR_TEMPLATES = false;
|
|
1201
|
+
let SAFE_FOR_XML = true;
|
|
1202
|
+
let WHOLE_DOCUMENT = false;
|
|
1203
|
+
let SET_CONFIG = false;
|
|
1204
|
+
let SET_CONFIG_ALLOWED_TAGS = null;
|
|
1205
|
+
let SET_CONFIG_ALLOWED_ATTR = null;
|
|
1206
|
+
let FORCE_BODY = false;
|
|
1207
|
+
let RETURN_DOM = false;
|
|
1208
|
+
let RETURN_DOM_FRAGMENT = false;
|
|
1209
|
+
let RETURN_TRUSTED_TYPE = false;
|
|
1210
|
+
let SANITIZE_DOM = true;
|
|
1211
|
+
let SANITIZE_NAMED_PROPS = false;
|
|
1212
|
+
const SANITIZE_NAMED_PROPS_PREFIX = "user-content-";
|
|
1213
|
+
let KEEP_CONTENT = true;
|
|
1214
|
+
let IN_PLACE = false;
|
|
1215
|
+
let USE_PROFILES = {};
|
|
1216
|
+
let FORBID_CONTENTS = null;
|
|
1217
|
+
const DEFAULT_FORBID_CONTENTS = addToSet({}, [
|
|
1218
|
+
"annotation-xml",
|
|
1219
|
+
"audio",
|
|
1220
|
+
"colgroup",
|
|
1221
|
+
"desc",
|
|
1222
|
+
"foreignobject",
|
|
1223
|
+
"head",
|
|
1224
|
+
"iframe",
|
|
1225
|
+
"math",
|
|
1226
|
+
"mi",
|
|
1227
|
+
"mn",
|
|
1228
|
+
"mo",
|
|
1229
|
+
"ms",
|
|
1230
|
+
"mtext",
|
|
1231
|
+
"noembed",
|
|
1232
|
+
"noframes",
|
|
1233
|
+
"noscript",
|
|
1234
|
+
"plaintext",
|
|
1235
|
+
"script",
|
|
1236
|
+
"selectedcontent",
|
|
1237
|
+
"style",
|
|
1238
|
+
"svg",
|
|
1239
|
+
"template",
|
|
1240
|
+
"thead",
|
|
1241
|
+
"title",
|
|
1242
|
+
"video",
|
|
1243
|
+
"xmp"
|
|
1244
|
+
]);
|
|
1245
|
+
let DATA_URI_TAGS = null;
|
|
1246
|
+
const DEFAULT_DATA_URI_TAGS = addToSet({}, [
|
|
1247
|
+
"audio",
|
|
1248
|
+
"video",
|
|
1249
|
+
"img",
|
|
1250
|
+
"source",
|
|
1251
|
+
"image",
|
|
1252
|
+
"track"
|
|
1253
|
+
]);
|
|
1254
|
+
let URI_SAFE_ATTRIBUTES = null;
|
|
1255
|
+
const DEFAULT_URI_SAFE_ATTRIBUTES = addToSet({}, [
|
|
1256
|
+
"alt",
|
|
1257
|
+
"class",
|
|
1258
|
+
"for",
|
|
1259
|
+
"id",
|
|
1260
|
+
"label",
|
|
1261
|
+
"name",
|
|
1262
|
+
"pattern",
|
|
1263
|
+
"placeholder",
|
|
1264
|
+
"role",
|
|
1265
|
+
"summary",
|
|
1266
|
+
"title",
|
|
1267
|
+
"value",
|
|
1268
|
+
"style",
|
|
1269
|
+
"xmlns"
|
|
1270
|
+
]);
|
|
1271
|
+
const MATHML_NAMESPACE = "http://www.w3.org/1998/Math/MathML";
|
|
1272
|
+
const SVG_NAMESPACE = "http://www.w3.org/2000/svg";
|
|
1273
|
+
const HTML_NAMESPACE = "http://www.w3.org/1999/xhtml";
|
|
1274
|
+
let NAMESPACE = HTML_NAMESPACE;
|
|
1275
|
+
let IS_EMPTY_INPUT = false;
|
|
1276
|
+
let ALLOWED_NAMESPACES = null;
|
|
1277
|
+
const DEFAULT_ALLOWED_NAMESPACES = addToSet({}, [
|
|
1278
|
+
MATHML_NAMESPACE,
|
|
1279
|
+
SVG_NAMESPACE,
|
|
1280
|
+
HTML_NAMESPACE
|
|
1281
|
+
], stringToString);
|
|
1282
|
+
const DEFAULT_MATHML_TEXT_INTEGRATION_POINTS = freeze([
|
|
1283
|
+
"mi",
|
|
1284
|
+
"mo",
|
|
1285
|
+
"mn",
|
|
1286
|
+
"ms",
|
|
1287
|
+
"mtext"
|
|
1288
|
+
]);
|
|
1289
|
+
let MATHML_TEXT_INTEGRATION_POINTS = addToSet({}, DEFAULT_MATHML_TEXT_INTEGRATION_POINTS);
|
|
1290
|
+
const DEFAULT_HTML_INTEGRATION_POINTS = freeze(["annotation-xml"]);
|
|
1291
|
+
let HTML_INTEGRATION_POINTS = addToSet({}, DEFAULT_HTML_INTEGRATION_POINTS);
|
|
1292
|
+
const COMMON_SVG_AND_HTML_ELEMENTS = addToSet({}, [
|
|
1293
|
+
"title",
|
|
1294
|
+
"style",
|
|
1295
|
+
"font",
|
|
1296
|
+
"a",
|
|
1297
|
+
"script"
|
|
1298
|
+
]);
|
|
1299
|
+
let PARSER_MEDIA_TYPE = null;
|
|
1300
|
+
const SUPPORTED_PARSER_MEDIA_TYPES = ["application/xhtml+xml", "text/html"];
|
|
1301
|
+
const DEFAULT_PARSER_MEDIA_TYPE = "text/html";
|
|
1302
|
+
let transformCaseFunc = null;
|
|
1303
|
+
let CONFIG = null;
|
|
1304
|
+
const formElement = document.createElement("form");
|
|
1305
|
+
const isRegexOrFunction = function isRegexOrFunction(testValue) {
|
|
1306
|
+
return testValue instanceof RegExp || testValue instanceof Function;
|
|
1307
|
+
};
|
|
1308
|
+
/**
|
|
1309
|
+
* _parseConfig
|
|
1310
|
+
*
|
|
1311
|
+
* @param cfg optional config literal
|
|
1312
|
+
*/
|
|
1313
|
+
const _parseConfig = function _parseConfig() {
|
|
1314
|
+
let cfg = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
|
1315
|
+
if (CONFIG && CONFIG === cfg) return;
|
|
1316
|
+
if (!cfg || typeof cfg !== "object") cfg = {};
|
|
1317
|
+
cfg = clone(cfg);
|
|
1318
|
+
PARSER_MEDIA_TYPE = SUPPORTED_PARSER_MEDIA_TYPES.indexOf(cfg.PARSER_MEDIA_TYPE) === -1 ? DEFAULT_PARSER_MEDIA_TYPE : cfg.PARSER_MEDIA_TYPE;
|
|
1319
|
+
transformCaseFunc = PARSER_MEDIA_TYPE === "application/xhtml+xml" ? stringToString : stringToLowerCase;
|
|
1320
|
+
ALLOWED_TAGS = _resolveSetOption(cfg, "ALLOWED_TAGS", DEFAULT_ALLOWED_TAGS, { transform: transformCaseFunc });
|
|
1321
|
+
ALLOWED_ATTR = _resolveSetOption(cfg, "ALLOWED_ATTR", DEFAULT_ALLOWED_ATTR, { transform: transformCaseFunc });
|
|
1322
|
+
ALLOWED_NAMESPACES = _resolveSetOption(cfg, "ALLOWED_NAMESPACES", DEFAULT_ALLOWED_NAMESPACES, { transform: stringToString });
|
|
1323
|
+
URI_SAFE_ATTRIBUTES = _resolveSetOption(cfg, "ADD_URI_SAFE_ATTR", DEFAULT_URI_SAFE_ATTRIBUTES, {
|
|
1324
|
+
transform: transformCaseFunc,
|
|
1325
|
+
base: DEFAULT_URI_SAFE_ATTRIBUTES
|
|
1326
|
+
});
|
|
1327
|
+
DATA_URI_TAGS = _resolveSetOption(cfg, "ADD_DATA_URI_TAGS", DEFAULT_DATA_URI_TAGS, {
|
|
1328
|
+
transform: transformCaseFunc,
|
|
1329
|
+
base: DEFAULT_DATA_URI_TAGS
|
|
1330
|
+
});
|
|
1331
|
+
FORBID_CONTENTS = _resolveSetOption(cfg, "FORBID_CONTENTS", DEFAULT_FORBID_CONTENTS, { transform: transformCaseFunc });
|
|
1332
|
+
FORBID_TAGS = _resolveSetOption(cfg, "FORBID_TAGS", clone({}), { transform: transformCaseFunc });
|
|
1333
|
+
FORBID_ATTR = _resolveSetOption(cfg, "FORBID_ATTR", clone({}), { transform: transformCaseFunc });
|
|
1334
|
+
USE_PROFILES = objectHasOwnProperty(cfg, "USE_PROFILES") ? cfg.USE_PROFILES && typeof cfg.USE_PROFILES === "object" ? clone(cfg.USE_PROFILES) : cfg.USE_PROFILES : false;
|
|
1335
|
+
ALLOW_ARIA_ATTR = cfg.ALLOW_ARIA_ATTR !== false;
|
|
1336
|
+
ALLOW_DATA_ATTR = cfg.ALLOW_DATA_ATTR !== false;
|
|
1337
|
+
ALLOW_UNKNOWN_PROTOCOLS = cfg.ALLOW_UNKNOWN_PROTOCOLS || false;
|
|
1338
|
+
ALLOW_SELF_CLOSE_IN_ATTR = cfg.ALLOW_SELF_CLOSE_IN_ATTR !== false;
|
|
1339
|
+
SAFE_FOR_TEMPLATES = cfg.SAFE_FOR_TEMPLATES || false;
|
|
1340
|
+
SAFE_FOR_XML = cfg.SAFE_FOR_XML !== false;
|
|
1341
|
+
WHOLE_DOCUMENT = cfg.WHOLE_DOCUMENT || false;
|
|
1342
|
+
RETURN_DOM = cfg.RETURN_DOM || false;
|
|
1343
|
+
RETURN_DOM_FRAGMENT = cfg.RETURN_DOM_FRAGMENT || false;
|
|
1344
|
+
RETURN_TRUSTED_TYPE = cfg.RETURN_TRUSTED_TYPE || false;
|
|
1345
|
+
FORCE_BODY = cfg.FORCE_BODY || false;
|
|
1346
|
+
SANITIZE_DOM = cfg.SANITIZE_DOM !== false;
|
|
1347
|
+
SANITIZE_NAMED_PROPS = cfg.SANITIZE_NAMED_PROPS || false;
|
|
1348
|
+
KEEP_CONTENT = cfg.KEEP_CONTENT !== false;
|
|
1349
|
+
IN_PLACE = cfg.IN_PLACE || false;
|
|
1350
|
+
IS_ALLOWED_URI$1 = isRegex(cfg.ALLOWED_URI_REGEXP) ? cfg.ALLOWED_URI_REGEXP : IS_ALLOWED_URI;
|
|
1351
|
+
NAMESPACE = typeof cfg.NAMESPACE === "string" ? cfg.NAMESPACE : HTML_NAMESPACE;
|
|
1352
|
+
MATHML_TEXT_INTEGRATION_POINTS = _resolveObjectOption(cfg, "MATHML_TEXT_INTEGRATION_POINTS", () => addToSet({}, DEFAULT_MATHML_TEXT_INTEGRATION_POINTS));
|
|
1353
|
+
HTML_INTEGRATION_POINTS = _resolveObjectOption(cfg, "HTML_INTEGRATION_POINTS", () => addToSet({}, DEFAULT_HTML_INTEGRATION_POINTS));
|
|
1354
|
+
const customElementHandling = _resolveObjectOption(cfg, "CUSTOM_ELEMENT_HANDLING", () => create(null));
|
|
1355
|
+
CUSTOM_ELEMENT_HANDLING = create(null);
|
|
1356
|
+
if (objectHasOwnProperty(customElementHandling, "tagNameCheck") && isRegexOrFunction(customElementHandling.tagNameCheck)) CUSTOM_ELEMENT_HANDLING.tagNameCheck = customElementHandling.tagNameCheck;
|
|
1357
|
+
if (objectHasOwnProperty(customElementHandling, "attributeNameCheck") && isRegexOrFunction(customElementHandling.attributeNameCheck)) CUSTOM_ELEMENT_HANDLING.attributeNameCheck = customElementHandling.attributeNameCheck;
|
|
1358
|
+
if (objectHasOwnProperty(customElementHandling, "allowCustomizedBuiltInElements") && typeof customElementHandling.allowCustomizedBuiltInElements === "boolean") CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements = customElementHandling.allowCustomizedBuiltInElements;
|
|
1359
|
+
seal(CUSTOM_ELEMENT_HANDLING);
|
|
1360
|
+
if (SAFE_FOR_TEMPLATES) ALLOW_DATA_ATTR = false;
|
|
1361
|
+
if (RETURN_DOM_FRAGMENT) RETURN_DOM = true;
|
|
1362
|
+
if (USE_PROFILES) {
|
|
1363
|
+
ALLOWED_TAGS = addToSet({}, text);
|
|
1364
|
+
ALLOWED_ATTR = create(null);
|
|
1365
|
+
if (USE_PROFILES.html === true) {
|
|
1366
|
+
addToSet(ALLOWED_TAGS, html$1);
|
|
1367
|
+
addToSet(ALLOWED_ATTR, html);
|
|
1368
|
+
}
|
|
1369
|
+
if (USE_PROFILES.svg === true) {
|
|
1370
|
+
addToSet(ALLOWED_TAGS, svg$1);
|
|
1371
|
+
addToSet(ALLOWED_ATTR, svg);
|
|
1372
|
+
addToSet(ALLOWED_ATTR, xml);
|
|
1373
|
+
}
|
|
1374
|
+
if (USE_PROFILES.svgFilters === true) {
|
|
1375
|
+
addToSet(ALLOWED_TAGS, svgFilters);
|
|
1376
|
+
addToSet(ALLOWED_ATTR, svg);
|
|
1377
|
+
addToSet(ALLOWED_ATTR, xml);
|
|
1378
|
+
}
|
|
1379
|
+
if (USE_PROFILES.mathMl === true) {
|
|
1380
|
+
addToSet(ALLOWED_TAGS, mathMl$1);
|
|
1381
|
+
addToSet(ALLOWED_ATTR, mathMl);
|
|
1382
|
+
addToSet(ALLOWED_ATTR, xml);
|
|
1383
|
+
}
|
|
1384
|
+
}
|
|
1385
|
+
EXTRA_ELEMENT_HANDLING.tagCheck = null;
|
|
1386
|
+
EXTRA_ELEMENT_HANDLING.attributeCheck = null;
|
|
1387
|
+
if (objectHasOwnProperty(cfg, "ADD_TAGS")) {
|
|
1388
|
+
if (typeof cfg.ADD_TAGS === "function") EXTRA_ELEMENT_HANDLING.tagCheck = cfg.ADD_TAGS;
|
|
1389
|
+
else if (arrayIsArray(cfg.ADD_TAGS)) {
|
|
1390
|
+
if (ALLOWED_TAGS === DEFAULT_ALLOWED_TAGS) ALLOWED_TAGS = clone(ALLOWED_TAGS);
|
|
1391
|
+
addToSet(ALLOWED_TAGS, cfg.ADD_TAGS, transformCaseFunc);
|
|
1392
|
+
}
|
|
1393
|
+
}
|
|
1394
|
+
if (objectHasOwnProperty(cfg, "ADD_ATTR")) {
|
|
1395
|
+
if (typeof cfg.ADD_ATTR === "function") EXTRA_ELEMENT_HANDLING.attributeCheck = cfg.ADD_ATTR;
|
|
1396
|
+
else if (arrayIsArray(cfg.ADD_ATTR)) {
|
|
1397
|
+
if (ALLOWED_ATTR === DEFAULT_ALLOWED_ATTR) ALLOWED_ATTR = clone(ALLOWED_ATTR);
|
|
1398
|
+
addToSet(ALLOWED_ATTR, cfg.ADD_ATTR, transformCaseFunc);
|
|
1399
|
+
}
|
|
1400
|
+
}
|
|
1401
|
+
if (objectHasOwnProperty(cfg, "ADD_FORBID_CONTENTS") && arrayIsArray(cfg.ADD_FORBID_CONTENTS)) {
|
|
1402
|
+
if (FORBID_CONTENTS === DEFAULT_FORBID_CONTENTS) FORBID_CONTENTS = clone(FORBID_CONTENTS);
|
|
1403
|
+
addToSet(FORBID_CONTENTS, cfg.ADD_FORBID_CONTENTS, transformCaseFunc);
|
|
1404
|
+
}
|
|
1405
|
+
if (KEEP_CONTENT) ALLOWED_TAGS["#text"] = true;
|
|
1406
|
+
if (WHOLE_DOCUMENT) addToSet(ALLOWED_TAGS, [
|
|
1407
|
+
"html",
|
|
1408
|
+
"head",
|
|
1409
|
+
"body"
|
|
1410
|
+
]);
|
|
1411
|
+
if (ALLOWED_TAGS.table) {
|
|
1412
|
+
addToSet(ALLOWED_TAGS, ["tbody"]);
|
|
1413
|
+
delete FORBID_TAGS.tbody;
|
|
1414
|
+
}
|
|
1415
|
+
if (cfg.TRUSTED_TYPES_POLICY) {
|
|
1416
|
+
if (typeof cfg.TRUSTED_TYPES_POLICY.createHTML !== "function") throw typeErrorCreate("TRUSTED_TYPES_POLICY configuration option must provide a \"createHTML\" hook.");
|
|
1417
|
+
if (typeof cfg.TRUSTED_TYPES_POLICY.createScriptURL !== "function") throw typeErrorCreate("TRUSTED_TYPES_POLICY configuration option must provide a \"createScriptURL\" hook.");
|
|
1418
|
+
const previousTrustedTypesPolicy = trustedTypesPolicy;
|
|
1419
|
+
trustedTypesPolicy = cfg.TRUSTED_TYPES_POLICY;
|
|
1420
|
+
try {
|
|
1421
|
+
emptyHTML = _createTrustedHTML("");
|
|
1422
|
+
} catch (error) {
|
|
1423
|
+
trustedTypesPolicy = previousTrustedTypesPolicy;
|
|
1424
|
+
throw error;
|
|
1425
|
+
}
|
|
1426
|
+
} else if (cfg.TRUSTED_TYPES_POLICY === null) {
|
|
1427
|
+
trustedTypesPolicy = void 0;
|
|
1428
|
+
emptyHTML = "";
|
|
1429
|
+
} else {
|
|
1430
|
+
if (trustedTypesPolicy === void 0) trustedTypesPolicy = _getDefaultTrustedTypesPolicy();
|
|
1431
|
+
if (trustedTypesPolicy && typeof emptyHTML === "string") emptyHTML = _createTrustedHTML("");
|
|
1432
|
+
}
|
|
1433
|
+
if (freeze) freeze(cfg);
|
|
1434
|
+
CONFIG = cfg;
|
|
1435
|
+
};
|
|
1436
|
+
const ALL_SVG_TAGS = addToSet({}, [
|
|
1437
|
+
...svg$1,
|
|
1438
|
+
...svgFilters,
|
|
1439
|
+
...svgDisallowed
|
|
1440
|
+
]);
|
|
1441
|
+
const ALL_MATHML_TAGS = addToSet({}, [...mathMl$1, ...mathMlDisallowed]);
|
|
1442
|
+
/**
|
|
1443
|
+
* Namespace rules for an element in the SVG namespace.
|
|
1444
|
+
*
|
|
1445
|
+
* @param tagName the element's lowercase tag name
|
|
1446
|
+
* @param parent the (possibly simulated) parent node
|
|
1447
|
+
* @param parentTagName the parent's lowercase tag name
|
|
1448
|
+
* @returns true if a spec-compliant parser could produce this element
|
|
1449
|
+
*/
|
|
1450
|
+
const _checkSvgNamespace = function _checkSvgNamespace(tagName, parent, parentTagName) {
|
|
1451
|
+
if (parent.namespaceURI === HTML_NAMESPACE) return tagName === "svg";
|
|
1452
|
+
if (parent.namespaceURI === MATHML_NAMESPACE) return tagName === "svg" && (parentTagName === "annotation-xml" || MATHML_TEXT_INTEGRATION_POINTS[parentTagName]);
|
|
1453
|
+
return Boolean(ALL_SVG_TAGS[tagName]);
|
|
1454
|
+
};
|
|
1455
|
+
/**
|
|
1456
|
+
* Namespace rules for an element in the MathML namespace.
|
|
1457
|
+
*
|
|
1458
|
+
* @param tagName the element's lowercase tag name
|
|
1459
|
+
* @param parent the (possibly simulated) parent node
|
|
1460
|
+
* @param parentTagName the parent's lowercase tag name
|
|
1461
|
+
* @returns true if a spec-compliant parser could produce this element
|
|
1462
|
+
*/
|
|
1463
|
+
const _checkMathMlNamespace = function _checkMathMlNamespace(tagName, parent, parentTagName) {
|
|
1464
|
+
if (parent.namespaceURI === HTML_NAMESPACE) return tagName === "math";
|
|
1465
|
+
if (parent.namespaceURI === SVG_NAMESPACE) return tagName === "math" && HTML_INTEGRATION_POINTS[parentTagName];
|
|
1466
|
+
return Boolean(ALL_MATHML_TAGS[tagName]);
|
|
1467
|
+
};
|
|
1468
|
+
/**
|
|
1469
|
+
* Namespace rules for an element in the HTML namespace.
|
|
1470
|
+
*
|
|
1471
|
+
* @param tagName the element's lowercase tag name
|
|
1472
|
+
* @param parent the (possibly simulated) parent node
|
|
1473
|
+
* @param parentTagName the parent's lowercase tag name
|
|
1474
|
+
* @returns true if a spec-compliant parser could produce this element
|
|
1475
|
+
*/
|
|
1476
|
+
const _checkHtmlNamespace = function _checkHtmlNamespace(tagName, parent, parentTagName) {
|
|
1477
|
+
if (parent.namespaceURI === SVG_NAMESPACE && !HTML_INTEGRATION_POINTS[parentTagName]) return false;
|
|
1478
|
+
if (parent.namespaceURI === MATHML_NAMESPACE && !MATHML_TEXT_INTEGRATION_POINTS[parentTagName]) return false;
|
|
1479
|
+
return !ALL_MATHML_TAGS[tagName] && (COMMON_SVG_AND_HTML_ELEMENTS[tagName] || !ALL_SVG_TAGS[tagName]);
|
|
1480
|
+
};
|
|
1481
|
+
/**
|
|
1482
|
+
* @param element a DOM element whose namespace is being checked
|
|
1483
|
+
* @returns Return false if the element has a
|
|
1484
|
+
* namespace that a spec-compliant parser would never
|
|
1485
|
+
* return. Return true otherwise.
|
|
1486
|
+
*/
|
|
1487
|
+
const _checkValidNamespace = function _checkValidNamespace(element) {
|
|
1488
|
+
let parent = getParentNode(element);
|
|
1489
|
+
if (!parent || !parent.tagName) parent = {
|
|
1490
|
+
namespaceURI: NAMESPACE,
|
|
1491
|
+
tagName: "template"
|
|
1492
|
+
};
|
|
1493
|
+
const tagName = stringToLowerCase(element.tagName);
|
|
1494
|
+
const parentTagName = stringToLowerCase(parent.tagName);
|
|
1495
|
+
if (!ALLOWED_NAMESPACES[element.namespaceURI]) return false;
|
|
1496
|
+
if (element.namespaceURI === SVG_NAMESPACE) return _checkSvgNamespace(tagName, parent, parentTagName);
|
|
1497
|
+
if (element.namespaceURI === MATHML_NAMESPACE) return _checkMathMlNamespace(tagName, parent, parentTagName);
|
|
1498
|
+
if (element.namespaceURI === HTML_NAMESPACE) return _checkHtmlNamespace(tagName, parent, parentTagName);
|
|
1499
|
+
if (PARSER_MEDIA_TYPE === "application/xhtml+xml" && ALLOWED_NAMESPACES[element.namespaceURI]) return true;
|
|
1500
|
+
return false;
|
|
1501
|
+
};
|
|
1502
|
+
/**
|
|
1503
|
+
* _forceRemove
|
|
1504
|
+
*
|
|
1505
|
+
* @param node a DOM node
|
|
1506
|
+
*/
|
|
1507
|
+
const _forceRemove = function _forceRemove(node) {
|
|
1508
|
+
arrayPush(DOMPurify.removed, { element: node });
|
|
1509
|
+
try {
|
|
1510
|
+
getParentNode(node).removeChild(node);
|
|
1511
|
+
} catch (_) {
|
|
1512
|
+
remove(node);
|
|
1513
|
+
if (!getParentNode(node)) throw typeErrorCreate("a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place");
|
|
1514
|
+
}
|
|
1515
|
+
};
|
|
1516
|
+
/**
|
|
1517
|
+
* _stripAttributeNode
|
|
1518
|
+
*
|
|
1519
|
+
* Remove a single Attr node case/namespace-exactly on an attribute-teardown
|
|
1520
|
+
* path. Name-based removeAttribute() ASCII-lowercases its lookup key for an
|
|
1521
|
+
* HTML element in an HTML document and so silently misses a case-preserved
|
|
1522
|
+
* handler (e.g. `ONERROR` off an XML/XHTML import) - the same defect
|
|
1523
|
+
* _removeAttribute() was fixed for, which a name-based call would reintroduce
|
|
1524
|
+
* on these IN_PLACE teardown paths. Unlike _removeAttribute this does not
|
|
1525
|
+
* record into DOMPurify.removed: the neutralize passes intentionally do not
|
|
1526
|
+
* book-keep. A clobbered/detached node falls back to best-effort name-based
|
|
1527
|
+
* removal.
|
|
1528
|
+
*
|
|
1529
|
+
* @param element the element to strip the attribute from
|
|
1530
|
+
* @param attribute the Attr node to remove
|
|
1531
|
+
* @param name the attribute's name, for the fallback path
|
|
1532
|
+
*/
|
|
1533
|
+
const _stripAttributeNode = function _stripAttributeNode(element, attribute, name) {
|
|
1534
|
+
try {
|
|
1535
|
+
removeAttributeNode(element, attribute);
|
|
1536
|
+
} catch (_) {
|
|
1537
|
+
try {
|
|
1538
|
+
element.removeAttribute(name);
|
|
1539
|
+
} catch (_) {}
|
|
1540
|
+
}
|
|
1541
|
+
};
|
|
1542
|
+
/**
|
|
1543
|
+
* _neutralizeRoot
|
|
1544
|
+
*
|
|
1545
|
+
* Fail-closed teardown of an in-place root after the sanitize walk aborts
|
|
1546
|
+
* (campaign-3 F2). An internal throw mid-walk — e.g. a page-registered
|
|
1547
|
+
* custom element's reaction detaches a node so `_forceRemove`'s deliberate
|
|
1548
|
+
* parentless guard throws, or any other re-entrant engine mutation — would
|
|
1549
|
+
* otherwise leave the caller's *live* tree half-sanitized, with everything
|
|
1550
|
+
* after the abort point still carrying its handlers. There is no safe way
|
|
1551
|
+
* to resume the walk (the tree mutated under us), so we strip the root bare:
|
|
1552
|
+
* remove every child and every attribute, then let the caller's catch see
|
|
1553
|
+
* the original error. Clobber-safe (cached `remove`/`childNodes`/`attributes`
|
|
1554
|
+
* getters; the root was already clobber-pre-flighted at the IN_PLACE entry).
|
|
1555
|
+
*
|
|
1556
|
+
* @param root the in-place root to empty
|
|
1557
|
+
*/
|
|
1558
|
+
const _neutralizeRoot = function _neutralizeRoot(root) {
|
|
1559
|
+
_neutralizeSubtree(root);
|
|
1560
|
+
const childNodes = getChildNodes(root);
|
|
1561
|
+
if (childNodes) {
|
|
1562
|
+
const snapshot = [];
|
|
1563
|
+
arrayForEach(childNodes, (child) => {
|
|
1564
|
+
arrayPush(snapshot, child);
|
|
1565
|
+
});
|
|
1566
|
+
arrayForEach(snapshot, (child) => {
|
|
1567
|
+
try {
|
|
1568
|
+
remove(child);
|
|
1569
|
+
} catch (_) {}
|
|
1570
|
+
});
|
|
1571
|
+
}
|
|
1572
|
+
const attributes = getAttributes(root);
|
|
1573
|
+
if (attributes) for (let i = attributes.length - 1; i >= 0; --i) {
|
|
1574
|
+
const attribute = attributes[i];
|
|
1575
|
+
const name = attribute && attribute.name;
|
|
1576
|
+
if (typeof name === "string") _stripAttributeNode(root, attribute, name);
|
|
1577
|
+
}
|
|
1578
|
+
};
|
|
1579
|
+
/**
|
|
1580
|
+
* _removeAttribute
|
|
1581
|
+
*
|
|
1582
|
+
* Name-based getAttributeNode()/removeAttribute() ASCII-lowercase their
|
|
1583
|
+
* lookup key for HTML elements in an HTML document, so they silently miss an
|
|
1584
|
+
* attribute whose stored qualified name still contains uppercase ASCII
|
|
1585
|
+
* letters. That happens when the node came from a case-preserving source
|
|
1586
|
+
* (an XML/XHTML document imported via importNode(), or createAttributeNS()),
|
|
1587
|
+
* where e.g. `ONERROR` survives the walk: the policy check lowercases to
|
|
1588
|
+
* `onerror` and rejects it, but `removeAttribute('ONERROR')` looks up
|
|
1589
|
+
* `onerror` and finds nothing. Remove the exact Attr node instead, which is
|
|
1590
|
+
* case- and namespace-exact, and fall back to name-based removal only when
|
|
1591
|
+
* the caller could not supply the node.
|
|
1592
|
+
*
|
|
1593
|
+
* @param name an Attribute name
|
|
1594
|
+
* @param element a DOM node
|
|
1595
|
+
* @param attr the exact Attr node to remove, when the caller has it
|
|
1596
|
+
*/
|
|
1597
|
+
const _removeAttribute = function _removeAttribute(name, element, attr) {
|
|
1598
|
+
if (!attr) try {
|
|
1599
|
+
attr = element.getAttributeNode(name);
|
|
1600
|
+
} catch (_) {
|
|
1601
|
+
attr = null;
|
|
1602
|
+
}
|
|
1603
|
+
arrayPush(DOMPurify.removed, {
|
|
1604
|
+
attribute: attr || null,
|
|
1605
|
+
from: element
|
|
1606
|
+
});
|
|
1607
|
+
try {
|
|
1608
|
+
if (attr) removeAttributeNode(element, attr);
|
|
1609
|
+
else element.removeAttribute(name);
|
|
1610
|
+
} catch (_) {
|
|
1611
|
+
try {
|
|
1612
|
+
element.removeAttribute(name);
|
|
1613
|
+
} catch (_) {}
|
|
1614
|
+
}
|
|
1615
|
+
if (name === "is") {
|
|
1616
|
+
if (RETURN_DOM || RETURN_DOM_FRAGMENT) try {
|
|
1617
|
+
_forceRemove(element);
|
|
1618
|
+
} catch (_) {}
|
|
1619
|
+
else try {
|
|
1620
|
+
element.setAttribute(name, "");
|
|
1621
|
+
} catch (_) {}
|
|
1622
|
+
}
|
|
1623
|
+
};
|
|
1624
|
+
/**
|
|
1625
|
+
* _stripDisallowedAttributes
|
|
1626
|
+
*
|
|
1627
|
+
* Removes every attribute the active configuration does not allow from a
|
|
1628
|
+
* single element, using the same allowlist as the main attribute pass (so
|
|
1629
|
+
* `on*` handlers go, but no `/^on/` blocklist is introduced). Used only to
|
|
1630
|
+
* neutralise nodes that are being discarded from an in-place tree.
|
|
1631
|
+
*
|
|
1632
|
+
* @param element the element to strip
|
|
1633
|
+
*/
|
|
1634
|
+
const _stripDisallowedAttributes = function _stripDisallowedAttributes(element) {
|
|
1635
|
+
const attributes = getAttributes(element);
|
|
1636
|
+
if (!attributes) return;
|
|
1637
|
+
for (let i = attributes.length - 1; i >= 0; --i) {
|
|
1638
|
+
const attribute = attributes[i];
|
|
1639
|
+
const name = attribute && attribute.name;
|
|
1640
|
+
if (typeof name !== "string" || ALLOWED_ATTR[transformCaseFunc(name)]) continue;
|
|
1641
|
+
_stripAttributeNode(element, attribute, name);
|
|
1642
|
+
}
|
|
1643
|
+
};
|
|
1644
|
+
/**
|
|
1645
|
+
* _neutralizeSubtree
|
|
1646
|
+
*
|
|
1647
|
+
* Completes the audit-5 F1 fix across every removal path. The KEEP_CONTENT
|
|
1648
|
+
* move-hoist neutralises only disallowed-tag removals; clobber, mXSS-canary,
|
|
1649
|
+
* namespace, comment, processing-instruction and KEEP_CONTENT:false removals
|
|
1650
|
+
* all drop their subtree wholesale via `_forceRemove`. On the IN_PLACE path
|
|
1651
|
+
* those dropped nodes are detached from the caller's LIVE tree but a
|
|
1652
|
+
* handler-bearing original among them (an `<img onerror>`/`<video>` that was
|
|
1653
|
+
* loading) keeps its queued resource event, which fires in page scope after
|
|
1654
|
+
* sanitize returns. This walks a removed subtree and strips every attribute
|
|
1655
|
+
* the active configuration does not allow — so `on*` handlers are cancelled
|
|
1656
|
+
* through the SAME allowlist that governs kept nodes, not a separate `/^on/`
|
|
1657
|
+
* blocklist. Run synchronously before sanitize returns, i.e. before any
|
|
1658
|
+
* queued event can fire. Hook-free by design: these nodes leave the output,
|
|
1659
|
+
* so firing attribute hooks for them would be surprising. Clobber-safe reads;
|
|
1660
|
+
* a doomed clobbered node may shadow `removeAttribute` (its own attributes are
|
|
1661
|
+
* irrelevant — it is discarded — while its non-clobbered descendants, e.g.
|
|
1662
|
+
* the `<img>`, are reached and scrubbed).
|
|
1663
|
+
*
|
|
1664
|
+
* @param root the root of a removed subtree to neutralise
|
|
1665
|
+
*/
|
|
1666
|
+
const _neutralizeSubtree = function _neutralizeSubtree(root) {
|
|
1667
|
+
const stack = [root];
|
|
1668
|
+
while (stack.length > 0) {
|
|
1669
|
+
const node = stack.pop();
|
|
1670
|
+
if (_readNodeType(node) === NODE_TYPE.element) _stripDisallowedAttributes(node);
|
|
1671
|
+
const childNodes = getChildNodes(node);
|
|
1672
|
+
if (childNodes) for (let i = childNodes.length - 1; i >= 0; --i) stack.push(childNodes[i]);
|
|
1673
|
+
}
|
|
1674
|
+
};
|
|
1675
|
+
/**
|
|
1676
|
+
* _neutralizePatchLinkage
|
|
1677
|
+
*
|
|
1678
|
+
* IN_PLACE entry pre-pass (declarative-partial-updates / streaming
|
|
1679
|
+
* hardening, https://github.com/WICG/declarative-partial-updates).
|
|
1680
|
+
*
|
|
1681
|
+
* The main walk strips patch linkage (`for`/`patchsrc`) and removes range
|
|
1682
|
+
* markers (PIs / markup comments) node-by-node, in document order, AS it
|
|
1683
|
+
* reaches each node. On a live in-place root that leaves a window: from the
|
|
1684
|
+
* moment the root is connected until the walk arrives at a given node, that
|
|
1685
|
+
* node's linkage is live. A patch applied on connection/stream can fire as
|
|
1686
|
+
* a microtask during the walk and inject or teleport an unsanitized DOM
|
|
1687
|
+
* range into a region the iterator has already passed and will not revisit,
|
|
1688
|
+
* so the post-return "tree is sanitized" contract is violated. Sweep the
|
|
1689
|
+
* whole tree once up front and sever every linkage before the walk begins,
|
|
1690
|
+
* closing that window.
|
|
1691
|
+
*
|
|
1692
|
+
* This CANNOT undo a patch that already fired before sanitize ran — that is
|
|
1693
|
+
* the irreducible "do not IN_PLACE a live-connected attacker tree" caveat —
|
|
1694
|
+
* but it closes everything from sanitize-start onward. Gated on SAFE_FOR_XML
|
|
1695
|
+
* to group with the rest of the declarative-partial-updates handling and
|
|
1696
|
+
* stay overridable, consistent with the codebase.
|
|
1697
|
+
*
|
|
1698
|
+
* Clobber-safe traversal (cached childNodes getter); per-node try/catch so a
|
|
1699
|
+
* clobbered root cannot defeat the sweep of its non-clobbered descendants.
|
|
1700
|
+
*
|
|
1701
|
+
* NOTE (pending real-Chrome confirmation, see test/declarative-patch-probe
|
|
1702
|
+
* .html Q1): this mirrors the existing policy of keeping `for` on
|
|
1703
|
+
* <label>/<output>. If the shipping feature can drive a patch through a
|
|
1704
|
+
* surviving `for`-on-label/output + `id` pair, this pre-pass and the
|
|
1705
|
+
* attribute check at _isBasicCustomElement's caller must additionally drop
|
|
1706
|
+
* that pair on the IN_PLACE path. Left as-is until the taxonomy is verified.
|
|
1707
|
+
*
|
|
1708
|
+
* @param root the in-place root to sweep
|
|
1709
|
+
*/
|
|
1710
|
+
/**
|
|
1711
|
+
* Central policy for declarative-partial-updates patch-linkage attributes,
|
|
1712
|
+
* shared by the _neutralizePatchLinkage pre-pass and _isValidAttribute so
|
|
1713
|
+
* the two sites cannot drift: `patchsrc` always links, `for` links
|
|
1714
|
+
* everywhere except on <label>/<output>, and the whole policy is gated on
|
|
1715
|
+
* SAFE_FOR_XML (see the rationale block in _isValidAttribute).
|
|
1716
|
+
*
|
|
1717
|
+
* @param lcName the transformCaseFunc'd attribute name
|
|
1718
|
+
* @param lcTag the transformCaseFunc'd tag name of the carrying element
|
|
1719
|
+
* @return true if the attribute is patch linkage and must be dropped
|
|
1720
|
+
*/
|
|
1721
|
+
const _isPatchLinkageAttribute = function _isPatchLinkageAttribute(lcName, lcTag) {
|
|
1722
|
+
if (!SAFE_FOR_XML) return false;
|
|
1723
|
+
if (lcName === "patchsrc") return true;
|
|
1724
|
+
return lcName === "for" && lcTag !== "label" && lcTag !== "output";
|
|
1725
|
+
};
|
|
1726
|
+
const _neutralizePatchLinkage = function _neutralizePatchLinkage(root) {
|
|
1727
|
+
if (!SAFE_FOR_XML) return;
|
|
1728
|
+
const stack = [root];
|
|
1729
|
+
while (stack.length > 0) {
|
|
1730
|
+
const node = stack.pop();
|
|
1731
|
+
const nodeType = _readNodeType(node);
|
|
1732
|
+
if (nodeType === NODE_TYPE.processingInstruction || nodeType === NODE_TYPE.comment && regExpTest(COMMENT_MARKUP_PROBE, node.data)) {
|
|
1733
|
+
try {
|
|
1734
|
+
remove(node);
|
|
1735
|
+
} catch (_) {}
|
|
1736
|
+
continue;
|
|
1737
|
+
}
|
|
1738
|
+
if (nodeType === NODE_TYPE.element) {
|
|
1739
|
+
const element = node;
|
|
1740
|
+
const lcTag = transformCaseFunc(_readNodeName(node));
|
|
1741
|
+
try {
|
|
1742
|
+
if (element.hasAttribute && element.hasAttribute("patchsrc")) element.removeAttribute("patchsrc");
|
|
1743
|
+
if (element.hasAttribute && element.hasAttribute("for") && _isPatchLinkageAttribute("for", lcTag)) element.removeAttribute("for");
|
|
1744
|
+
} catch (_) {}
|
|
1745
|
+
}
|
|
1746
|
+
const childNodes = getChildNodes(node);
|
|
1747
|
+
if (childNodes) for (let i = childNodes.length - 1; i >= 0; --i) stack.push(childNodes[i]);
|
|
1748
|
+
}
|
|
1749
|
+
};
|
|
1750
|
+
/**
|
|
1751
|
+
* _initDocument
|
|
1752
|
+
*
|
|
1753
|
+
* @param dirty - a string of dirty markup
|
|
1754
|
+
* @return a DOM, filled with the dirty markup
|
|
1755
|
+
*/
|
|
1756
|
+
const _initDocument = function _initDocument(dirty) {
|
|
1757
|
+
let doc = null;
|
|
1758
|
+
let leadingWhitespace = null;
|
|
1759
|
+
if (FORCE_BODY) dirty = "<remove></remove>" + dirty;
|
|
1760
|
+
else {
|
|
1761
|
+
const matches = stringMatch(dirty, /^[\r\n\t ]+/);
|
|
1762
|
+
leadingWhitespace = matches && matches[0];
|
|
1763
|
+
}
|
|
1764
|
+
if (PARSER_MEDIA_TYPE === "application/xhtml+xml" && NAMESPACE === HTML_NAMESPACE) dirty = "<html xmlns=\"http://www.w3.org/1999/xhtml\"><head></head><body>" + dirty + "</body></html>";
|
|
1765
|
+
const dirtyPayload = trustedTypesPolicy ? _createTrustedHTML(dirty) : dirty;
|
|
1766
|
+
if (NAMESPACE === HTML_NAMESPACE) try {
|
|
1767
|
+
doc = new DOMParser().parseFromString(dirtyPayload, PARSER_MEDIA_TYPE);
|
|
1768
|
+
} catch (_) {}
|
|
1769
|
+
if (!doc || !doc.documentElement) {
|
|
1770
|
+
doc = implementation.createDocument(NAMESPACE, "template", null);
|
|
1771
|
+
try {
|
|
1772
|
+
doc.documentElement.innerHTML = IS_EMPTY_INPUT ? emptyHTML : dirtyPayload;
|
|
1773
|
+
} catch (_) {}
|
|
1774
|
+
}
|
|
1775
|
+
const body = doc.body || doc.documentElement;
|
|
1776
|
+
if (dirty && leadingWhitespace) body.insertBefore(document.createTextNode(leadingWhitespace), body.childNodes[0] || null);
|
|
1777
|
+
if (NAMESPACE === HTML_NAMESPACE) return getElementsByTagName.call(doc, WHOLE_DOCUMENT ? "html" : "body")[0];
|
|
1778
|
+
return WHOLE_DOCUMENT ? doc.documentElement : body;
|
|
1779
|
+
};
|
|
1780
|
+
/**
|
|
1781
|
+
* Creates a NodeIterator object that you can use to traverse filtered lists of nodes or elements in a document.
|
|
1782
|
+
*
|
|
1783
|
+
* @param root The root element or node to start traversing on.
|
|
1784
|
+
* @return The created NodeIterator
|
|
1785
|
+
*/
|
|
1786
|
+
const _createNodeIterator = function _createNodeIterator(root) {
|
|
1787
|
+
const doc = getOwnerDocument ? getOwnerDocument(root) : root.ownerDocument;
|
|
1788
|
+
return createNodeIterator.call(doc || root, root, NodeFilter.SHOW_ELEMENT | NodeFilter.SHOW_COMMENT | NodeFilter.SHOW_TEXT | NodeFilter.SHOW_PROCESSING_INSTRUCTION | NodeFilter.SHOW_CDATA_SECTION, null);
|
|
1789
|
+
};
|
|
1790
|
+
/**
|
|
1791
|
+
* Replace template expression syntax (mustache, ERB, template
|
|
1792
|
+
* literal) with a space; shared by all SAFE_FOR_TEMPLATES scrub
|
|
1793
|
+
* sites. Order matters: mustache, then ERB, then template literal.
|
|
1794
|
+
*
|
|
1795
|
+
* @param value the string to scrub
|
|
1796
|
+
* @returns the scrubbed string
|
|
1797
|
+
*/
|
|
1798
|
+
const _stripTemplateExpressions = function _stripTemplateExpressions(value) {
|
|
1799
|
+
value = stringReplace(value, MUSTACHE_EXPR$1, " ");
|
|
1800
|
+
value = stringReplace(value, ERB_EXPR$1, " ");
|
|
1801
|
+
value = stringReplace(value, TMPLIT_EXPR$1, " ");
|
|
1802
|
+
return value;
|
|
1803
|
+
};
|
|
1804
|
+
/**
|
|
1805
|
+
* Strip template-engine expressions ({{...}}, ${...}, <%...%>) from the
|
|
1806
|
+
* character data of an element subtree. Used as the final safety net for
|
|
1807
|
+
* SAFE_FOR_TEMPLATES on every DOM-returning code path so that expressions
|
|
1808
|
+
* which only form after text-node normalization (e.g. fragments split across
|
|
1809
|
+
* stripped elements) cannot survive into a template-evaluating framework.
|
|
1810
|
+
*
|
|
1811
|
+
* Walks text/comment/CDATA/processing-instruction nodes and mutates `.data`
|
|
1812
|
+
* in place rather than round-tripping through innerHTML. This preserves
|
|
1813
|
+
* descendant node references (important for IN_PLACE callers), avoids a
|
|
1814
|
+
* serialize/reparse cycle, and reads literal character data — which means
|
|
1815
|
+
* `<%...%>` in text content matches the ERB regex against its real bytes
|
|
1816
|
+
* instead of the HTML-entity-escaped form innerHTML would produce.
|
|
1817
|
+
*
|
|
1818
|
+
* Attribute values are not visited here; SAFE_FOR_TEMPLATES handling for
|
|
1819
|
+
* attributes is performed during the per-node `_sanitizeAttributes` pass.
|
|
1820
|
+
*
|
|
1821
|
+
* @param node The root element whose character data should be scrubbed.
|
|
1822
|
+
*/
|
|
1823
|
+
const _scrubTemplateExpressions2 = function _scrubTemplateExpressions(node) {
|
|
1824
|
+
var _node$querySelectorAl;
|
|
1825
|
+
node.normalize();
|
|
1826
|
+
const doc = getOwnerDocument ? getOwnerDocument(node) : node.ownerDocument;
|
|
1827
|
+
const walker = createNodeIterator.call(doc || node, node, NodeFilter.SHOW_TEXT | NodeFilter.SHOW_COMMENT | NodeFilter.SHOW_CDATA_SECTION | NodeFilter.SHOW_PROCESSING_INSTRUCTION, null);
|
|
1828
|
+
let currentNode = walker.nextNode();
|
|
1829
|
+
while (currentNode) {
|
|
1830
|
+
currentNode.data = _stripTemplateExpressions(currentNode.data);
|
|
1831
|
+
currentNode = walker.nextNode();
|
|
1832
|
+
}
|
|
1833
|
+
const templates = (_node$querySelectorAl = node.querySelectorAll) === null || _node$querySelectorAl === void 0 ? void 0 : _node$querySelectorAl.call(node, "template");
|
|
1834
|
+
if (templates) arrayForEach(templates, (tmpl) => {
|
|
1835
|
+
if (_isDocumentFragment(tmpl.content)) _scrubTemplateExpressions2(tmpl.content);
|
|
1836
|
+
});
|
|
1837
|
+
};
|
|
1838
|
+
/**
|
|
1839
|
+
* _isClobbered
|
|
1840
|
+
*
|
|
1841
|
+
* Detect DOM-clobbering on HTMLFormElement nodes. Form is the only HTML
|
|
1842
|
+
* interface with [LegacyOverrideBuiltIns]; a descendant element with a
|
|
1843
|
+
* `name` attribute matching a prototype property shadows that property
|
|
1844
|
+
* on direct reads. We use this check at the IN_PLACE entry-point and
|
|
1845
|
+
* during attribute sanitization to refuse clobbered forms.
|
|
1846
|
+
*
|
|
1847
|
+
* @param element element to check for clobbering attacks
|
|
1848
|
+
* @return true if clobbered, false if safe
|
|
1849
|
+
*/
|
|
1850
|
+
const _isClobbered = function _isClobbered(element) {
|
|
1851
|
+
const realTagName = getNodeName ? getNodeName(element) : null;
|
|
1852
|
+
if (typeof realTagName !== "string") return false;
|
|
1853
|
+
if (transformCaseFunc(realTagName) !== "form") return false;
|
|
1854
|
+
return typeof element.nodeName !== "string" || typeof element.textContent !== "string" || typeof element.removeChild !== "function" || element.attributes !== getAttributes(element) || typeof element.removeAttribute !== "function" || typeof element.removeAttributeNode !== "function" || typeof element.getAttributeNode !== "function" || typeof element.setAttribute !== "function" || typeof element.namespaceURI !== "string" || typeof element.insertBefore !== "function" || typeof element.hasChildNodes !== "function" || element.nodeType !== getNodeType(element) || element.childNodes !== getChildNodes(element);
|
|
1855
|
+
};
|
|
1856
|
+
/**
|
|
1857
|
+
* Checks whether the given value is a DocumentFragment from any realm.
|
|
1858
|
+
*
|
|
1859
|
+
* The realm-independent replacement reads `nodeType` through the cached
|
|
1860
|
+
* Node.prototype getter and compares to the DOCUMENT_FRAGMENT_NODE
|
|
1861
|
+
* constant (11). nodeType is a numeric value resolved from the node's
|
|
1862
|
+
* internal slot, identical across realms for the same kind of node.
|
|
1863
|
+
*
|
|
1864
|
+
* @param value object to check
|
|
1865
|
+
* @return true if value is a DocumentFragment-shaped node from any realm
|
|
1866
|
+
*/
|
|
1867
|
+
const _isDocumentFragment = function _isDocumentFragment(value) {
|
|
1868
|
+
if (!getNodeType || typeof value !== "object" || value === null) return false;
|
|
1869
|
+
try {
|
|
1870
|
+
return getNodeType(value) === NODE_TYPE.documentFragment;
|
|
1871
|
+
} catch (_) {
|
|
1872
|
+
return false;
|
|
1873
|
+
}
|
|
1874
|
+
};
|
|
1875
|
+
/**
|
|
1876
|
+
* Checks whether the given object is a DOM node, including nodes that
|
|
1877
|
+
* originate from a different window/realm (e.g. an iframe's
|
|
1878
|
+
* contentDocument). The previous `value instanceof Node` check was
|
|
1879
|
+
* realm-bound: nodes from a different window failed it, causing
|
|
1880
|
+
* sanitize() to silently stringify them and reset IN_PLACE to false,
|
|
1881
|
+
* returning the original node unsanitized. See GHSA-4w3q-35jp-p934.
|
|
1882
|
+
*
|
|
1883
|
+
* @param value object to check whether it's a DOM node
|
|
1884
|
+
* @return true if value is a DOM node from any realm
|
|
1885
|
+
*/
|
|
1886
|
+
const _isNode = function _isNode(value) {
|
|
1887
|
+
if (!getNodeType || typeof value !== "object" || value === null) return false;
|
|
1888
|
+
try {
|
|
1889
|
+
return typeof getNodeType(value) === "number";
|
|
1890
|
+
} catch (_) {
|
|
1891
|
+
return false;
|
|
1892
|
+
}
|
|
1893
|
+
};
|
|
1894
|
+
function _executeHooks(hooks, currentNode, data) {
|
|
1895
|
+
if (hooks.length === 0) return;
|
|
1896
|
+
arrayForEach(hooks, (hook) => {
|
|
1897
|
+
hook.call(DOMPurify, currentNode, data, CONFIG);
|
|
1898
|
+
});
|
|
1899
|
+
}
|
|
1900
|
+
/**
|
|
1901
|
+
* Structural-threat checks that condemn a node regardless of the
|
|
1902
|
+
* allowlists: mXSS via namespace confusion, risky CSS construction,
|
|
1903
|
+
* processing instructions, markup-bearing comments. Pure predicate;
|
|
1904
|
+
* the caller removes. Check order is load-bearing.
|
|
1905
|
+
*
|
|
1906
|
+
* @param currentNode the node to inspect
|
|
1907
|
+
* @param tagName the node's transformCaseFunc'd tag name
|
|
1908
|
+
* @return true if the node must be removed
|
|
1909
|
+
*/
|
|
1910
|
+
const _isUnsafeNode = function _isUnsafeNode(currentNode, tagName) {
|
|
1911
|
+
if (SAFE_FOR_XML && currentNode.hasChildNodes() && !_isNode(currentNode.firstElementChild) && regExpTest(ELEMENT_MARKUP_PROBE, currentNode.textContent) && regExpTest(ELEMENT_MARKUP_PROBE, currentNode.innerHTML)) return true;
|
|
1912
|
+
if (SAFE_FOR_XML && currentNode.namespaceURI === HTML_NAMESPACE && LITERAL_TEXT_ELEMENTS[tagName] && (_isNode(currentNode.firstElementChild) || typeof currentNode.textContent === "string" && regExpTest(LITERAL_TEXT_CLOSE[tagName], currentNode.textContent))) return true;
|
|
1913
|
+
if (currentNode.nodeType === NODE_TYPE.processingInstruction) return true;
|
|
1914
|
+
if (SAFE_FOR_XML && currentNode.nodeType === NODE_TYPE.comment && regExpTest(COMMENT_MARKUP_PROBE, currentNode.data)) return true;
|
|
1915
|
+
return false;
|
|
1916
|
+
};
|
|
1917
|
+
/**
|
|
1918
|
+
* Evaluate a CUSTOM_ELEMENT_HANDLING check (a RegExp or a predicate
|
|
1919
|
+
* function, per the validation in _parseConfig) against a name.
|
|
1920
|
+
* Additional arguments are forwarded to predicate functions - the
|
|
1921
|
+
* attributeNameCheck predicate receives the tag name as its second
|
|
1922
|
+
* argument. A null/absent check never matches.
|
|
1923
|
+
*
|
|
1924
|
+
* @param check the configured tagNameCheck / attributeNameCheck value
|
|
1925
|
+
* @param name the name to test
|
|
1926
|
+
* @param args extra arguments forwarded to a predicate function
|
|
1927
|
+
* @return true if the check matches the name
|
|
1928
|
+
*/
|
|
1929
|
+
const _matchesNameCheck = function _matchesNameCheck(check, name) {
|
|
1930
|
+
if (check instanceof RegExp) return regExpTest(check, name);
|
|
1931
|
+
if (check instanceof Function) {
|
|
1932
|
+
for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) args[_key - 2] = arguments[_key];
|
|
1933
|
+
return Boolean(check(name, ...args));
|
|
1934
|
+
}
|
|
1935
|
+
return false;
|
|
1936
|
+
};
|
|
1937
|
+
/**
|
|
1938
|
+
* Handle a node whose tag is forbidden or not allowlisted: keep
|
|
1939
|
+
* allowed custom elements (false return exits _sanitizeElements
|
|
1940
|
+
* early - the namespace and fallback-tag removal checks are
|
|
1941
|
+
* intentionally skipped for kept custom elements), else hoist
|
|
1942
|
+
* content per KEEP_CONTENT and remove.
|
|
1943
|
+
*
|
|
1944
|
+
* A kept custom element is the ONLY case in which this function
|
|
1945
|
+
* returns false, so the caller uses that return value to run the
|
|
1946
|
+
* afterSanitizeElements hook on the kept element and keep the
|
|
1947
|
+
* element-hook lifecycle consistent with normal allowlisted
|
|
1948
|
+
* elements (GHSA-c2j3-45gr-mqc4).
|
|
1949
|
+
*
|
|
1950
|
+
* @param currentNode the disallowed node
|
|
1951
|
+
* @param tagName the node's transformCaseFunc'd tag name
|
|
1952
|
+
* @return true if the node was removed, false if kept
|
|
1953
|
+
*/
|
|
1954
|
+
const _sanitizeDisallowedNode = function _sanitizeDisallowedNode(currentNode, tagName, root) {
|
|
1955
|
+
if (!FORBID_TAGS[tagName] && _isBasicCustomElement(tagName) && _matchesNameCheck(CUSTOM_ELEMENT_HANDLING.tagNameCheck, tagName)) return false;
|
|
1956
|
+
if (KEEP_CONTENT && !FORBID_CONTENTS[tagName]) {
|
|
1957
|
+
const parentNode = getParentNode(currentNode);
|
|
1958
|
+
const childNodes = getChildNodes(currentNode);
|
|
1959
|
+
if (childNodes && parentNode) {
|
|
1960
|
+
const childCount = childNodes.length;
|
|
1961
|
+
for (let i = childCount - 1; i >= 0; --i) {
|
|
1962
|
+
const hoisted = currentNode === root ? cloneNode(childNodes[i], true) : childNodes[i];
|
|
1963
|
+
parentNode.insertBefore(hoisted, getNextSibling(currentNode));
|
|
1964
|
+
}
|
|
1965
|
+
}
|
|
1966
|
+
}
|
|
1967
|
+
_forceRemove(currentNode);
|
|
1968
|
+
return true;
|
|
1969
|
+
};
|
|
1970
|
+
/**
|
|
1971
|
+
* Fork a hook-mutable allowlist off its shared binding the first time a
|
|
1972
|
+
* (possibly lazily-installed) uponSanitize* hook is about to see it, so the
|
|
1973
|
+
* hook cannot widen the per-instance default or the setConfig binding by
|
|
1974
|
+
* reference and leak past the call. Returns the set unchanged once it is
|
|
1975
|
+
* already call-local, so repeated calls across elements are idempotent.
|
|
1976
|
+
*
|
|
1977
|
+
* @param hookList the uponSanitize* hook array for this event
|
|
1978
|
+
* @param set the current ALLOWED_TAGS / ALLOWED_ATTR binding
|
|
1979
|
+
* @param defaultSet the per-instance DEFAULT_ALLOWED_* constant
|
|
1980
|
+
* @param setConfigSet the captured setConfig() binding, or null
|
|
1981
|
+
* @return a call-local clone if a hook is present and set is still shared,
|
|
1982
|
+
* else set unchanged
|
|
1983
|
+
*/
|
|
1984
|
+
const _forkSharedAllowlist = function _forkSharedAllowlist(hookList, set, defaultSet, setConfigSet) {
|
|
1985
|
+
if (hookList.length === 0) return set;
|
|
1986
|
+
return set === defaultSet || set === setConfigSet ? clone(set) : set;
|
|
1987
|
+
};
|
|
1988
|
+
/**
|
|
1989
|
+
* Shared guard for a node that a hook has detached from the walk tree,
|
|
1990
|
+
* used after each element-hook site in _sanitizeElements. Detaching is a
|
|
1991
|
+
* long-standing user pattern (issue #469; draw.io-style foreignObject
|
|
1992
|
+
* filtering). Per the cached, unclobberable parentNode getter the node is
|
|
1993
|
+
* genuinely out of the tree, so it can reach neither the serialized
|
|
1994
|
+
* output nor an IN_PLACE live tree; treat it as removed and stop
|
|
1995
|
+
* processing it. Without this guard, the unsafe-node / namespace checks
|
|
1996
|
+
* would call _forceRemove on a parentless node and hit the REPORT-3
|
|
1997
|
+
* fail-closed throw — which exists for nodes DOMPurify wants gone but
|
|
1998
|
+
* *cannot* detach (clobbered / parentless roots), the opposite of a node
|
|
1999
|
+
* that is already safely gone. The walk root is exempt: a detached
|
|
2000
|
+
* IN_PLACE root is legitimate input and must still be fully sanitized,
|
|
2001
|
+
* and a kill-decision on it must keep hitting the REPORT-3 throw.
|
|
2002
|
+
*
|
|
2003
|
+
* Nodes detached by hooks stay the hook's responsibility for placement:
|
|
2004
|
+
* they are not recorded in DOMPurify.removed, so the post-walk IN_PLACE
|
|
2005
|
+
* pass (which iterates DOMPurify.removed) does not reach them. But a
|
|
2006
|
+
* hook-detached subtree can still hold a queued resource-event handler -
|
|
2007
|
+
* e.g. an <img onload> that began loading when the caller built the live
|
|
2008
|
+
* tree - which fires in page scope after sanitize returns even though the
|
|
2009
|
+
* handler never reached the returned tree. That is the audit-5 F1 hazard,
|
|
2010
|
+
* and the documented node.remove() hook pattern walks straight into it.
|
|
2011
|
+
* So on the IN_PLACE path we neutralize the detached subtree inline,
|
|
2012
|
+
* stripping its non-allow-listed attributes before returning, exactly as
|
|
2013
|
+
* the post-walk pass does for _forceRemove'd subtrees.
|
|
2014
|
+
*
|
|
2015
|
+
* @param currentNode the node a hook may have detached
|
|
2016
|
+
* @param root the current walk root
|
|
2017
|
+
* @return true if the node is detached and now handled, false otherwise
|
|
2018
|
+
*/
|
|
2019
|
+
const _handleHookDetachedNode = function _handleHookDetachedNode(currentNode, root) {
|
|
2020
|
+
if (currentNode === root || getParentNode(currentNode) !== null) return false;
|
|
2021
|
+
if (IN_PLACE) _neutralizeSubtree(currentNode);
|
|
2022
|
+
return true;
|
|
2023
|
+
};
|
|
2024
|
+
/**
|
|
2025
|
+
* _sanitizeElements
|
|
2026
|
+
*
|
|
2027
|
+
* @protect nodeName
|
|
2028
|
+
* @protect textContent
|
|
2029
|
+
* @protect removeChild
|
|
2030
|
+
* @param currentNode to check for permission to exist
|
|
2031
|
+
* @return true if node was killed, false if left alive
|
|
2032
|
+
*/
|
|
2033
|
+
const _sanitizeElements = function _sanitizeElements(currentNode, root) {
|
|
2034
|
+
_executeHooks(hooks.beforeSanitizeElements, currentNode, null);
|
|
2035
|
+
if (_handleHookDetachedNode(currentNode, root)) return true;
|
|
2036
|
+
if (_isClobbered(currentNode)) {
|
|
2037
|
+
_forceRemove(currentNode);
|
|
2038
|
+
return true;
|
|
2039
|
+
}
|
|
2040
|
+
const tagName = transformCaseFunc(_readNodeName(currentNode));
|
|
2041
|
+
ALLOWED_TAGS = _forkSharedAllowlist(hooks.uponSanitizeElement, ALLOWED_TAGS, DEFAULT_ALLOWED_TAGS, SET_CONFIG_ALLOWED_TAGS);
|
|
2042
|
+
_executeHooks(hooks.uponSanitizeElement, currentNode, {
|
|
2043
|
+
tagName,
|
|
2044
|
+
allowedTags: ALLOWED_TAGS
|
|
2045
|
+
});
|
|
2046
|
+
if (_handleHookDetachedNode(currentNode, root)) return true;
|
|
2047
|
+
if (_isUnsafeNode(currentNode, tagName)) {
|
|
2048
|
+
_forceRemove(currentNode);
|
|
2049
|
+
return true;
|
|
2050
|
+
}
|
|
2051
|
+
if (FORBID_TAGS[tagName] || !(EXTRA_ELEMENT_HANDLING.tagCheck instanceof Function && EXTRA_ELEMENT_HANDLING.tagCheck(tagName)) && !ALLOWED_TAGS[tagName]) {
|
|
2052
|
+
const removed = _sanitizeDisallowedNode(currentNode, tagName, root);
|
|
2053
|
+
if (removed === false) {
|
|
2054
|
+
_executeHooks(hooks.afterSanitizeElements, currentNode, null);
|
|
2055
|
+
if (_handleHookDetachedNode(currentNode, root)) return true;
|
|
2056
|
+
}
|
|
2057
|
+
return removed;
|
|
2058
|
+
}
|
|
2059
|
+
if (_readNodeType(currentNode) === NODE_TYPE.element && !_checkValidNamespace(currentNode)) {
|
|
2060
|
+
_forceRemove(currentNode);
|
|
2061
|
+
return true;
|
|
2062
|
+
}
|
|
2063
|
+
if ((tagName === "noscript" || tagName === "noembed" || tagName === "noframes") && regExpTest(FALLBACK_TAG_CLOSE, currentNode.innerHTML)) {
|
|
2064
|
+
_forceRemove(currentNode);
|
|
2065
|
+
return true;
|
|
2066
|
+
}
|
|
2067
|
+
if (SAFE_FOR_TEMPLATES && currentNode.nodeType === NODE_TYPE.text) {
|
|
2068
|
+
const content = _stripTemplateExpressions(currentNode.textContent);
|
|
2069
|
+
if (currentNode.textContent !== content) {
|
|
2070
|
+
arrayPush(DOMPurify.removed, { element: currentNode.cloneNode() });
|
|
2071
|
+
currentNode.textContent = content;
|
|
2072
|
+
}
|
|
2073
|
+
}
|
|
2074
|
+
_executeHooks(hooks.afterSanitizeElements, currentNode, null);
|
|
2075
|
+
return _handleHookDetachedNode(currentNode, root);
|
|
2076
|
+
};
|
|
2077
|
+
/**
|
|
2078
|
+
* _isValidAttribute
|
|
2079
|
+
*
|
|
2080
|
+
* @param lcTag Lowercase tag name of containing element.
|
|
2081
|
+
* @param lcName Lowercase attribute name.
|
|
2082
|
+
* @param value Attribute value.
|
|
2083
|
+
* @return Returns true if `value` is valid, otherwise false.
|
|
2084
|
+
*/
|
|
2085
|
+
const _isValidAttribute = function _isValidAttribute(lcTag, lcName, value) {
|
|
2086
|
+
if (FORBID_ATTR[lcName]) return false;
|
|
2087
|
+
if (_isPatchLinkageAttribute(lcName, lcTag)) return false;
|
|
2088
|
+
if (SANITIZE_DOM && (lcName === "id" || lcName === "name") && (value in document || value in formElement)) return false;
|
|
2089
|
+
const nameIsPermitted = ALLOWED_ATTR[lcName] || EXTRA_ELEMENT_HANDLING.attributeCheck instanceof Function && EXTRA_ELEMENT_HANDLING.attributeCheck(lcName, lcTag);
|
|
2090
|
+
if (ALLOW_DATA_ATTR && regExpTest(DATA_ATTR$1, lcName)) return true;
|
|
2091
|
+
if (ALLOW_ARIA_ATTR && regExpTest(ARIA_ATTR$1, lcName)) return true;
|
|
2092
|
+
if (!nameIsPermitted) return _isBasicCustomElement(lcTag) && _matchesNameCheck(CUSTOM_ELEMENT_HANDLING.tagNameCheck, lcTag) && _matchesNameCheck(CUSTOM_ELEMENT_HANDLING.attributeNameCheck, lcName, lcTag) || lcName === "is" && CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements && _matchesNameCheck(CUSTOM_ELEMENT_HANDLING.tagNameCheck, value);
|
|
2093
|
+
if (URI_SAFE_ATTRIBUTES[lcName]) return true;
|
|
2094
|
+
if (regExpTest(IS_ALLOWED_URI$1, stringReplace(value, ATTR_WHITESPACE$1, ""))) return true;
|
|
2095
|
+
if ((lcName === "src" || lcName === "xlink:href" || lcName === "href") && lcTag !== "script" && stringIndexOf(value, "data:") === 0 && DATA_URI_TAGS[lcTag]) return true;
|
|
2096
|
+
if (ALLOW_UNKNOWN_PROTOCOLS && !regExpTest(IS_SCRIPT_OR_DATA$1, stringReplace(value, ATTR_WHITESPACE$1, ""))) return true;
|
|
2097
|
+
return !value;
|
|
2098
|
+
};
|
|
2099
|
+
const RESERVED_CUSTOM_ELEMENT_NAMES = addToSet({}, [
|
|
2100
|
+
"annotation-xml",
|
|
2101
|
+
"color-profile",
|
|
2102
|
+
"font-face",
|
|
2103
|
+
"font-face-format",
|
|
2104
|
+
"font-face-name",
|
|
2105
|
+
"font-face-src",
|
|
2106
|
+
"font-face-uri",
|
|
2107
|
+
"missing-glyph"
|
|
2108
|
+
]);
|
|
2109
|
+
/**
|
|
2110
|
+
* _isBasicCustomElement
|
|
2111
|
+
* checks if at least one dash is included in tagName, and it's not the first char
|
|
2112
|
+
* for more sophisticated checking see https://github.com/sindresorhus/validate-element-name
|
|
2113
|
+
*
|
|
2114
|
+
* @param tagName name of the tag of the node to sanitize
|
|
2115
|
+
* @returns Returns true if the tag name meets the basic criteria for a custom element, otherwise false.
|
|
2116
|
+
*/
|
|
2117
|
+
const _isBasicCustomElement = function _isBasicCustomElement(tagName) {
|
|
2118
|
+
return !RESERVED_CUSTOM_ELEMENT_NAMES[stringToLowerCase(tagName)] && regExpTest(CUSTOM_ELEMENT$1, tagName);
|
|
2119
|
+
};
|
|
2120
|
+
/**
|
|
2121
|
+
* Wrap an attribute value in the matching Trusted Types object when
|
|
2122
|
+
* the active policy requires it. Namespaced attributes pass through
|
|
2123
|
+
* unchanged (no TT support yet, see
|
|
2124
|
+
* https://bugs.chromium.org/p/chromium/issues/detail?id=1305293).
|
|
2125
|
+
*
|
|
2126
|
+
* @param lcTag lowercase tag name of the containing element
|
|
2127
|
+
* @param lcName lowercase attribute name
|
|
2128
|
+
* @param namespaceURI the attribute's namespace, if any
|
|
2129
|
+
* @param value the attribute value to wrap
|
|
2130
|
+
* @return the value, wrapped when Trusted Types demand it
|
|
2131
|
+
*/
|
|
2132
|
+
const _applyTrustedTypesToAttribute = function _applyTrustedTypesToAttribute(lcTag, lcName, namespaceURI, value) {
|
|
2133
|
+
if (trustedTypesPolicy && typeof trustedTypes === "object" && typeof trustedTypes.getAttributeType === "function" && !namespaceURI) switch (trustedTypes.getAttributeType(lcTag, lcName)) {
|
|
2134
|
+
case "TrustedHTML": return _createTrustedHTML(value);
|
|
2135
|
+
case "TrustedScriptURL": return _createTrustedScriptURL(value);
|
|
2136
|
+
}
|
|
2137
|
+
return value;
|
|
2138
|
+
};
|
|
2139
|
+
/**
|
|
2140
|
+
* Write a modified attribute value back onto the element. On
|
|
2141
|
+
* success, re-probe for clobbering introduced by the new value and
|
|
2142
|
+
* remove the element when found; otherwise, when this writeback is the
|
|
2143
|
+
* recreate half of the SANITIZE_NAMED_PROPS remove-and-recreate, pop the
|
|
2144
|
+
* removal entry that path recorded so it does not show as removed. On
|
|
2145
|
+
* failure, remove the attribute instead.
|
|
2146
|
+
*
|
|
2147
|
+
* Returns true only on a clean write (the value was set and the new value
|
|
2148
|
+
* introduced no clobbering). The caller uses that, together with its own
|
|
2149
|
+
* knowledge of whether this attribute pushed a DOMPurify.removed record, to
|
|
2150
|
+
* decide whether to pop that record. The pop must happen ONLY for the
|
|
2151
|
+
* named-prop remove-and-recreate; popping on any other value change (trim,
|
|
2152
|
+
* template scrubbing, Trusted Types) would consume an unrelated _forceRemove
|
|
2153
|
+
* subtree-cleanup record and let that detached subtree keep a live event
|
|
2154
|
+
* handler through the IN_PLACE neutralization pass (SO-001).
|
|
2155
|
+
*
|
|
2156
|
+
* @param currentNode the element carrying the attribute
|
|
2157
|
+
* @param name the attribute name as present on the element
|
|
2158
|
+
* @param namespaceURI the attribute's namespace, if any
|
|
2159
|
+
* @param value the new attribute value
|
|
2160
|
+
* @return true if the value was written without introducing clobbering
|
|
2161
|
+
*/
|
|
2162
|
+
const _setAttributeValue = function _setAttributeValue(currentNode, name, namespaceURI, value) {
|
|
2163
|
+
try {
|
|
2164
|
+
if (namespaceURI) currentNode.setAttributeNS(namespaceURI, name, value);
|
|
2165
|
+
else currentNode.setAttribute(name, value);
|
|
2166
|
+
if (_isClobbered(currentNode)) {
|
|
2167
|
+
_forceRemove(currentNode);
|
|
2168
|
+
return false;
|
|
2169
|
+
}
|
|
2170
|
+
return true;
|
|
2171
|
+
} catch (_) {
|
|
2172
|
+
_removeAttribute(name, currentNode);
|
|
2173
|
+
return false;
|
|
2174
|
+
}
|
|
2175
|
+
};
|
|
2176
|
+
/**
|
|
2177
|
+
* _sanitizeAttributes
|
|
2178
|
+
*
|
|
2179
|
+
* @protect attributes
|
|
2180
|
+
* @protect nodeName
|
|
2181
|
+
* @protect removeAttribute
|
|
2182
|
+
* @protect setAttribute
|
|
2183
|
+
*
|
|
2184
|
+
* @param currentNode to sanitize
|
|
2185
|
+
* @param root the current walk root
|
|
2186
|
+
*/
|
|
2187
|
+
const _sanitizeAttributes = function _sanitizeAttributes(currentNode, root) {
|
|
2188
|
+
_executeHooks(hooks.beforeSanitizeAttributes, currentNode, null);
|
|
2189
|
+
if (_handleHookDetachedNode(currentNode, root)) return;
|
|
2190
|
+
const attributes = currentNode.attributes;
|
|
2191
|
+
if (!attributes || _isClobbered(currentNode)) return;
|
|
2192
|
+
ALLOWED_ATTR = _forkSharedAllowlist(hooks.uponSanitizeAttribute, ALLOWED_ATTR, DEFAULT_ALLOWED_ATTR, SET_CONFIG_ALLOWED_ATTR);
|
|
2193
|
+
const hookEvent = {
|
|
2194
|
+
attrName: "",
|
|
2195
|
+
attrValue: "",
|
|
2196
|
+
keepAttr: true,
|
|
2197
|
+
allowedAttributes: ALLOWED_ATTR,
|
|
2198
|
+
forceKeepAttr: void 0
|
|
2199
|
+
};
|
|
2200
|
+
let l = attributes.length;
|
|
2201
|
+
const lcTag = transformCaseFunc(currentNode.nodeName);
|
|
2202
|
+
while (l--) {
|
|
2203
|
+
const attr = attributes[l];
|
|
2204
|
+
const name = attr.name, namespaceURI = attr.namespaceURI, attrValue = attr.value;
|
|
2205
|
+
const lcName = transformCaseFunc(name);
|
|
2206
|
+
const initValue = attrValue;
|
|
2207
|
+
let value = name === "value" ? initValue : stringTrim(initValue);
|
|
2208
|
+
let recreatedNamedProp = false;
|
|
2209
|
+
hookEvent.attrName = lcName;
|
|
2210
|
+
hookEvent.attrValue = value;
|
|
2211
|
+
hookEvent.keepAttr = true;
|
|
2212
|
+
hookEvent.forceKeepAttr = void 0;
|
|
2213
|
+
_executeHooks(hooks.uponSanitizeAttribute, currentNode, hookEvent);
|
|
2214
|
+
value = hookEvent.attrValue;
|
|
2215
|
+
if (SANITIZE_NAMED_PROPS && (lcName === "id" || lcName === "name") && stringIndexOf(value, SANITIZE_NAMED_PROPS_PREFIX) !== 0) {
|
|
2216
|
+
_removeAttribute(name, currentNode, attr);
|
|
2217
|
+
value = SANITIZE_NAMED_PROPS_PREFIX + value;
|
|
2218
|
+
recreatedNamedProp = true;
|
|
2219
|
+
}
|
|
2220
|
+
if (SAFE_FOR_XML && regExpTest(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i, value)) {
|
|
2221
|
+
_removeAttribute(name, currentNode, attr);
|
|
2222
|
+
continue;
|
|
2223
|
+
}
|
|
2224
|
+
if (lcName === "attributename" && stringMatch(value, "href")) {
|
|
2225
|
+
_removeAttribute(name, currentNode, attr);
|
|
2226
|
+
continue;
|
|
2227
|
+
}
|
|
2228
|
+
if (hookEvent.forceKeepAttr) continue;
|
|
2229
|
+
if (!hookEvent.keepAttr) {
|
|
2230
|
+
_removeAttribute(name, currentNode, attr);
|
|
2231
|
+
continue;
|
|
2232
|
+
}
|
|
2233
|
+
if (!ALLOW_SELF_CLOSE_IN_ATTR && regExpTest(SELF_CLOSING_TAG, value)) {
|
|
2234
|
+
_removeAttribute(name, currentNode, attr);
|
|
2235
|
+
continue;
|
|
2236
|
+
}
|
|
2237
|
+
if (SAFE_FOR_TEMPLATES) value = _stripTemplateExpressions(value);
|
|
2238
|
+
if (!_isValidAttribute(lcTag, lcName, value)) {
|
|
2239
|
+
_removeAttribute(name, currentNode, attr);
|
|
2240
|
+
continue;
|
|
2241
|
+
}
|
|
2242
|
+
value = _applyTrustedTypesToAttribute(lcTag, lcName, namespaceURI, value);
|
|
2243
|
+
if (value !== initValue) {
|
|
2244
|
+
if (_setAttributeValue(currentNode, name, namespaceURI, value) && recreatedNamedProp) arrayPop(DOMPurify.removed);
|
|
2245
|
+
}
|
|
2246
|
+
}
|
|
2247
|
+
_executeHooks(hooks.afterSanitizeAttributes, currentNode, null);
|
|
2248
|
+
_handleHookDetachedNode(currentNode, root);
|
|
2249
|
+
};
|
|
2250
|
+
/**
|
|
2251
|
+
* _sanitizeShadowDOM
|
|
2252
|
+
*
|
|
2253
|
+
* @param fragment to iterate over recursively
|
|
2254
|
+
*/
|
|
2255
|
+
const _sanitizeShadowDOM2 = function _sanitizeShadowDOM(fragment) {
|
|
2256
|
+
let shadowNode = null;
|
|
2257
|
+
const shadowIterator = _createNodeIterator(fragment);
|
|
2258
|
+
_executeHooks(hooks.beforeSanitizeShadowDOM, fragment, null);
|
|
2259
|
+
while (shadowNode = shadowIterator.nextNode()) {
|
|
2260
|
+
_executeHooks(hooks.uponSanitizeShadowNode, shadowNode, null);
|
|
2261
|
+
_sanitizeElements(shadowNode, fragment);
|
|
2262
|
+
_sanitizeAttributes(shadowNode, fragment);
|
|
2263
|
+
if (_isDocumentFragment(shadowNode.content)) _sanitizeShadowDOM2(shadowNode.content);
|
|
2264
|
+
if (_readNodeType(shadowNode) === NODE_TYPE.element) {
|
|
2265
|
+
const innerSr = getShadowRoot(shadowNode);
|
|
2266
|
+
if (_isDocumentFragment(innerSr)) {
|
|
2267
|
+
_sanitizeAttachedShadowRoots(innerSr);
|
|
2268
|
+
_sanitizeShadowDOM2(innerSr);
|
|
2269
|
+
}
|
|
2270
|
+
}
|
|
2271
|
+
}
|
|
2272
|
+
_executeHooks(hooks.afterSanitizeShadowDOM, fragment, null);
|
|
2273
|
+
};
|
|
2274
|
+
/**
|
|
2275
|
+
* _sanitizeAttachedShadowRoots
|
|
2276
|
+
*
|
|
2277
|
+
* Walks `root` and feeds every attached shadow root we encounter into
|
|
2278
|
+
* the existing _sanitizeShadowDOM pipeline. The default node iterator
|
|
2279
|
+
* does not descend into shadow trees, so nodes inside an attached
|
|
2280
|
+
* shadow root would otherwise be skipped entirely.
|
|
2281
|
+
*
|
|
2282
|
+
* Two real input paths put attached shadow roots in front of us:
|
|
2283
|
+
* 1. IN_PLACE on a DOM node that already has shadow roots attached.
|
|
2284
|
+
* 2. DOM-node input where importNode(dirty, true) deep-clones the
|
|
2285
|
+
* shadow root because it was created with `clonable: true`.
|
|
2286
|
+
*
|
|
2287
|
+
* This pass runs once, up front, so the main iteration loop (and the
|
|
2288
|
+
* existing _sanitizeShadowDOM template-content recursion) stay
|
|
2289
|
+
* untouched — string-input paths are not affected.
|
|
2290
|
+
*
|
|
2291
|
+
* @param root the subtree root to walk for attached shadow roots
|
|
2292
|
+
*/
|
|
2293
|
+
const _sanitizeAttachedShadowRoots = function _sanitizeAttachedShadowRoots(root) {
|
|
2294
|
+
const stack = [{
|
|
2295
|
+
node: root,
|
|
2296
|
+
shadow: null
|
|
2297
|
+
}];
|
|
2298
|
+
while (stack.length > 0) {
|
|
2299
|
+
const item = stack.pop();
|
|
2300
|
+
if (item.shadow) {
|
|
2301
|
+
_sanitizeShadowDOM2(item.shadow);
|
|
2302
|
+
continue;
|
|
2303
|
+
}
|
|
2304
|
+
const node = item.node;
|
|
2305
|
+
const isElement = _readNodeType(node) === NODE_TYPE.element;
|
|
2306
|
+
const childNodes = getChildNodes(node);
|
|
2307
|
+
if (childNodes) for (let i = childNodes.length - 1; i >= 0; --i) stack.push({
|
|
2308
|
+
node: childNodes[i],
|
|
2309
|
+
shadow: null
|
|
2310
|
+
});
|
|
2311
|
+
if (isElement) {
|
|
2312
|
+
const rootName = getNodeName ? getNodeName(node) : null;
|
|
2313
|
+
if (typeof rootName === "string" && transformCaseFunc(rootName) === "template") {
|
|
2314
|
+
const content = node.content;
|
|
2315
|
+
if (_isDocumentFragment(content)) stack.push({
|
|
2316
|
+
node: content,
|
|
2317
|
+
shadow: null
|
|
2318
|
+
});
|
|
2319
|
+
}
|
|
2320
|
+
}
|
|
2321
|
+
if (isElement) {
|
|
2322
|
+
const sr = getShadowRoot(node);
|
|
2323
|
+
if (_isDocumentFragment(sr)) stack.push({
|
|
2324
|
+
node: null,
|
|
2325
|
+
shadow: sr
|
|
2326
|
+
}, {
|
|
2327
|
+
node: sr,
|
|
2328
|
+
shadow: null
|
|
2329
|
+
});
|
|
2330
|
+
}
|
|
2331
|
+
}
|
|
2332
|
+
};
|
|
2333
|
+
DOMPurify.sanitize = function(dirty) {
|
|
2334
|
+
let cfg = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
|
|
2335
|
+
let body = null;
|
|
2336
|
+
let importedNode = null;
|
|
2337
|
+
let currentNode = null;
|
|
2338
|
+
let returnNode = null;
|
|
2339
|
+
IS_EMPTY_INPUT = !dirty;
|
|
2340
|
+
if (IS_EMPTY_INPUT) dirty = "<!-->";
|
|
2341
|
+
if (typeof dirty !== "string" && !_isNode(dirty)) {
|
|
2342
|
+
dirty = stringifyValue(dirty);
|
|
2343
|
+
if (typeof dirty !== "string") throw typeErrorCreate("dirty is not a string, aborting");
|
|
2344
|
+
}
|
|
2345
|
+
if (!DOMPurify.isSupported) return dirty;
|
|
2346
|
+
if (SET_CONFIG) {
|
|
2347
|
+
ALLOWED_TAGS = SET_CONFIG_ALLOWED_TAGS;
|
|
2348
|
+
ALLOWED_ATTR = SET_CONFIG_ALLOWED_ATTR;
|
|
2349
|
+
} else _parseConfig(cfg);
|
|
2350
|
+
if (hooks.uponSanitizeElement.length > 0 || hooks.uponSanitizeAttribute.length > 0) ALLOWED_TAGS = clone(ALLOWED_TAGS);
|
|
2351
|
+
if (hooks.uponSanitizeAttribute.length > 0) ALLOWED_ATTR = clone(ALLOWED_ATTR);
|
|
2352
|
+
DOMPurify.removed = [];
|
|
2353
|
+
const inPlace = IN_PLACE && typeof dirty !== "string" && _isNode(dirty);
|
|
2354
|
+
if (inPlace) {
|
|
2355
|
+
_neutralizePatchLinkage(dirty);
|
|
2356
|
+
const nn = _readNodeName(dirty);
|
|
2357
|
+
if (typeof nn === "string") {
|
|
2358
|
+
const tagName = transformCaseFunc(nn);
|
|
2359
|
+
if (!ALLOWED_TAGS[tagName] || FORBID_TAGS[tagName]) {
|
|
2360
|
+
_neutralizeRoot(dirty);
|
|
2361
|
+
throw typeErrorCreate("root node is forbidden and cannot be sanitized in-place");
|
|
2362
|
+
}
|
|
2363
|
+
}
|
|
2364
|
+
if (_isClobbered(dirty)) {
|
|
2365
|
+
_neutralizeRoot(dirty);
|
|
2366
|
+
throw typeErrorCreate("root node is clobbered and cannot be sanitized in-place");
|
|
2367
|
+
}
|
|
2368
|
+
try {
|
|
2369
|
+
_sanitizeAttachedShadowRoots(dirty);
|
|
2370
|
+
} catch (error) {
|
|
2371
|
+
_neutralizeRoot(dirty);
|
|
2372
|
+
throw error;
|
|
2373
|
+
}
|
|
2374
|
+
} else if (_isNode(dirty)) {
|
|
2375
|
+
body = _initDocument("<!---->");
|
|
2376
|
+
importedNode = body.ownerDocument.importNode(dirty, true);
|
|
2377
|
+
if (importedNode.nodeType === NODE_TYPE.element && importedNode.nodeName === "BODY") body = importedNode;
|
|
2378
|
+
else if (importedNode.nodeName === "HTML") body = importedNode;
|
|
2379
|
+
else body.appendChild(importedNode);
|
|
2380
|
+
_sanitizeAttachedShadowRoots(body);
|
|
2381
|
+
} else {
|
|
2382
|
+
if (!RETURN_DOM && !SAFE_FOR_TEMPLATES && !WHOLE_DOCUMENT && dirty.indexOf("<") === -1) return trustedTypesPolicy && RETURN_TRUSTED_TYPE ? _createTrustedHTML(dirty) : dirty;
|
|
2383
|
+
body = _initDocument(dirty);
|
|
2384
|
+
if (!body) return RETURN_DOM ? null : RETURN_TRUSTED_TYPE ? emptyHTML : "";
|
|
2385
|
+
}
|
|
2386
|
+
if (body && FORCE_BODY) _forceRemove(body.firstChild);
|
|
2387
|
+
const walkRoot = inPlace ? dirty : body;
|
|
2388
|
+
try {
|
|
2389
|
+
const nodeIterator = _createNodeIterator(walkRoot);
|
|
2390
|
+
while (currentNode = nodeIterator.nextNode()) {
|
|
2391
|
+
_sanitizeElements(currentNode, walkRoot);
|
|
2392
|
+
_sanitizeAttributes(currentNode, walkRoot);
|
|
2393
|
+
if (_isDocumentFragment(currentNode.content)) _sanitizeShadowDOM2(currentNode.content);
|
|
2394
|
+
}
|
|
2395
|
+
} catch (error) {
|
|
2396
|
+
if (inPlace) {
|
|
2397
|
+
_neutralizeRoot(dirty);
|
|
2398
|
+
arrayForEach(DOMPurify.removed, (entry) => {
|
|
2399
|
+
if (entry.element) _neutralizeSubtree(entry.element);
|
|
2400
|
+
});
|
|
2401
|
+
}
|
|
2402
|
+
throw error;
|
|
2403
|
+
}
|
|
2404
|
+
if (inPlace) {
|
|
2405
|
+
let rootWasRemoved = false;
|
|
2406
|
+
arrayForEach(DOMPurify.removed, (entry) => {
|
|
2407
|
+
if (entry.element) {
|
|
2408
|
+
if (entry.element === dirty) rootWasRemoved = true;
|
|
2409
|
+
_neutralizeSubtree(entry.element);
|
|
2410
|
+
}
|
|
2411
|
+
});
|
|
2412
|
+
if (rootWasRemoved) throw typeErrorCreate("a node selected for removal could not be safely returned; refusing to sanitize in place");
|
|
2413
|
+
if (SAFE_FOR_TEMPLATES) _scrubTemplateExpressions2(dirty);
|
|
2414
|
+
return dirty;
|
|
2415
|
+
}
|
|
2416
|
+
if (RETURN_DOM) {
|
|
2417
|
+
if (SAFE_FOR_TEMPLATES) _scrubTemplateExpressions2(body);
|
|
2418
|
+
if (RETURN_DOM_FRAGMENT) {
|
|
2419
|
+
returnNode = createDocumentFragment.call(body.ownerDocument);
|
|
2420
|
+
while (body.firstChild) returnNode.appendChild(body.firstChild);
|
|
2421
|
+
} else returnNode = body;
|
|
2422
|
+
if (ALLOWED_ATTR.shadowroot || ALLOWED_ATTR.shadowrootmode) returnNode = importNode.call(originalDocument, returnNode, true);
|
|
2423
|
+
return returnNode;
|
|
2424
|
+
}
|
|
2425
|
+
let serializedHTML = WHOLE_DOCUMENT ? body.outerHTML : body.innerHTML;
|
|
2426
|
+
if (WHOLE_DOCUMENT && ALLOWED_TAGS["!doctype"] && body.ownerDocument && body.ownerDocument.doctype && body.ownerDocument.doctype.name && regExpTest(DOCTYPE_NAME, body.ownerDocument.doctype.name)) serializedHTML = "<!DOCTYPE " + body.ownerDocument.doctype.name + ">\n" + serializedHTML;
|
|
2427
|
+
if (SAFE_FOR_TEMPLATES) serializedHTML = _stripTemplateExpressions(serializedHTML);
|
|
2428
|
+
return trustedTypesPolicy && RETURN_TRUSTED_TYPE ? _createTrustedHTML(serializedHTML) : serializedHTML;
|
|
2429
|
+
};
|
|
2430
|
+
DOMPurify.setConfig = function() {
|
|
2431
|
+
let cfg = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
|
2432
|
+
_parseConfig(cfg);
|
|
2433
|
+
SET_CONFIG = true;
|
|
2434
|
+
SET_CONFIG_ALLOWED_TAGS = ALLOWED_TAGS;
|
|
2435
|
+
SET_CONFIG_ALLOWED_ATTR = ALLOWED_ATTR;
|
|
2436
|
+
};
|
|
2437
|
+
DOMPurify.clearConfig = function() {
|
|
2438
|
+
CONFIG = null;
|
|
2439
|
+
SET_CONFIG = false;
|
|
2440
|
+
SET_CONFIG_ALLOWED_TAGS = null;
|
|
2441
|
+
SET_CONFIG_ALLOWED_ATTR = null;
|
|
2442
|
+
trustedTypesPolicy = defaultTrustedTypesPolicy;
|
|
2443
|
+
emptyHTML = "";
|
|
2444
|
+
};
|
|
2445
|
+
DOMPurify.isValidAttribute = function(tag, attr, value) {
|
|
2446
|
+
if (!CONFIG) _parseConfig({});
|
|
2447
|
+
const lcTag = transformCaseFunc(tag);
|
|
2448
|
+
const lcName = transformCaseFunc(attr);
|
|
2449
|
+
return _isValidAttribute(lcTag, lcName, value);
|
|
2450
|
+
};
|
|
2451
|
+
DOMPurify.addHook = function(entryPoint, hookFunction) {
|
|
2452
|
+
if (typeof hookFunction !== "function") return;
|
|
2453
|
+
if (!objectHasOwnProperty(hooks, entryPoint)) return;
|
|
2454
|
+
arrayPush(hooks[entryPoint], hookFunction);
|
|
2455
|
+
};
|
|
2456
|
+
DOMPurify.removeHook = function(entryPoint, hookFunction) {
|
|
2457
|
+
if (!objectHasOwnProperty(hooks, entryPoint)) return;
|
|
2458
|
+
if (hookFunction !== void 0) {
|
|
2459
|
+
const index = arrayLastIndexOf(hooks[entryPoint], hookFunction);
|
|
2460
|
+
return index === -1 ? void 0 : arraySplice(hooks[entryPoint], index, 1)[0];
|
|
2461
|
+
}
|
|
2462
|
+
return arrayPop(hooks[entryPoint]);
|
|
2463
|
+
};
|
|
2464
|
+
DOMPurify.removeHooks = function(entryPoint) {
|
|
2465
|
+
if (!objectHasOwnProperty(hooks, entryPoint)) return;
|
|
2466
|
+
hooks[entryPoint] = [];
|
|
2467
|
+
};
|
|
2468
|
+
DOMPurify.removeAllHooks = function() {
|
|
2469
|
+
hooks = _createHooksMap();
|
|
2470
|
+
};
|
|
2471
|
+
return DOMPurify;
|
|
2227
2472
|
}
|
|
2228
|
-
var
|
|
2473
|
+
var purify_default = createDOMPurify();
|
|
2229
2474
|
|
|
2230
2475
|
|
|
2231
2476
|
//# sourceMappingURL=purify.es.mjs.map
|
|
2232
2477
|
|
|
2233
|
-
|
|
2234
2478
|
/***/ })
|
|
2235
2479
|
|
|
2236
2480
|
}])
|