@ukic/web-components 3.28.0 → 3.30.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/components/ic-accordion.js +53 -38
- package/components/ic-accordion.js.map +1 -1
- package/components/ic-breadcrumb-group.js +16 -12
- package/components/ic-breadcrumb-group.js.map +1 -1
- package/components/ic-menu-item2.js +7 -2
- package/components/ic-menu-item2.js.map +1 -1
- package/components/ic-menu2.js +1393 -307
- package/components/ic-menu2.js.map +1 -1
- package/components/ic-navigation-button.js +8 -5
- package/components/ic-navigation-button.js.map +1 -1
- package/components/ic-pagination-bar.js.map +1 -1
- package/components/ic-pagination-item2.js.map +1 -1
- package/components/ic-pagination2.js.map +1 -1
- package/components/ic-popover-menu.js +17 -5
- package/components/ic-popover-menu.js.map +1 -1
- package/components/ic-radio-group.js.map +1 -1
- package/components/ic-skip-link.js.map +1 -1
- package/components/ic-status-tag.js.map +1 -1
- package/dist/cjs/core.cjs.js +1 -1
- package/dist/cjs/ic-accordion.cjs.entry.js +53 -38
- package/dist/cjs/ic-accordion.cjs.entry.js.map +1 -1
- package/dist/cjs/ic-breadcrumb-group.cjs.entry.js +16 -12
- package/dist/cjs/ic-breadcrumb-group.cjs.entry.js.map +1 -1
- package/dist/cjs/ic-button_3.cjs.entry.js.map +1 -1
- package/dist/cjs/ic-horizontal-scroll.cjs.entry.js.map +1 -1
- package/dist/cjs/ic-input-component-container_3.cjs.entry.js +1393 -307
- package/dist/cjs/ic-input-component-container_3.cjs.entry.js.map +1 -1
- package/dist/cjs/ic-menu-item.cjs.entry.js +5 -1
- package/dist/cjs/ic-menu-item.cjs.entry.js.map +1 -1
- package/dist/cjs/ic-navigation-button.cjs.entry.js +8 -5
- package/dist/cjs/ic-navigation-button.cjs.entry.js.map +1 -1
- package/dist/cjs/ic-popover-menu.cjs.entry.js +16 -5
- package/dist/cjs/ic-popover-menu.cjs.entry.js.map +1 -1
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/collection/components/ic-accordion/ic-accordion.js +53 -38
- package/dist/collection/components/ic-accordion/ic-accordion.js.map +1 -1
- package/dist/collection/components/ic-breadcrumb-group/ic-breadcrumb-group.js +17 -13
- package/dist/collection/components/ic-breadcrumb-group/ic-breadcrumb-group.js.map +1 -1
- package/dist/collection/components/ic-menu-item/ic-menu-item.css +9 -14
- package/dist/collection/components/ic-menu-item/ic-menu-item.js +24 -0
- package/dist/collection/components/ic-menu-item/ic-menu-item.js.map +1 -1
- package/dist/collection/components/ic-navigation-button/ic-navigation-button.js +8 -5
- package/dist/collection/components/ic-navigation-button/ic-navigation-button.js.map +1 -1
- package/dist/collection/components/ic-popover-menu/ic-popover-menu.js +36 -5
- package/dist/collection/components/ic-popover-menu/ic-popover-menu.js.map +1 -1
- package/dist/collection/components/ic-popover-menu/ic-popover-menu.stories.js +169 -1
- package/dist/components/ic-accordion.js +53 -38
- package/dist/components/ic-accordion.js.map +1 -1
- package/dist/components/ic-back-to-top.js.map +1 -1
- package/dist/components/ic-breadcrumb-group.js +16 -12
- package/dist/components/ic-breadcrumb-group.js.map +1 -1
- package/dist/components/ic-menu-item2.js +7 -2
- package/dist/components/ic-menu-item2.js.map +1 -1
- package/dist/components/ic-menu2.js +1393 -307
- package/dist/components/ic-menu2.js.map +1 -1
- package/dist/components/ic-navigation-button.js +8 -5
- package/dist/components/ic-navigation-button.js.map +1 -1
- package/dist/components/ic-popover-menu.js +17 -5
- package/dist/components/ic-popover-menu.js.map +1 -1
- package/dist/components/ic-radio-group.js.map +1 -1
- package/dist/components/ic-radio-option.js.map +1 -1
- package/dist/components/ic-side-navigation.js.map +1 -1
- package/dist/components/ic-skip-link.js.map +1 -1
- package/dist/components/ic-status-tag.js.map +1 -1
- package/dist/core/core.esm.js +1 -1
- package/dist/core/core.esm.js.map +1 -1
- package/dist/core/{p-9ced00a7.entry.js → p-41bbdc4c.entry.js} +2 -2
- package/dist/core/{p-9ced00a7.entry.js.map → p-41bbdc4c.entry.js.map} +1 -1
- package/dist/core/p-8fc5e9f9.entry.js.map +1 -1
- package/dist/core/p-98dee727.entry.js.map +1 -1
- package/dist/core/{p-fc4b7d2b.entry.js → p-9cf35c23.entry.js} +2 -2
- package/dist/core/p-9cf35c23.entry.js.map +1 -0
- package/dist/core/p-be8bbed8.entry.js +2 -0
- package/dist/core/p-be8bbed8.entry.js.map +1 -0
- package/dist/core/p-ccba84b7.entry.js +3 -0
- package/dist/core/p-ccba84b7.entry.js.map +1 -0
- package/dist/core/p-ef289935.entry.js +2 -0
- package/dist/core/p-ef289935.entry.js.map +1 -0
- package/dist/core/p-f8aa89ff.entry.js +2 -0
- package/dist/core/p-f8aa89ff.entry.js.map +1 -0
- package/dist/esm/core.js +1 -1
- package/dist/esm/ic-accordion.entry.js +53 -38
- package/dist/esm/ic-accordion.entry.js.map +1 -1
- package/dist/esm/ic-breadcrumb-group.entry.js +16 -12
- package/dist/esm/ic-breadcrumb-group.entry.js.map +1 -1
- package/dist/esm/ic-button_3.entry.js.map +1 -1
- package/dist/esm/ic-horizontal-scroll.entry.js.map +1 -1
- package/dist/esm/ic-input-component-container_3.entry.js +1393 -307
- package/dist/esm/ic-input-component-container_3.entry.js.map +1 -1
- package/dist/esm/ic-menu-item.entry.js +5 -1
- package/dist/esm/ic-menu-item.entry.js.map +1 -1
- package/dist/esm/ic-navigation-button.entry.js +8 -5
- package/dist/esm/ic-navigation-button.entry.js.map +1 -1
- package/dist/esm/ic-popover-menu.entry.js +16 -5
- package/dist/esm/ic-popover-menu.entry.js.map +1 -1
- package/dist/esm/loader.js +1 -1
- package/dist/types/components/ic-accordion/ic-accordion.d.ts +2 -0
- package/dist/types/components/ic-breadcrumb-group/ic-breadcrumb-group.d.ts +6 -1
- package/dist/types/components/ic-menu-item/ic-menu-item.d.ts +4 -0
- package/dist/types/components/ic-popover-menu/ic-popover-menu.d.ts +4 -0
- package/dist/types/components.d.ts +18 -2
- package/hydrate/index.js +1494 -369
- package/hydrate/index.mjs +1494 -369
- package/package.json +10 -6
- package/vscode-data.json +20 -1
- package/dist/core/p-2b1ce5b7.entry.js +0 -2
- package/dist/core/p-2b1ce5b7.entry.js.map +0 -1
- package/dist/core/p-56ab6fb7.entry.js +0 -2
- package/dist/core/p-56ab6fb7.entry.js.map +0 -1
- package/dist/core/p-d5fcd4f9.entry.js +0 -2
- package/dist/core/p-d5fcd4f9.entry.js.map +0 -1
- package/dist/core/p-fc4b7d2b.entry.js.map +0 -1
- package/dist/core/p-fdc4376e.entry.js +0 -3
- package/dist/core/p-fdc4376e.entry.js.map +0 -1
|
@@ -101,28 +101,69 @@ var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof win
|
|
|
101
101
|
|
|
102
102
|
var purify = {exports: {}};
|
|
103
103
|
|
|
104
|
-
/*! @license DOMPurify 3.4.
|
|
104
|
+
/*! @license DOMPurify 3.4.13 | (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.13/LICENSE */
|
|
105
105
|
|
|
106
106
|
(function (module, exports) {
|
|
107
107
|
(function (global, factory) {
|
|
108
108
|
module.exports = factory() ;
|
|
109
109
|
})(commonjsGlobal, (function () {
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
110
|
+
function _arrayLikeToArray(r, a) {
|
|
111
|
+
(null == a || a > r.length) && (a = r.length);
|
|
112
|
+
for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
|
|
113
|
+
return n;
|
|
114
|
+
}
|
|
115
|
+
function _arrayWithHoles(r) {
|
|
116
|
+
if (Array.isArray(r)) return r;
|
|
117
|
+
}
|
|
118
|
+
function _iterableToArrayLimit(r, l) {
|
|
119
|
+
var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
|
|
120
|
+
if (null != t) {
|
|
121
|
+
var e,
|
|
122
|
+
n,
|
|
123
|
+
i,
|
|
124
|
+
u,
|
|
125
|
+
a = [],
|
|
126
|
+
f = true,
|
|
127
|
+
o = false;
|
|
128
|
+
try {
|
|
129
|
+
if (i = (t = t.call(r)).next, 0 === l) ; else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0);
|
|
130
|
+
} catch (r) {
|
|
131
|
+
o = true, n = r;
|
|
132
|
+
} finally {
|
|
133
|
+
try {
|
|
134
|
+
if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return;
|
|
135
|
+
} finally {
|
|
136
|
+
if (o) throw n;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
return a;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
function _nonIterableRest() {
|
|
143
|
+
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
144
|
+
}
|
|
145
|
+
function _slicedToArray(r, e) {
|
|
146
|
+
return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest();
|
|
147
|
+
}
|
|
148
|
+
function _unsupportedIterableToArray(r, a) {
|
|
149
|
+
if (r) {
|
|
150
|
+
if ("string" == typeof r) return _arrayLikeToArray(r, a);
|
|
151
|
+
var t = {}.toString.call(r).slice(8, -1);
|
|
152
|
+
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;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
const entries = Object.entries,
|
|
157
|
+
setPrototypeOf = Object.setPrototypeOf,
|
|
158
|
+
isFrozen = Object.isFrozen,
|
|
159
|
+
getPrototypeOf = Object.getPrototypeOf,
|
|
160
|
+
getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
|
|
161
|
+
let freeze = Object.freeze,
|
|
162
|
+
seal = Object.seal,
|
|
163
|
+
create = Object.create; // eslint-disable-line import/no-mutable-exports
|
|
164
|
+
let _ref = typeof Reflect !== 'undefined' && Reflect,
|
|
165
|
+
apply = _ref.apply,
|
|
166
|
+
construct = _ref.construct;
|
|
126
167
|
if (!freeze) {
|
|
127
168
|
freeze = function freeze(x) {
|
|
128
169
|
return x;
|
|
@@ -154,13 +195,19 @@ var purify = {exports: {}};
|
|
|
154
195
|
const arrayPop = unapply(Array.prototype.pop);
|
|
155
196
|
const arrayPush = unapply(Array.prototype.push);
|
|
156
197
|
const arraySplice = unapply(Array.prototype.splice);
|
|
198
|
+
const arrayIsArray = Array.isArray;
|
|
157
199
|
const stringToLowerCase = unapply(String.prototype.toLowerCase);
|
|
158
200
|
const stringToString = unapply(String.prototype.toString);
|
|
159
201
|
const stringMatch = unapply(String.prototype.match);
|
|
160
202
|
const stringReplace = unapply(String.prototype.replace);
|
|
161
203
|
const stringIndexOf = unapply(String.prototype.indexOf);
|
|
162
204
|
const stringTrim = unapply(String.prototype.trim);
|
|
205
|
+
const numberToString = unapply(Number.prototype.toString);
|
|
206
|
+
const booleanToString = unapply(Boolean.prototype.toString);
|
|
207
|
+
const bigintToString = typeof BigInt === 'undefined' ? null : unapply(BigInt.prototype.toString);
|
|
208
|
+
const symbolToString = typeof Symbol === 'undefined' ? null : unapply(Symbol.prototype.toString);
|
|
163
209
|
const objectHasOwnProperty = unapply(Object.prototype.hasOwnProperty);
|
|
210
|
+
const objectToString = unapply(Object.prototype.toString);
|
|
164
211
|
const regExpTest = unapply(RegExp.prototype.test);
|
|
165
212
|
const typeErrorCreate = unconstruct(TypeError);
|
|
166
213
|
/**
|
|
@@ -210,6 +257,9 @@ var purify = {exports: {}};
|
|
|
210
257
|
// Prevent prototype setters from intercepting set as a this value.
|
|
211
258
|
setPrototypeOf(set, null);
|
|
212
259
|
}
|
|
260
|
+
if (!arrayIsArray(array)) {
|
|
261
|
+
return set;
|
|
262
|
+
}
|
|
213
263
|
let l = array.length;
|
|
214
264
|
while (l--) {
|
|
215
265
|
let element = array[l];
|
|
@@ -250,10 +300,13 @@ var purify = {exports: {}};
|
|
|
250
300
|
*/
|
|
251
301
|
function clone(object) {
|
|
252
302
|
const newObject = create(null);
|
|
253
|
-
for (const
|
|
303
|
+
for (const _ref2 of entries(object)) {
|
|
304
|
+
var _ref3 = _slicedToArray(_ref2, 2);
|
|
305
|
+
const property = _ref3[0];
|
|
306
|
+
const value = _ref3[1];
|
|
254
307
|
const isPropertyExist = objectHasOwnProperty(object, property);
|
|
255
308
|
if (isPropertyExist) {
|
|
256
|
-
if (
|
|
309
|
+
if (arrayIsArray(value)) {
|
|
257
310
|
newObject[property] = cleanArray(value);
|
|
258
311
|
} else if (value && typeof value === 'object' && value.constructor === Object) {
|
|
259
312
|
newObject[property] = clone(value);
|
|
@@ -264,6 +317,58 @@ var purify = {exports: {}};
|
|
|
264
317
|
}
|
|
265
318
|
return newObject;
|
|
266
319
|
}
|
|
320
|
+
/**
|
|
321
|
+
* Convert non-node values into strings without depending on direct property access.
|
|
322
|
+
*
|
|
323
|
+
* @param value - The value to stringify.
|
|
324
|
+
* @returns A string representation of the provided value.
|
|
325
|
+
*/
|
|
326
|
+
function stringifyValue(value) {
|
|
327
|
+
switch (typeof value) {
|
|
328
|
+
case 'string':
|
|
329
|
+
{
|
|
330
|
+
return value;
|
|
331
|
+
}
|
|
332
|
+
case 'number':
|
|
333
|
+
{
|
|
334
|
+
return numberToString(value);
|
|
335
|
+
}
|
|
336
|
+
case 'boolean':
|
|
337
|
+
{
|
|
338
|
+
return booleanToString(value);
|
|
339
|
+
}
|
|
340
|
+
case 'bigint':
|
|
341
|
+
{
|
|
342
|
+
return bigintToString ? bigintToString(value) : '0';
|
|
343
|
+
}
|
|
344
|
+
case 'symbol':
|
|
345
|
+
{
|
|
346
|
+
return symbolToString ? symbolToString(value) : 'Symbol()';
|
|
347
|
+
}
|
|
348
|
+
case 'undefined':
|
|
349
|
+
{
|
|
350
|
+
return objectToString(value);
|
|
351
|
+
}
|
|
352
|
+
case 'function':
|
|
353
|
+
case 'object':
|
|
354
|
+
{
|
|
355
|
+
if (value === null) {
|
|
356
|
+
return objectToString(value);
|
|
357
|
+
}
|
|
358
|
+
const valueAsRecord = value;
|
|
359
|
+
const valueToString = lookupGetter(valueAsRecord, 'toString');
|
|
360
|
+
if (typeof valueToString === 'function') {
|
|
361
|
+
const stringified = valueToString(valueAsRecord);
|
|
362
|
+
return typeof stringified === 'string' ? stringified : objectToString(stringified);
|
|
363
|
+
}
|
|
364
|
+
return objectToString(value);
|
|
365
|
+
}
|
|
366
|
+
default:
|
|
367
|
+
{
|
|
368
|
+
return objectToString(value);
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
}
|
|
267
372
|
/**
|
|
268
373
|
* This method automatically checks if the prop is function or getter and behaves accordingly.
|
|
269
374
|
*
|
|
@@ -289,6 +394,14 @@ var purify = {exports: {}};
|
|
|
289
394
|
}
|
|
290
395
|
return fallbackValue;
|
|
291
396
|
}
|
|
397
|
+
function isRegex(value) {
|
|
398
|
+
try {
|
|
399
|
+
regExpTest(value, '');
|
|
400
|
+
return true;
|
|
401
|
+
} catch (_unused) {
|
|
402
|
+
return false;
|
|
403
|
+
}
|
|
404
|
+
}
|
|
292
405
|
|
|
293
406
|
const html$1 = freeze(['a', 'abbr', 'acronym', 'address', 'area', 'article', 'aside', 'audio', 'b', 'bdi', 'bdo', 'big', 'blink', 'blockquote', 'body', 'br', 'button', 'canvas', 'caption', 'center', 'cite', 'code', 'col', 'colgroup', 'content', 'data', 'datalist', 'dd', 'decorator', 'del', 'details', 'dfn', 'dialog', 'dir', 'div', 'dl', 'dt', 'element', 'em', 'fieldset', 'figcaption', 'figure', 'font', 'footer', 'form', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'head', 'header', 'hgroup', 'hr', 'html', 'i', 'img', 'input', 'ins', 'kbd', 'label', 'legend', 'li', 'main', 'map', 'mark', 'marquee', 'menu', 'menuitem', 'meter', 'nav', 'nobr', 'ol', 'optgroup', 'option', 'output', 'p', 'picture', 'pre', 'progress', 'q', 'rp', 'rt', 'ruby', 's', 'samp', 'search', 'section', 'select', 'shadow', 'slot', 'small', 'source', 'spacer', 'span', 'strike', 'strong', 'style', 'sub', 'summary', 'sup', 'table', 'tbody', 'td', 'template', 'textarea', 'tfoot', 'th', 'thead', 'time', 'tr', 'track', 'tt', 'u', 'ul', 'var', 'video', 'wbr']);
|
|
294
407
|
const svg$1 = freeze(['svg', 'a', 'altglyph', 'altglyphdef', 'altglyphitem', 'animatecolor', 'animatemotion', 'animatetransform', 'circle', 'clippath', 'defs', 'desc', 'ellipse', 'enterkeyhint', 'exportparts', 'filter', 'font', 'g', 'glyph', 'glyphref', 'hkern', 'image', 'inputmode', 'line', 'lineargradient', 'marker', 'mask', 'metadata', 'mpath', 'part', 'path', 'pattern', 'polygon', 'polyline', 'radialgradient', 'rect', 'stop', 'style', 'switch', 'symbol', 'text', 'textpath', 'title', 'tref', 'tspan', 'view', 'vkern']);
|
|
@@ -304,15 +417,14 @@ var purify = {exports: {}};
|
|
|
304
417
|
const mathMlDisallowed = freeze(['maction', 'maligngroup', 'malignmark', 'mlongdiv', 'mscarries', 'mscarry', 'msgroup', 'mstack', 'msline', 'msrow', 'semantics', 'annotation', 'annotation-xml', 'mprescripts', 'none']);
|
|
305
418
|
const text = freeze(['#text']);
|
|
306
419
|
|
|
307
|
-
const html = freeze(['accept', 'action', 'align', 'alt', 'autocapitalize', 'autocomplete', 'autopictureinpicture', 'autoplay', 'background', 'bgcolor', 'border', 'capture', 'cellpadding', 'cellspacing', 'checked', 'cite', 'class', 'clear', 'color', 'cols', 'colspan', 'controls', 'controlslist', 'coords', 'crossorigin', 'datetime', 'decoding', 'default', 'dir', 'disabled', 'disablepictureinpicture', 'disableremoteplayback', 'download', 'draggable', 'enctype', 'enterkeyhint', 'exportparts', 'face', 'for', 'headers', 'height', 'hidden', 'high', 'href', 'hreflang', 'id', 'inert', 'inputmode', 'integrity', 'ismap', 'kind', 'label', 'lang', 'list', 'loading', 'loop', 'low', 'max', 'maxlength', 'media', 'method', 'min', 'minlength', 'multiple', 'muted', 'name', 'nonce', 'noshade', 'novalidate', 'nowrap', 'open', 'optimum', 'part', 'pattern', 'placeholder', 'playsinline', 'popover', 'popovertarget', 'popovertargetaction', 'poster', 'preload', 'pubdate', 'radiogroup', 'readonly', 'rel', 'required', 'rev', 'reversed', 'role', 'rows', 'rowspan', 'spellcheck', 'scope', 'selected', 'shape', 'size', 'sizes', 'slot', 'span', 'srclang', 'start', 'src', 'srcset', 'step', 'style', 'summary', 'tabindex', 'title', 'translate', 'type', 'usemap', 'valign', 'value', 'width', 'wrap', 'xmlns'
|
|
308
|
-
const svg = freeze(['accent-height', 'accumulate', 'additive', 'alignment-baseline', 'amplitude', 'ascent', 'attributename', 'attributetype', 'azimuth', 'basefrequency', 'baseline-shift', 'begin', 'bias', 'by', 'class', 'clip', 'clippathunits', 'clip-path', 'clip-rule', 'color', 'color-interpolation', 'color-interpolation-filters', 'color-profile', 'color-rendering', 'cx', 'cy', 'd', 'dx', 'dy', 'diffuseconstant', 'direction', 'display', 'divisor', 'dur', 'edgemode', 'elevation', 'end', 'exponent', 'fill', 'fill-opacity', 'fill-rule', 'filter', 'filterunits', 'flood-color', 'flood-opacity', 'font-family', 'font-size', 'font-size-adjust', 'font-stretch', 'font-style', 'font-variant', 'font-weight', 'fx', 'fy', 'g1', 'g2', 'glyph-name', 'glyphref', 'gradientunits', 'gradienttransform', 'height', 'href', 'id', 'image-rendering', 'in', 'in2', 'intercept', 'k', 'k1', 'k2', 'k3', 'k4', 'kerning', 'keypoints', 'keysplines', 'keytimes', 'lang', 'lengthadjust', 'letter-spacing', 'kernelmatrix', 'kernelunitlength', 'lighting-color', 'local', 'marker-end', 'marker-mid', 'marker-start', 'markerheight', 'markerunits', 'markerwidth', 'maskcontentunits', 'maskunits', 'max', 'mask', 'mask-type', 'media', 'method', 'mode', 'min', 'name', 'numoctaves', 'offset', 'operator', 'opacity', 'order', 'orient', 'orientation', 'origin', 'overflow', 'paint-order', 'path', 'pathlength', 'patterncontentunits', 'patterntransform', 'patternunits', 'points', 'preservealpha', 'preserveaspectratio', 'primitiveunits', 'r', 'rx', 'ry', 'radius', 'refx', 'refy', 'repeatcount', 'repeatdur', 'restart', 'result', 'rotate', 'scale', 'seed', 'shape-rendering', 'slope', 'specularconstant', 'specularexponent', 'spreadmethod', 'startoffset', 'stddeviation', 'stitchtiles', 'stop-color', 'stop-opacity', 'stroke-dasharray', 'stroke-dashoffset', 'stroke-linecap', 'stroke-linejoin', 'stroke-miterlimit', 'stroke-opacity', 'stroke', 'stroke-width', 'style', 'surfacescale', 'systemlanguage', 'tabindex', 'tablevalues', 'targetx', 'targety', 'transform', 'transform-origin', 'text-anchor', 'text-decoration', 'text-rendering', 'textlength', 'type', 'u1', 'u2', 'unicode', 'values', 'viewbox', 'visibility', 'version', 'vert-adv-y', 'vert-origin-x', 'vert-origin-y', 'width', 'word-spacing', 'wrap', 'writing-mode', 'xchannelselector', 'ychannelselector', 'x', 'x1', 'x2', 'xmlns', 'y', 'y1', 'y2', 'z', 'zoomandpan']);
|
|
420
|
+
const html = freeze(['accept', 'action', 'align', 'alt', 'autocapitalize', 'autocomplete', 'autopictureinpicture', 'autoplay', 'background', 'bgcolor', 'border', 'capture', 'cellpadding', 'cellspacing', 'checked', 'cite', 'class', 'clear', 'color', 'cols', 'colspan', 'command', 'commandfor', 'controls', 'controlslist', 'coords', 'crossorigin', 'datetime', 'decoding', 'default', 'dir', 'disabled', 'disablepictureinpicture', 'disableremoteplayback', 'download', 'draggable', 'enctype', 'enterkeyhint', 'exportparts', 'face', 'for', 'headers', 'height', 'hidden', 'high', 'href', 'hreflang', 'id', 'inert', 'inputmode', 'integrity', 'ismap', 'kind', 'label', 'lang', 'list', 'loading', 'loop', 'low', 'max', 'maxlength', 'media', 'method', 'min', 'minlength', 'multiple', 'muted', 'name', 'nonce', 'noshade', 'novalidate', 'nowrap', 'open', 'optimum', 'part', 'pattern', 'placeholder', 'playsinline', 'popover', 'popovertarget', 'popovertargetaction', 'poster', 'preload', 'pubdate', 'radiogroup', 'readonly', 'rel', 'required', 'rev', 'reversed', 'role', 'rows', 'rowspan', 'spellcheck', 'scope', 'selected', 'shape', 'size', 'sizes', 'slot', 'span', 'srclang', 'start', 'src', 'srcset', 'step', 'style', 'summary', 'tabindex', 'title', 'translate', 'type', 'usemap', 'valign', 'value', 'width', 'wrap', 'xmlns']);
|
|
421
|
+
const svg = freeze(['accent-height', 'accumulate', 'additive', 'alignment-baseline', 'amplitude', 'ascent', 'attributename', 'attributetype', 'azimuth', 'basefrequency', 'baseline-shift', 'begin', 'bias', 'by', 'class', 'clip', 'clippathunits', 'clip-path', 'clip-rule', 'color', 'color-interpolation', 'color-interpolation-filters', 'color-profile', 'color-rendering', 'cx', 'cy', 'd', 'dx', 'dy', 'diffuseconstant', 'direction', 'display', 'divisor', 'dominant-baseline', 'dur', 'edgemode', 'elevation', 'end', 'exponent', 'fill', 'fill-opacity', 'fill-rule', 'filter', 'filterunits', 'flood-color', 'flood-opacity', 'font-family', 'font-size', 'font-size-adjust', 'font-stretch', 'font-style', 'font-variant', 'font-weight', 'fx', 'fy', 'g1', 'g2', 'glyph-name', 'glyphref', 'gradientunits', 'gradienttransform', 'height', 'href', 'id', 'image-rendering', 'in', 'in2', 'intercept', 'k', 'k1', 'k2', 'k3', 'k4', 'kerning', 'keypoints', 'keysplines', 'keytimes', 'lang', 'lengthadjust', 'letter-spacing', 'kernelmatrix', 'kernelunitlength', 'lighting-color', 'local', 'marker-end', 'marker-mid', 'marker-start', 'markerheight', 'markerunits', 'markerwidth', 'maskcontentunits', 'maskunits', 'max', 'mask', 'mask-type', 'media', 'method', 'mode', 'min', 'name', 'numoctaves', 'offset', 'operator', 'opacity', 'order', 'orient', 'orientation', 'origin', 'overflow', 'paint-order', 'path', 'pathlength', 'patterncontentunits', 'patterntransform', 'patternunits', 'points', 'preservealpha', 'preserveaspectratio', 'primitiveunits', 'r', 'rx', 'ry', 'radius', 'refx', 'refy', 'repeatcount', 'repeatdur', 'restart', 'result', 'rotate', 'scale', 'seed', 'shape-rendering', 'slope', 'specularconstant', 'specularexponent', 'spreadmethod', 'startoffset', 'stddeviation', 'stitchtiles', 'stop-color', 'stop-opacity', 'stroke-dasharray', 'stroke-dashoffset', 'stroke-linecap', 'stroke-linejoin', 'stroke-miterlimit', 'stroke-opacity', 'stroke', 'stroke-width', 'style', 'surfacescale', 'systemlanguage', 'tabindex', 'tablevalues', 'targetx', 'targety', 'transform', 'transform-origin', 'text-anchor', 'text-decoration', 'text-orientation', 'text-rendering', 'textlength', 'type', 'u1', 'u2', 'unicode', 'values', 'viewbox', 'visibility', 'version', 'vert-adv-y', 'vert-origin-x', 'vert-origin-y', 'width', 'word-spacing', 'wrap', 'writing-mode', 'xchannelselector', 'ychannelselector', 'x', 'x1', 'x2', 'xmlns', 'y', 'y1', 'y2', 'z', 'zoomandpan']);
|
|
309
422
|
const mathMl = freeze(['accent', 'accentunder', 'align', 'bevelled', 'close', 'columnalign', 'columnlines', 'columnspacing', 'columnspan', 'denomalign', 'depth', 'dir', 'display', 'displaystyle', 'encoding', 'fence', 'frame', 'height', 'href', 'id', 'largeop', 'length', 'linethickness', 'lquote', 'lspace', 'mathbackground', 'mathcolor', 'mathsize', 'mathvariant', 'maxsize', 'minsize', 'movablelimits', 'notation', 'numalign', 'open', 'rowalign', 'rowlines', 'rowspacing', 'rowspan', 'rspace', 'rquote', 'scriptlevel', 'scriptminsize', 'scriptsizemultiplier', 'selection', 'separator', 'separators', 'stretchy', 'subscriptshift', 'supscriptshift', 'symmetric', 'voffset', 'width', 'xmlns']);
|
|
310
423
|
const xml = freeze(['xlink:href', 'xml:id', 'xlink:title', 'xml:space', 'xmlns:xlink']);
|
|
311
424
|
|
|
312
|
-
|
|
313
|
-
const
|
|
314
|
-
const
|
|
315
|
-
const TMPLIT_EXPR = seal(/\$\{[\w\W]*/gm); // eslint-disable-line unicorn/better-regex
|
|
425
|
+
const MUSTACHE_EXPR = seal(/{{[\w\W]*|^[\w\W]*}}/g);
|
|
426
|
+
const ERB_EXPR = seal(/<%[\w\W]*|^[\w\W]*%>/g);
|
|
427
|
+
const TMPLIT_EXPR = seal(/\${[\w\W]*/g);
|
|
316
428
|
const DATA_ATTR = seal(/^data-[\-\w.\u00B7-\uFFFF]+$/); // eslint-disable-line no-useless-escape
|
|
317
429
|
const ARIA_ATTR = seal(/^aria-[\-\w]+$/); // eslint-disable-line no-useless-escape
|
|
318
430
|
const IS_ALLOWED_URI = seal(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i // eslint-disable-line no-useless-escape
|
|
@@ -322,30 +434,31 @@ var purify = {exports: {}};
|
|
|
322
434
|
);
|
|
323
435
|
const DOCTYPE_NAME = seal(/^html$/i);
|
|
324
436
|
const CUSTOM_ELEMENT = seal(/^[a-z][.\w]*(-[.\w]+)+$/i);
|
|
437
|
+
// Markup-significant character probes used by _sanitizeElements.
|
|
438
|
+
// Shared module-level instances are safe despite the sticky /g flags:
|
|
439
|
+
// unapply() resets lastIndex for RegExp receivers before every call.
|
|
440
|
+
const ELEMENT_MARKUP_PROBE = seal(/<[/\w!]/g);
|
|
441
|
+
const COMMENT_MARKUP_PROBE = seal(/<[/\w]/g);
|
|
442
|
+
const FALLBACK_TAG_CLOSE = seal(/<\/no(script|embed|frames)/i);
|
|
443
|
+
const SELF_CLOSING_TAG = seal(/\/>/i);
|
|
325
444
|
|
|
326
|
-
var EXPRESSIONS = /*#__PURE__*/Object.freeze({
|
|
327
|
-
__proto__: null,
|
|
328
|
-
ARIA_ATTR: ARIA_ATTR,
|
|
329
|
-
ATTR_WHITESPACE: ATTR_WHITESPACE,
|
|
330
|
-
CUSTOM_ELEMENT: CUSTOM_ELEMENT,
|
|
331
|
-
DATA_ATTR: DATA_ATTR,
|
|
332
|
-
DOCTYPE_NAME: DOCTYPE_NAME,
|
|
333
|
-
ERB_EXPR: ERB_EXPR,
|
|
334
|
-
IS_ALLOWED_URI: IS_ALLOWED_URI,
|
|
335
|
-
IS_SCRIPT_OR_DATA: IS_SCRIPT_OR_DATA,
|
|
336
|
-
MUSTACHE_EXPR: MUSTACHE_EXPR,
|
|
337
|
-
TMPLIT_EXPR: TMPLIT_EXPR
|
|
338
|
-
});
|
|
339
|
-
|
|
340
|
-
/* eslint-disable @typescript-eslint/indent */
|
|
341
445
|
// https://developer.mozilla.org/en-US/docs/Web/API/Node/nodeType
|
|
342
446
|
const NODE_TYPE = {
|
|
343
447
|
element: 1,
|
|
448
|
+
attribute: 2,
|
|
344
449
|
text: 3,
|
|
450
|
+
cdataSection: 4,
|
|
451
|
+
entityReference: 5,
|
|
345
452
|
// Deprecated
|
|
346
|
-
|
|
453
|
+
entityNode: 6,
|
|
454
|
+
// Deprecated
|
|
455
|
+
processingInstruction: 7,
|
|
347
456
|
comment: 8,
|
|
348
|
-
document: 9
|
|
457
|
+
document: 9,
|
|
458
|
+
documentType: 10,
|
|
459
|
+
documentFragment: 11,
|
|
460
|
+
notation: 12 // Deprecated
|
|
461
|
+
};
|
|
349
462
|
const getGlobal = function getGlobal() {
|
|
350
463
|
return typeof window === 'undefined' ? null : window;
|
|
351
464
|
};
|
|
@@ -400,10 +513,25 @@ var purify = {exports: {}};
|
|
|
400
513
|
uponSanitizeShadowNode: []
|
|
401
514
|
};
|
|
402
515
|
};
|
|
516
|
+
/**
|
|
517
|
+
* Resolve a set-valued configuration option: a fresh set built from
|
|
518
|
+
* cfg[key] when it is an own array property (seeded with a clone of
|
|
519
|
+
* options.base when given, case-normalized via options.transform),
|
|
520
|
+
* the fallback set otherwise.
|
|
521
|
+
*
|
|
522
|
+
* @param cfg the cloned, prototype-free configuration object
|
|
523
|
+
* @param key the configuration property to read
|
|
524
|
+
* @param fallback the set to use when the option is absent or not an array
|
|
525
|
+
* @param options transform and optional base set to merge into
|
|
526
|
+
* @returns the resolved set
|
|
527
|
+
*/
|
|
528
|
+
const _resolveSetOption = function _resolveSetOption(cfg, key, fallback, options) {
|
|
529
|
+
return objectHasOwnProperty(cfg, key) && arrayIsArray(cfg[key]) ? addToSet(options.base ? clone(options.base) : {}, cfg[key], options.transform) : fallback;
|
|
530
|
+
};
|
|
403
531
|
function createDOMPurify() {
|
|
404
532
|
let window = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : getGlobal();
|
|
405
533
|
const DOMPurify = root => createDOMPurify(root);
|
|
406
|
-
DOMPurify.version = '3.4.
|
|
534
|
+
DOMPurify.version = '3.4.13';
|
|
407
535
|
DOMPurify.removed = [];
|
|
408
536
|
if (!window || !window.document || window.document.nodeType !== NODE_TYPE.document || !window.Element) {
|
|
409
537
|
// Not running in a browser, provide a factory function
|
|
@@ -411,28 +539,26 @@ var purify = {exports: {}};
|
|
|
411
539
|
DOMPurify.isSupported = false;
|
|
412
540
|
return DOMPurify;
|
|
413
541
|
}
|
|
414
|
-
let
|
|
415
|
-
document
|
|
416
|
-
} = window;
|
|
542
|
+
let document = window.document;
|
|
417
543
|
const originalDocument = document;
|
|
418
544
|
const currentScript = originalDocument.currentScript;
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
NamedNodeMap = window.NamedNodeMap || window.MozNamedAttrMap,
|
|
426
|
-
HTMLFormElement,
|
|
427
|
-
DOMParser,
|
|
428
|
-
trustedTypes
|
|
429
|
-
} = window;
|
|
545
|
+
const HTMLTemplateElement = window.HTMLTemplateElement,
|
|
546
|
+
Node = window.Node,
|
|
547
|
+
Element = window.Element,
|
|
548
|
+
NodeFilter = window.NodeFilter;
|
|
549
|
+
const DOMParser = window.DOMParser,
|
|
550
|
+
trustedTypes = window.trustedTypes;
|
|
430
551
|
const ElementPrototype = Element.prototype;
|
|
431
552
|
const cloneNode = lookupGetter(ElementPrototype, 'cloneNode');
|
|
432
553
|
const remove = lookupGetter(ElementPrototype, 'remove');
|
|
433
554
|
const getNextSibling = lookupGetter(ElementPrototype, 'nextSibling');
|
|
434
555
|
const getChildNodes = lookupGetter(ElementPrototype, 'childNodes');
|
|
435
556
|
const getParentNode = lookupGetter(ElementPrototype, 'parentNode');
|
|
557
|
+
const getShadowRoot = lookupGetter(ElementPrototype, 'shadowRoot');
|
|
558
|
+
const getAttributes = lookupGetter(ElementPrototype, 'attributes');
|
|
559
|
+
const getNodeType = Node && Node.prototype ? lookupGetter(Node.prototype, 'nodeType') : null;
|
|
560
|
+
const getNodeName = Node && Node.prototype ? lookupGetter(Node.prototype, 'nodeName') : null;
|
|
561
|
+
const getOwnerDocument = Node && Node.prototype ? lookupGetter(Node.prototype, 'ownerDocument') : null;
|
|
436
562
|
// As per issue #47, the web-components registry is inherited by a
|
|
437
563
|
// new document created via createHTMLDocument. As per the spec
|
|
438
564
|
// (http://w3c.github.io/webcomponents/spec/custom/#creating-and-passing-registries)
|
|
@@ -447,33 +573,74 @@ var purify = {exports: {}};
|
|
|
447
573
|
}
|
|
448
574
|
let trustedTypesPolicy;
|
|
449
575
|
let emptyHTML = '';
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
576
|
+
// The instance's own internal Trusted Types policy. Unlike a caller-supplied
|
|
577
|
+
// `TRUSTED_TYPES_POLICY`, this is created at most once — Trusted Types throws
|
|
578
|
+
// on duplicate policy names — and is the only policy allowed to persist
|
|
579
|
+
// across configurations and survive `clearConfig()`.
|
|
580
|
+
let defaultTrustedTypesPolicy;
|
|
581
|
+
let defaultTrustedTypesPolicyResolved = false;
|
|
582
|
+
// Tracks whether we are already inside a call to the configured Trusted Types
|
|
583
|
+
// policy (`createHTML` or `createScriptURL`). If a supplied policy callback
|
|
584
|
+
// itself calls `DOMPurify.sanitize` (the cause of #1422), `sanitize` would
|
|
585
|
+
// re-enter the policy and recurse until the stack overflows. We detect that
|
|
586
|
+
// re-entry and throw a clear, actionable error instead. The guard is shared
|
|
587
|
+
// across both callbacks, because either one re-entering `sanitize` triggers
|
|
588
|
+
// the same unbounded recursion.
|
|
589
|
+
let IN_TRUSTED_TYPES_POLICY = 0;
|
|
590
|
+
const _assertNotInTrustedTypesPolicy = function _assertNotInTrustedTypesPolicy() {
|
|
591
|
+
if (IN_TRUSTED_TYPES_POLICY > 0) {
|
|
592
|
+
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.');
|
|
593
|
+
}
|
|
594
|
+
};
|
|
595
|
+
const _createTrustedHTML = function _createTrustedHTML(html) {
|
|
596
|
+
_assertNotInTrustedTypesPolicy();
|
|
597
|
+
IN_TRUSTED_TYPES_POLICY++;
|
|
598
|
+
try {
|
|
599
|
+
return trustedTypesPolicy.createHTML(html);
|
|
600
|
+
} finally {
|
|
601
|
+
IN_TRUSTED_TYPES_POLICY--;
|
|
602
|
+
}
|
|
603
|
+
};
|
|
604
|
+
const _createTrustedScriptURL = function _createTrustedScriptURL(scriptUrl) {
|
|
605
|
+
_assertNotInTrustedTypesPolicy();
|
|
606
|
+
IN_TRUSTED_TYPES_POLICY++;
|
|
607
|
+
try {
|
|
608
|
+
return trustedTypesPolicy.createScriptURL(scriptUrl);
|
|
609
|
+
} finally {
|
|
610
|
+
IN_TRUSTED_TYPES_POLICY--;
|
|
611
|
+
}
|
|
612
|
+
};
|
|
613
|
+
// Lazily resolve (and cache) the instance's internal default policy.
|
|
614
|
+
// Resolution is attempted at most once: a successful `createPolicy` cannot be
|
|
615
|
+
// repeated (Trusted Types throws on duplicate names), and a failed or
|
|
616
|
+
// unsupported attempt must not be retried on every parse.
|
|
617
|
+
const _getDefaultTrustedTypesPolicy = function _getDefaultTrustedTypesPolicy() {
|
|
618
|
+
if (!defaultTrustedTypesPolicyResolved) {
|
|
619
|
+
defaultTrustedTypesPolicy = _createTrustedTypesPolicy(trustedTypes, currentScript);
|
|
620
|
+
defaultTrustedTypesPolicyResolved = true;
|
|
621
|
+
}
|
|
622
|
+
return defaultTrustedTypesPolicy;
|
|
623
|
+
};
|
|
624
|
+
const _document = document,
|
|
625
|
+
implementation = _document.implementation,
|
|
626
|
+
createNodeIterator = _document.createNodeIterator,
|
|
627
|
+
createDocumentFragment = _document.createDocumentFragment,
|
|
628
|
+
getElementsByTagName = _document.getElementsByTagName;
|
|
629
|
+
const importNode = originalDocument.importNode;
|
|
459
630
|
let hooks = _createHooksMap();
|
|
460
631
|
/**
|
|
461
632
|
* Expose whether this browser supports running the full DOMPurify.
|
|
462
633
|
*/
|
|
463
634
|
DOMPurify.isSupported = typeof entries === 'function' && typeof getParentNode === 'function' && implementation && implementation.createHTMLDocument !== undefined;
|
|
464
|
-
const
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
} = EXPRESSIONS;
|
|
474
|
-
let {
|
|
475
|
-
IS_ALLOWED_URI: IS_ALLOWED_URI$1
|
|
476
|
-
} = EXPRESSIONS;
|
|
635
|
+
const MUSTACHE_EXPR$1 = MUSTACHE_EXPR,
|
|
636
|
+
ERB_EXPR$1 = ERB_EXPR,
|
|
637
|
+
TMPLIT_EXPR$1 = TMPLIT_EXPR,
|
|
638
|
+
DATA_ATTR$1 = DATA_ATTR,
|
|
639
|
+
ARIA_ATTR$1 = ARIA_ATTR,
|
|
640
|
+
IS_SCRIPT_OR_DATA$1 = IS_SCRIPT_OR_DATA,
|
|
641
|
+
ATTR_WHITESPACE$1 = ATTR_WHITESPACE,
|
|
642
|
+
CUSTOM_ELEMENT$1 = CUSTOM_ELEMENT;
|
|
643
|
+
let IS_ALLOWED_URI$1 = IS_ALLOWED_URI;
|
|
477
644
|
/**
|
|
478
645
|
* We consider the elements and attributes below to be safe. Ideally
|
|
479
646
|
* don't add any new ones but feel free to remove unwanted ones.
|
|
@@ -550,6 +717,13 @@ var purify = {exports: {}};
|
|
|
550
717
|
let WHOLE_DOCUMENT = false;
|
|
551
718
|
/* Track whether config is already set on this instance of DOMPurify. */
|
|
552
719
|
let SET_CONFIG = false;
|
|
720
|
+
/* Pristine allowlist bindings captured at setConfig() time. On the
|
|
721
|
+
* persistent-config path sanitize() restores the sets from these before
|
|
722
|
+
* the per-walk hook clone-guard, so a hook's in-call widening cannot
|
|
723
|
+
* carry across calls. Null until setConfig() is called; reset by
|
|
724
|
+
* clearConfig(). */
|
|
725
|
+
let SET_CONFIG_ALLOWED_TAGS = null;
|
|
726
|
+
let SET_CONFIG_ALLOWED_ATTR = null;
|
|
553
727
|
/* Decide if all elements (e.g. style, script) must be children of
|
|
554
728
|
* document.body. By default, browsers might move them to document.head */
|
|
555
729
|
let FORCE_BODY = false;
|
|
@@ -592,7 +766,17 @@ var purify = {exports: {}};
|
|
|
592
766
|
let USE_PROFILES = {};
|
|
593
767
|
/* Tags to ignore content of when KEEP_CONTENT is true */
|
|
594
768
|
let FORBID_CONTENTS = null;
|
|
595
|
-
const DEFAULT_FORBID_CONTENTS = addToSet({}, ['annotation-xml', 'audio', 'colgroup', 'desc', 'foreignobject', 'head', 'iframe', 'math', 'mi', 'mn', 'mo', 'ms', 'mtext', 'noembed', 'noframes', 'noscript', 'plaintext', 'script',
|
|
769
|
+
const DEFAULT_FORBID_CONTENTS = addToSet({}, ['annotation-xml', 'audio', 'colgroup', 'desc', 'foreignobject', 'head', 'iframe', 'math', 'mi', 'mn', 'mo', 'ms', 'mtext', 'noembed', 'noframes', 'noscript', 'plaintext', 'script',
|
|
770
|
+
// <selectedcontent> mirrors the selected <option>'s subtree, cloned by
|
|
771
|
+
// the UA (customizable <select>) — including any on* handlers — and the
|
|
772
|
+
// engine re-mirrors synchronously whenever a removal changes which
|
|
773
|
+
// option/selectedcontent is current, even inside DOMPurify's inert
|
|
774
|
+
// DOMParser document. Hoisting its children on removal re-inserts a fresh
|
|
775
|
+
// mirror target ahead of the walk, which the engine refills, looping
|
|
776
|
+
// forever (DoS) and amplifying output. Dropping its content on removal
|
|
777
|
+
// (rather than hoisting) breaks that cascade; the content is a duplicate
|
|
778
|
+
// of the option, which is sanitized on its own. See campaign-3 F1/F6.
|
|
779
|
+
'selectedcontent', 'style', 'svg', 'template', 'thead', 'title', 'video', 'xmp']);
|
|
596
780
|
/* Tags that are safe for data: URIs */
|
|
597
781
|
let DATA_URI_TAGS = null;
|
|
598
782
|
const DEFAULT_DATA_URI_TAGS = addToSet({}, ['audio', 'video', 'img', 'source', 'image', 'track']);
|
|
@@ -608,8 +792,10 @@ var purify = {exports: {}};
|
|
|
608
792
|
/* Allowed XHTML+XML namespaces */
|
|
609
793
|
let ALLOWED_NAMESPACES = null;
|
|
610
794
|
const DEFAULT_ALLOWED_NAMESPACES = addToSet({}, [MATHML_NAMESPACE, SVG_NAMESPACE, HTML_NAMESPACE], stringToString);
|
|
611
|
-
|
|
612
|
-
let
|
|
795
|
+
const DEFAULT_MATHML_TEXT_INTEGRATION_POINTS = freeze(['mi', 'mo', 'mn', 'ms', 'mtext']);
|
|
796
|
+
let MATHML_TEXT_INTEGRATION_POINTS = addToSet({}, DEFAULT_MATHML_TEXT_INTEGRATION_POINTS);
|
|
797
|
+
const DEFAULT_HTML_INTEGRATION_POINTS = freeze(['annotation-xml']);
|
|
798
|
+
let HTML_INTEGRATION_POINTS = addToSet({}, DEFAULT_HTML_INTEGRATION_POINTS);
|
|
613
799
|
// Certain elements are allowed in both SVG and HTML
|
|
614
800
|
// namespace. We need to specify them explicitly
|
|
615
801
|
// so that they don't get erroneously deleted from
|
|
@@ -651,15 +837,33 @@ var purify = {exports: {}};
|
|
|
651
837
|
// HTML tags and attributes are not case-sensitive, converting to lowercase. Keeping XHTML as is.
|
|
652
838
|
transformCaseFunc = PARSER_MEDIA_TYPE === 'application/xhtml+xml' ? stringToString : stringToLowerCase;
|
|
653
839
|
/* Set configuration parameters */
|
|
654
|
-
ALLOWED_TAGS =
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
840
|
+
ALLOWED_TAGS = _resolveSetOption(cfg, 'ALLOWED_TAGS', DEFAULT_ALLOWED_TAGS, {
|
|
841
|
+
transform: transformCaseFunc
|
|
842
|
+
});
|
|
843
|
+
ALLOWED_ATTR = _resolveSetOption(cfg, 'ALLOWED_ATTR', DEFAULT_ALLOWED_ATTR, {
|
|
844
|
+
transform: transformCaseFunc
|
|
845
|
+
});
|
|
846
|
+
ALLOWED_NAMESPACES = _resolveSetOption(cfg, 'ALLOWED_NAMESPACES', DEFAULT_ALLOWED_NAMESPACES, {
|
|
847
|
+
transform: stringToString
|
|
848
|
+
});
|
|
849
|
+
URI_SAFE_ATTRIBUTES = _resolveSetOption(cfg, 'ADD_URI_SAFE_ATTR', DEFAULT_URI_SAFE_ATTRIBUTES, {
|
|
850
|
+
transform: transformCaseFunc,
|
|
851
|
+
base: DEFAULT_URI_SAFE_ATTRIBUTES
|
|
852
|
+
});
|
|
853
|
+
DATA_URI_TAGS = _resolveSetOption(cfg, 'ADD_DATA_URI_TAGS', DEFAULT_DATA_URI_TAGS, {
|
|
854
|
+
transform: transformCaseFunc,
|
|
855
|
+
base: DEFAULT_DATA_URI_TAGS
|
|
856
|
+
});
|
|
857
|
+
FORBID_CONTENTS = _resolveSetOption(cfg, 'FORBID_CONTENTS', DEFAULT_FORBID_CONTENTS, {
|
|
858
|
+
transform: transformCaseFunc
|
|
859
|
+
});
|
|
860
|
+
FORBID_TAGS = _resolveSetOption(cfg, 'FORBID_TAGS', clone({}), {
|
|
861
|
+
transform: transformCaseFunc
|
|
862
|
+
});
|
|
863
|
+
FORBID_ATTR = _resolveSetOption(cfg, 'FORBID_ATTR', clone({}), {
|
|
864
|
+
transform: transformCaseFunc
|
|
865
|
+
});
|
|
866
|
+
USE_PROFILES = objectHasOwnProperty(cfg, 'USE_PROFILES') ? cfg.USE_PROFILES && typeof cfg.USE_PROFILES === 'object' ? clone(cfg.USE_PROFILES) : cfg.USE_PROFILES : false;
|
|
663
867
|
ALLOW_ARIA_ATTR = cfg.ALLOW_ARIA_ATTR !== false; // Default true
|
|
664
868
|
ALLOW_DATA_ATTR = cfg.ALLOW_DATA_ATTR !== false; // Default true
|
|
665
869
|
ALLOW_UNKNOWN_PROTOCOLS = cfg.ALLOW_UNKNOWN_PROTOCOLS || false; // Default false
|
|
@@ -675,20 +879,22 @@ var purify = {exports: {}};
|
|
|
675
879
|
SANITIZE_NAMED_PROPS = cfg.SANITIZE_NAMED_PROPS || false; // Default false
|
|
676
880
|
KEEP_CONTENT = cfg.KEEP_CONTENT !== false; // Default true
|
|
677
881
|
IN_PLACE = cfg.IN_PLACE || false; // Default false
|
|
678
|
-
IS_ALLOWED_URI$1 = cfg.ALLOWED_URI_REGEXP
|
|
679
|
-
NAMESPACE = cfg.NAMESPACE
|
|
680
|
-
MATHML_TEXT_INTEGRATION_POINTS = cfg.MATHML_TEXT_INTEGRATION_POINTS
|
|
681
|
-
HTML_INTEGRATION_POINTS = cfg.HTML_INTEGRATION_POINTS
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
882
|
+
IS_ALLOWED_URI$1 = isRegex(cfg.ALLOWED_URI_REGEXP) ? cfg.ALLOWED_URI_REGEXP : IS_ALLOWED_URI; // Default regexp
|
|
883
|
+
NAMESPACE = typeof cfg.NAMESPACE === 'string' ? cfg.NAMESPACE : HTML_NAMESPACE; // Default HTML namespace
|
|
884
|
+
MATHML_TEXT_INTEGRATION_POINTS = objectHasOwnProperty(cfg, 'MATHML_TEXT_INTEGRATION_POINTS') && cfg.MATHML_TEXT_INTEGRATION_POINTS && typeof cfg.MATHML_TEXT_INTEGRATION_POINTS === 'object' ? clone(cfg.MATHML_TEXT_INTEGRATION_POINTS) : addToSet({}, DEFAULT_MATHML_TEXT_INTEGRATION_POINTS); // Default built-in map
|
|
885
|
+
HTML_INTEGRATION_POINTS = objectHasOwnProperty(cfg, 'HTML_INTEGRATION_POINTS') && cfg.HTML_INTEGRATION_POINTS && typeof cfg.HTML_INTEGRATION_POINTS === 'object' ? clone(cfg.HTML_INTEGRATION_POINTS) : addToSet({}, DEFAULT_HTML_INTEGRATION_POINTS); // Default built-in map
|
|
886
|
+
const customElementHandling = objectHasOwnProperty(cfg, 'CUSTOM_ELEMENT_HANDLING') && cfg.CUSTOM_ELEMENT_HANDLING && typeof cfg.CUSTOM_ELEMENT_HANDLING === 'object' ? clone(cfg.CUSTOM_ELEMENT_HANDLING) : create(null);
|
|
887
|
+
CUSTOM_ELEMENT_HANDLING = create(null);
|
|
888
|
+
if (objectHasOwnProperty(customElementHandling, 'tagNameCheck') && isRegexOrFunction(customElementHandling.tagNameCheck)) {
|
|
889
|
+
CUSTOM_ELEMENT_HANDLING.tagNameCheck = customElementHandling.tagNameCheck; // Default undefined
|
|
890
|
+
}
|
|
891
|
+
if (objectHasOwnProperty(customElementHandling, 'attributeNameCheck') && isRegexOrFunction(customElementHandling.attributeNameCheck)) {
|
|
892
|
+
CUSTOM_ELEMENT_HANDLING.attributeNameCheck = customElementHandling.attributeNameCheck; // Default undefined
|
|
893
|
+
}
|
|
894
|
+
if (objectHasOwnProperty(customElementHandling, 'allowCustomizedBuiltInElements') && typeof customElementHandling.allowCustomizedBuiltInElements === 'boolean') {
|
|
895
|
+
CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements = customElementHandling.allowCustomizedBuiltInElements; // Default undefined
|
|
896
|
+
}
|
|
897
|
+
seal(CUSTOM_ELEMENT_HANDLING);
|
|
692
898
|
if (SAFE_FOR_TEMPLATES) {
|
|
693
899
|
ALLOW_DATA_ATTR = false;
|
|
694
900
|
}
|
|
@@ -724,36 +930,36 @@ var purify = {exports: {}};
|
|
|
724
930
|
EXTRA_ELEMENT_HANDLING.tagCheck = null;
|
|
725
931
|
EXTRA_ELEMENT_HANDLING.attributeCheck = null;
|
|
726
932
|
/* Merge configuration parameters */
|
|
727
|
-
if (cfg
|
|
933
|
+
if (objectHasOwnProperty(cfg, 'ADD_TAGS')) {
|
|
728
934
|
if (typeof cfg.ADD_TAGS === 'function') {
|
|
729
935
|
EXTRA_ELEMENT_HANDLING.tagCheck = cfg.ADD_TAGS;
|
|
730
|
-
} else {
|
|
936
|
+
} else if (arrayIsArray(cfg.ADD_TAGS)) {
|
|
731
937
|
if (ALLOWED_TAGS === DEFAULT_ALLOWED_TAGS) {
|
|
732
938
|
ALLOWED_TAGS = clone(ALLOWED_TAGS);
|
|
733
939
|
}
|
|
734
940
|
addToSet(ALLOWED_TAGS, cfg.ADD_TAGS, transformCaseFunc);
|
|
735
941
|
}
|
|
736
942
|
}
|
|
737
|
-
if (cfg
|
|
943
|
+
if (objectHasOwnProperty(cfg, 'ADD_ATTR')) {
|
|
738
944
|
if (typeof cfg.ADD_ATTR === 'function') {
|
|
739
945
|
EXTRA_ELEMENT_HANDLING.attributeCheck = cfg.ADD_ATTR;
|
|
740
|
-
} else {
|
|
946
|
+
} else if (arrayIsArray(cfg.ADD_ATTR)) {
|
|
741
947
|
if (ALLOWED_ATTR === DEFAULT_ALLOWED_ATTR) {
|
|
742
948
|
ALLOWED_ATTR = clone(ALLOWED_ATTR);
|
|
743
949
|
}
|
|
744
950
|
addToSet(ALLOWED_ATTR, cfg.ADD_ATTR, transformCaseFunc);
|
|
745
951
|
}
|
|
746
952
|
}
|
|
747
|
-
if (cfg.ADD_URI_SAFE_ATTR) {
|
|
953
|
+
if (objectHasOwnProperty(cfg, 'ADD_URI_SAFE_ATTR') && arrayIsArray(cfg.ADD_URI_SAFE_ATTR)) {
|
|
748
954
|
addToSet(URI_SAFE_ATTRIBUTES, cfg.ADD_URI_SAFE_ATTR, transformCaseFunc);
|
|
749
955
|
}
|
|
750
|
-
if (cfg.FORBID_CONTENTS) {
|
|
956
|
+
if (objectHasOwnProperty(cfg, 'FORBID_CONTENTS') && arrayIsArray(cfg.FORBID_CONTENTS)) {
|
|
751
957
|
if (FORBID_CONTENTS === DEFAULT_FORBID_CONTENTS) {
|
|
752
958
|
FORBID_CONTENTS = clone(FORBID_CONTENTS);
|
|
753
959
|
}
|
|
754
960
|
addToSet(FORBID_CONTENTS, cfg.FORBID_CONTENTS, transformCaseFunc);
|
|
755
961
|
}
|
|
756
|
-
if (cfg.ADD_FORBID_CONTENTS) {
|
|
962
|
+
if (objectHasOwnProperty(cfg, 'ADD_FORBID_CONTENTS') && arrayIsArray(cfg.ADD_FORBID_CONTENTS)) {
|
|
757
963
|
if (FORBID_CONTENTS === DEFAULT_FORBID_CONTENTS) {
|
|
758
964
|
FORBID_CONTENTS = clone(FORBID_CONTENTS);
|
|
759
965
|
}
|
|
@@ -772,6 +978,13 @@ var purify = {exports: {}};
|
|
|
772
978
|
addToSet(ALLOWED_TAGS, ['tbody']);
|
|
773
979
|
delete FORBID_TAGS.tbody;
|
|
774
980
|
}
|
|
981
|
+
// Re-derive the active Trusted Types policy from this configuration on
|
|
982
|
+
// every parse. The active policy must never be sticky closure state that
|
|
983
|
+
// outlives the config that set it: a caller-supplied policy left in place
|
|
984
|
+
// after `clearConfig()` — or after a later call that supplied none, or
|
|
985
|
+
// `TRUSTED_TYPES_POLICY: null` — could sign a subsequent "default"
|
|
986
|
+
// `RETURN_TRUSTED_TYPE` result with a foreign, possibly unsafe policy.
|
|
987
|
+
// See GHSA-vxr8-fq34-vvx9.
|
|
775
988
|
if (cfg.TRUSTED_TYPES_POLICY) {
|
|
776
989
|
if (typeof cfg.TRUSTED_TYPES_POLICY.createHTML !== 'function') {
|
|
777
990
|
throw typeErrorCreate('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');
|
|
@@ -779,18 +992,45 @@ var purify = {exports: {}};
|
|
|
779
992
|
if (typeof cfg.TRUSTED_TYPES_POLICY.createScriptURL !== 'function') {
|
|
780
993
|
throw typeErrorCreate('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');
|
|
781
994
|
}
|
|
782
|
-
//
|
|
995
|
+
// A caller-supplied policy applies to this configuration only.
|
|
996
|
+
const previousTrustedTypesPolicy = trustedTypesPolicy;
|
|
783
997
|
trustedTypesPolicy = cfg.TRUSTED_TYPES_POLICY;
|
|
784
|
-
// Sign local variables required by `sanitize`.
|
|
785
|
-
|
|
998
|
+
// Sign local variables required by `sanitize`. If the supplied policy's
|
|
999
|
+
// `createHTML` is circular (i.e. it calls `DOMPurify.sanitize`), this
|
|
1000
|
+
// throws via the re-entrancy guard. Restore the previous policy first so
|
|
1001
|
+
// the instance is not left in a poisoned state. See #1422.
|
|
1002
|
+
try {
|
|
1003
|
+
emptyHTML = _createTrustedHTML('');
|
|
1004
|
+
} catch (error) {
|
|
1005
|
+
trustedTypesPolicy = previousTrustedTypesPolicy;
|
|
1006
|
+
throw error;
|
|
1007
|
+
}
|
|
1008
|
+
} else if (cfg.TRUSTED_TYPES_POLICY === null) {
|
|
1009
|
+
// Explicit opt-out for this call: perform no Trusted Types signing and
|
|
1010
|
+
// create nothing (so a strict `trusted-types` CSP that disallows a
|
|
1011
|
+
// `dompurify` policy can still call `sanitize` from inside its own
|
|
1012
|
+
// policy — see #1422). Resetting to `undefined` rather than a sticky
|
|
1013
|
+
// `null` also drops any previously retained caller policy, so it cannot
|
|
1014
|
+
// resurface on a later call, while still allowing the next config-less
|
|
1015
|
+
// call to restore the internal default policy. See GHSA-vxr8-fq34-vvx9.
|
|
1016
|
+
trustedTypesPolicy = undefined;
|
|
1017
|
+
emptyHTML = '';
|
|
786
1018
|
} else {
|
|
787
|
-
//
|
|
1019
|
+
// No policy supplied: keep the currently active policy if one is set — a
|
|
1020
|
+
// previously supplied policy is intentionally sticky across config-less
|
|
1021
|
+
// calls — otherwise fall back to the instance's own internal policy,
|
|
1022
|
+
// created at most once. (A policy supplied for a *single* call still
|
|
1023
|
+
// lingers by design; what must not linger is a policy whose configuration
|
|
1024
|
+
// has been torn down via `clearConfig()`, which restores the default.)
|
|
788
1025
|
if (trustedTypesPolicy === undefined) {
|
|
789
|
-
trustedTypesPolicy =
|
|
1026
|
+
trustedTypesPolicy = _getDefaultTrustedTypesPolicy();
|
|
790
1027
|
}
|
|
791
|
-
//
|
|
792
|
-
|
|
793
|
-
|
|
1028
|
+
// Sign internal variables only when a policy is active. A falsy policy
|
|
1029
|
+
// (Trusted Types unsupported, creation failed, or an explicit opt-out)
|
|
1030
|
+
// leaves `emptyHTML` as a plain string, so we never call `.createHTML` on
|
|
1031
|
+
// a non-policy and throw. See #1422.
|
|
1032
|
+
if (trustedTypesPolicy && typeof emptyHTML === 'string') {
|
|
1033
|
+
emptyHTML = _createTrustedHTML('');
|
|
794
1034
|
}
|
|
795
1035
|
}
|
|
796
1036
|
// Prevent further manipulation of configuration.
|
|
@@ -805,6 +1045,77 @@ var purify = {exports: {}};
|
|
|
805
1045
|
* correctly. */
|
|
806
1046
|
const ALL_SVG_TAGS = addToSet({}, [...svg$1, ...svgFilters, ...svgDisallowed]);
|
|
807
1047
|
const ALL_MATHML_TAGS = addToSet({}, [...mathMl$1, ...mathMlDisallowed]);
|
|
1048
|
+
/**
|
|
1049
|
+
* Namespace rules for an element in the SVG namespace.
|
|
1050
|
+
*
|
|
1051
|
+
* @param tagName the element's lowercase tag name
|
|
1052
|
+
* @param parent the (possibly simulated) parent node
|
|
1053
|
+
* @param parentTagName the parent's lowercase tag name
|
|
1054
|
+
* @returns true if a spec-compliant parser could produce this element
|
|
1055
|
+
*/
|
|
1056
|
+
const _checkSvgNamespace = function _checkSvgNamespace(tagName, parent, parentTagName) {
|
|
1057
|
+
// The only way to switch from HTML namespace to SVG
|
|
1058
|
+
// is via <svg>. If it happens via any other tag, then
|
|
1059
|
+
// it should be killed.
|
|
1060
|
+
if (parent.namespaceURI === HTML_NAMESPACE) {
|
|
1061
|
+
return tagName === 'svg';
|
|
1062
|
+
}
|
|
1063
|
+
// The only way to switch from MathML to SVG is via <svg>
|
|
1064
|
+
// if the parent is either <annotation-xml> or a MathML
|
|
1065
|
+
// text integration point.
|
|
1066
|
+
if (parent.namespaceURI === MATHML_NAMESPACE) {
|
|
1067
|
+
return tagName === 'svg' && (parentTagName === 'annotation-xml' || MATHML_TEXT_INTEGRATION_POINTS[parentTagName]);
|
|
1068
|
+
}
|
|
1069
|
+
// We only allow elements that are defined in SVG
|
|
1070
|
+
// spec. All others are disallowed in SVG namespace.
|
|
1071
|
+
return Boolean(ALL_SVG_TAGS[tagName]);
|
|
1072
|
+
};
|
|
1073
|
+
/**
|
|
1074
|
+
* Namespace rules for an element in the MathML namespace.
|
|
1075
|
+
*
|
|
1076
|
+
* @param tagName the element's lowercase tag name
|
|
1077
|
+
* @param parent the (possibly simulated) parent node
|
|
1078
|
+
* @param parentTagName the parent's lowercase tag name
|
|
1079
|
+
* @returns true if a spec-compliant parser could produce this element
|
|
1080
|
+
*/
|
|
1081
|
+
const _checkMathMlNamespace = function _checkMathMlNamespace(tagName, parent, parentTagName) {
|
|
1082
|
+
// The only way to switch from HTML namespace to MathML
|
|
1083
|
+
// is via <math>. If it happens via any other tag, then
|
|
1084
|
+
// it should be killed.
|
|
1085
|
+
if (parent.namespaceURI === HTML_NAMESPACE) {
|
|
1086
|
+
return tagName === 'math';
|
|
1087
|
+
}
|
|
1088
|
+
// The only way to switch from SVG to MathML is via
|
|
1089
|
+
// <math> and HTML integration points
|
|
1090
|
+
if (parent.namespaceURI === SVG_NAMESPACE) {
|
|
1091
|
+
return tagName === 'math' && HTML_INTEGRATION_POINTS[parentTagName];
|
|
1092
|
+
}
|
|
1093
|
+
// We only allow elements that are defined in MathML
|
|
1094
|
+
// spec. All others are disallowed in MathML namespace.
|
|
1095
|
+
return Boolean(ALL_MATHML_TAGS[tagName]);
|
|
1096
|
+
};
|
|
1097
|
+
/**
|
|
1098
|
+
* Namespace rules for an element in the HTML namespace.
|
|
1099
|
+
*
|
|
1100
|
+
* @param tagName the element's lowercase tag name
|
|
1101
|
+
* @param parent the (possibly simulated) parent node
|
|
1102
|
+
* @param parentTagName the parent's lowercase tag name
|
|
1103
|
+
* @returns true if a spec-compliant parser could produce this element
|
|
1104
|
+
*/
|
|
1105
|
+
const _checkHtmlNamespace = function _checkHtmlNamespace(tagName, parent, parentTagName) {
|
|
1106
|
+
// The only way to switch from SVG to HTML is via
|
|
1107
|
+
// HTML integration points, and from MathML to HTML
|
|
1108
|
+
// is via MathML text integration points
|
|
1109
|
+
if (parent.namespaceURI === SVG_NAMESPACE && !HTML_INTEGRATION_POINTS[parentTagName]) {
|
|
1110
|
+
return false;
|
|
1111
|
+
}
|
|
1112
|
+
if (parent.namespaceURI === MATHML_NAMESPACE && !MATHML_TEXT_INTEGRATION_POINTS[parentTagName]) {
|
|
1113
|
+
return false;
|
|
1114
|
+
}
|
|
1115
|
+
// We disallow tags that are specific for MathML
|
|
1116
|
+
// or SVG and should never appear in HTML namespace
|
|
1117
|
+
return !ALL_MATHML_TAGS[tagName] && (COMMON_SVG_AND_HTML_ELEMENTS[tagName] || !ALL_SVG_TAGS[tagName]);
|
|
1118
|
+
};
|
|
808
1119
|
/**
|
|
809
1120
|
* @param element a DOM element whose namespace is being checked
|
|
810
1121
|
* @returns Return false if the element has a
|
|
@@ -827,51 +1138,13 @@ var purify = {exports: {}};
|
|
|
827
1138
|
return false;
|
|
828
1139
|
}
|
|
829
1140
|
if (element.namespaceURI === SVG_NAMESPACE) {
|
|
830
|
-
|
|
831
|
-
// is via <svg>. If it happens via any other tag, then
|
|
832
|
-
// it should be killed.
|
|
833
|
-
if (parent.namespaceURI === HTML_NAMESPACE) {
|
|
834
|
-
return tagName === 'svg';
|
|
835
|
-
}
|
|
836
|
-
// The only way to switch from MathML to SVG is via`
|
|
837
|
-
// svg if parent is either <annotation-xml> or MathML
|
|
838
|
-
// text integration points.
|
|
839
|
-
if (parent.namespaceURI === MATHML_NAMESPACE) {
|
|
840
|
-
return tagName === 'svg' && (parentTagName === 'annotation-xml' || MATHML_TEXT_INTEGRATION_POINTS[parentTagName]);
|
|
841
|
-
}
|
|
842
|
-
// We only allow elements that are defined in SVG
|
|
843
|
-
// spec. All others are disallowed in SVG namespace.
|
|
844
|
-
return Boolean(ALL_SVG_TAGS[tagName]);
|
|
1141
|
+
return _checkSvgNamespace(tagName, parent, parentTagName);
|
|
845
1142
|
}
|
|
846
1143
|
if (element.namespaceURI === MATHML_NAMESPACE) {
|
|
847
|
-
|
|
848
|
-
// is via <math>. If it happens via any other tag, then
|
|
849
|
-
// it should be killed.
|
|
850
|
-
if (parent.namespaceURI === HTML_NAMESPACE) {
|
|
851
|
-
return tagName === 'math';
|
|
852
|
-
}
|
|
853
|
-
// The only way to switch from SVG to MathML is via
|
|
854
|
-
// <math> and HTML integration points
|
|
855
|
-
if (parent.namespaceURI === SVG_NAMESPACE) {
|
|
856
|
-
return tagName === 'math' && HTML_INTEGRATION_POINTS[parentTagName];
|
|
857
|
-
}
|
|
858
|
-
// We only allow elements that are defined in MathML
|
|
859
|
-
// spec. All others are disallowed in MathML namespace.
|
|
860
|
-
return Boolean(ALL_MATHML_TAGS[tagName]);
|
|
1144
|
+
return _checkMathMlNamespace(tagName, parent, parentTagName);
|
|
861
1145
|
}
|
|
862
1146
|
if (element.namespaceURI === HTML_NAMESPACE) {
|
|
863
|
-
|
|
864
|
-
// HTML integration points, and from MathML to HTML
|
|
865
|
-
// is via MathML text integration points
|
|
866
|
-
if (parent.namespaceURI === SVG_NAMESPACE && !HTML_INTEGRATION_POINTS[parentTagName]) {
|
|
867
|
-
return false;
|
|
868
|
-
}
|
|
869
|
-
if (parent.namespaceURI === MATHML_NAMESPACE && !MATHML_TEXT_INTEGRATION_POINTS[parentTagName]) {
|
|
870
|
-
return false;
|
|
871
|
-
}
|
|
872
|
-
// We disallow tags that are specific for MathML
|
|
873
|
-
// or SVG and should never appear in HTML namespace
|
|
874
|
-
return !ALL_MATHML_TAGS[tagName] && (COMMON_SVG_AND_HTML_ELEMENTS[tagName] || !ALL_SVG_TAGS[tagName]);
|
|
1147
|
+
return _checkHtmlNamespace(tagName, parent, parentTagName);
|
|
875
1148
|
}
|
|
876
1149
|
// For XHTML and XML documents that support custom namespaces
|
|
877
1150
|
if (PARSER_MEDIA_TYPE === 'application/xhtml+xml' && ALLOWED_NAMESPACES[element.namespaceURI]) {
|
|
@@ -896,7 +1169,81 @@ var purify = {exports: {}};
|
|
|
896
1169
|
// eslint-disable-next-line unicorn/prefer-dom-node-remove
|
|
897
1170
|
getParentNode(node).removeChild(node);
|
|
898
1171
|
} catch (_) {
|
|
1172
|
+
/* The normal detach failed — this is reached for a parentless node
|
|
1173
|
+
(getParentNode() is null, so .removeChild throws). Element.prototype
|
|
1174
|
+
.remove() is itself a spec no-op on a parentless node, so a recorded
|
|
1175
|
+
"removal" would otherwise hand the caller back an intact,
|
|
1176
|
+
payload-bearing node (e.g. a detached IN_PLACE root the mXSS canary or
|
|
1177
|
+
the style-with-element-child rule decided to kill). Fail closed by
|
|
1178
|
+
throwing — exactly as a clobbered root does at the IN_PLACE entry —
|
|
1179
|
+
rather than trying to "neutralize" the node via its own methods.
|
|
1180
|
+
Neutralizing would mean calling getAttributeNames()/removeAttribute()
|
|
1181
|
+
on the node, both of which a <form> root can clobber via a named child
|
|
1182
|
+
(and _isClobbered does not even probe getAttributeNames), so the
|
|
1183
|
+
neutralize step could itself be silently defeated, leaving the payload
|
|
1184
|
+
intact. A throw touches only the cached, clobber-safe remove() and
|
|
1185
|
+
getParentNode(). Generalizes GHSA-r47g-fvhr-h676 (clobbered-form root)
|
|
1186
|
+
to every root-kill reason. REPORT-3.
|
|
1187
|
+
This lives inside the catch, so it never fires for a normally-removed
|
|
1188
|
+
in-tree node: those have a parent, removeChild() succeeds, and the
|
|
1189
|
+
catch is not entered. Only a kept (parentless) root reaches here. */
|
|
899
1190
|
remove(node);
|
|
1191
|
+
if (!getParentNode(node)) {
|
|
1192
|
+
throw typeErrorCreate('a node selected for removal could not be detached from its tree ' + 'and cannot be safely returned; refusing to sanitize in place');
|
|
1193
|
+
}
|
|
1194
|
+
}
|
|
1195
|
+
};
|
|
1196
|
+
/**
|
|
1197
|
+
* _neutralizeRoot
|
|
1198
|
+
*
|
|
1199
|
+
* Fail-closed teardown of an in-place root after the sanitize walk aborts
|
|
1200
|
+
* (campaign-3 F2). An internal throw mid-walk — e.g. a page-registered
|
|
1201
|
+
* custom element's reaction detaches a node so `_forceRemove`'s deliberate
|
|
1202
|
+
* parentless guard throws, or any other re-entrant engine mutation — would
|
|
1203
|
+
* otherwise leave the caller's *live* tree half-sanitized, with everything
|
|
1204
|
+
* after the abort point still carrying its handlers. There is no safe way
|
|
1205
|
+
* to resume the walk (the tree mutated under us), so we strip the root bare:
|
|
1206
|
+
* remove every child and every attribute, then let the caller's catch see
|
|
1207
|
+
* the original error. Clobber-safe (cached `remove`/`childNodes`/`attributes`
|
|
1208
|
+
* getters; the root was already clobber-pre-flighted at the IN_PLACE entry).
|
|
1209
|
+
*
|
|
1210
|
+
* @param root the in-place root to empty
|
|
1211
|
+
*/
|
|
1212
|
+
const _neutralizeRoot = function _neutralizeRoot(root) {
|
|
1213
|
+
/* Strip every disallowed attribute (on* handlers included) off the whole
|
|
1214
|
+
subtree BEFORE detaching anything. Detaching first would hand back
|
|
1215
|
+
handler-bearing originals (e.g. an already-loading `<img onerror>`)
|
|
1216
|
+
whose queued resource event still fires in page scope after we throw.
|
|
1217
|
+
Clobber-safe reads; a doomed clobbered node's own attributes are
|
|
1218
|
+
irrelevant while its non-clobbered descendants are reached and scrubbed. */
|
|
1219
|
+
_neutralizeSubtree(root);
|
|
1220
|
+
const childNodes = getChildNodes(root);
|
|
1221
|
+
if (childNodes) {
|
|
1222
|
+
const snapshot = [];
|
|
1223
|
+
arrayForEach(childNodes, child => {
|
|
1224
|
+
arrayPush(snapshot, child);
|
|
1225
|
+
});
|
|
1226
|
+
arrayForEach(snapshot, child => {
|
|
1227
|
+
try {
|
|
1228
|
+
remove(child);
|
|
1229
|
+
} catch (_) {
|
|
1230
|
+
/* Best-effort teardown; a still-attached child is handled below */
|
|
1231
|
+
}
|
|
1232
|
+
});
|
|
1233
|
+
}
|
|
1234
|
+
const attributes = getAttributes(root);
|
|
1235
|
+
if (attributes) {
|
|
1236
|
+
for (let i = attributes.length - 1; i >= 0; --i) {
|
|
1237
|
+
const attribute = attributes[i];
|
|
1238
|
+
const name = attribute && attribute.name;
|
|
1239
|
+
if (typeof name === 'string') {
|
|
1240
|
+
try {
|
|
1241
|
+
root.removeAttribute(name);
|
|
1242
|
+
} catch (_) {
|
|
1243
|
+
/* Clobbered removeAttribute — ignore (fail-closed best effort) */
|
|
1244
|
+
}
|
|
1245
|
+
}
|
|
1246
|
+
}
|
|
900
1247
|
}
|
|
901
1248
|
};
|
|
902
1249
|
/**
|
|
@@ -931,6 +1278,148 @@ var purify = {exports: {}};
|
|
|
931
1278
|
}
|
|
932
1279
|
}
|
|
933
1280
|
};
|
|
1281
|
+
/**
|
|
1282
|
+
* _stripDisallowedAttributes
|
|
1283
|
+
*
|
|
1284
|
+
* Removes every attribute the active configuration does not allow from a
|
|
1285
|
+
* single element, using the same allowlist as the main attribute pass (so
|
|
1286
|
+
* `on*` handlers go, but no `/^on/` blocklist is introduced). Used only to
|
|
1287
|
+
* neutralise nodes that are being discarded from an in-place tree.
|
|
1288
|
+
*
|
|
1289
|
+
* @param element the element to strip
|
|
1290
|
+
*/
|
|
1291
|
+
const _stripDisallowedAttributes = function _stripDisallowedAttributes(element) {
|
|
1292
|
+
const attributes = getAttributes(element);
|
|
1293
|
+
if (!attributes) {
|
|
1294
|
+
return;
|
|
1295
|
+
}
|
|
1296
|
+
for (let i = attributes.length - 1; i >= 0; --i) {
|
|
1297
|
+
const attribute = attributes[i];
|
|
1298
|
+
const name = attribute && attribute.name;
|
|
1299
|
+
if (typeof name !== 'string' || ALLOWED_ATTR[transformCaseFunc(name)]) {
|
|
1300
|
+
continue;
|
|
1301
|
+
}
|
|
1302
|
+
try {
|
|
1303
|
+
element.removeAttribute(name);
|
|
1304
|
+
} catch (_) {
|
|
1305
|
+
/* Clobbered removeAttribute on a doomed node — ignore */
|
|
1306
|
+
}
|
|
1307
|
+
}
|
|
1308
|
+
};
|
|
1309
|
+
/**
|
|
1310
|
+
* _neutralizeSubtree
|
|
1311
|
+
*
|
|
1312
|
+
* Completes the audit-5 F1 fix across every removal path. The KEEP_CONTENT
|
|
1313
|
+
* move-hoist neutralises only disallowed-tag removals; clobber, mXSS-canary,
|
|
1314
|
+
* namespace, comment, processing-instruction and KEEP_CONTENT:false removals
|
|
1315
|
+
* all drop their subtree wholesale via `_forceRemove`. On the IN_PLACE path
|
|
1316
|
+
* those dropped nodes are detached from the caller's LIVE tree but a
|
|
1317
|
+
* handler-bearing original among them (an `<img onerror>`/`<video>` that was
|
|
1318
|
+
* loading) keeps its queued resource event, which fires in page scope after
|
|
1319
|
+
* sanitize returns. This walks a removed subtree and strips every attribute
|
|
1320
|
+
* the active configuration does not allow — so `on*` handlers are cancelled
|
|
1321
|
+
* through the SAME allowlist that governs kept nodes, not a separate `/^on/`
|
|
1322
|
+
* blocklist. Run synchronously before sanitize returns, i.e. before any
|
|
1323
|
+
* queued event can fire. Hook-free by design: these nodes leave the output,
|
|
1324
|
+
* so firing attribute hooks for them would be surprising. Clobber-safe reads;
|
|
1325
|
+
* a doomed clobbered node may shadow `removeAttribute` (its own attributes are
|
|
1326
|
+
* irrelevant — it is discarded — while its non-clobbered descendants, e.g.
|
|
1327
|
+
* the `<img>`, are reached and scrubbed).
|
|
1328
|
+
*
|
|
1329
|
+
* @param root the root of a removed subtree to neutralise
|
|
1330
|
+
*/
|
|
1331
|
+
const _neutralizeSubtree = function _neutralizeSubtree(root) {
|
|
1332
|
+
const stack = [root];
|
|
1333
|
+
while (stack.length > 0) {
|
|
1334
|
+
const node = stack.pop();
|
|
1335
|
+
const nodeType = getNodeType ? getNodeType(node) : node.nodeType;
|
|
1336
|
+
if (nodeType === NODE_TYPE.element) {
|
|
1337
|
+
_stripDisallowedAttributes(node);
|
|
1338
|
+
}
|
|
1339
|
+
const childNodes = getChildNodes(node);
|
|
1340
|
+
if (childNodes) {
|
|
1341
|
+
for (let i = childNodes.length - 1; i >= 0; --i) {
|
|
1342
|
+
stack.push(childNodes[i]);
|
|
1343
|
+
}
|
|
1344
|
+
}
|
|
1345
|
+
}
|
|
1346
|
+
};
|
|
1347
|
+
/**
|
|
1348
|
+
* _neutralizePatchLinkage
|
|
1349
|
+
*
|
|
1350
|
+
* IN_PLACE entry pre-pass (declarative-partial-updates / streaming
|
|
1351
|
+
* hardening, https://github.com/WICG/declarative-partial-updates).
|
|
1352
|
+
*
|
|
1353
|
+
* The main walk strips patch linkage (`for`/`patchsrc`) and removes range
|
|
1354
|
+
* markers (PIs / markup comments) node-by-node, in document order, AS it
|
|
1355
|
+
* reaches each node. On a live in-place root that leaves a window: from the
|
|
1356
|
+
* moment the root is connected until the walk arrives at a given node, that
|
|
1357
|
+
* node's linkage is live. A patch applied on connection/stream can fire as
|
|
1358
|
+
* a microtask during the walk and inject or teleport an unsanitized DOM
|
|
1359
|
+
* range into a region the iterator has already passed and will not revisit,
|
|
1360
|
+
* so the post-return "tree is sanitized" contract is violated. Sweep the
|
|
1361
|
+
* whole tree once up front and sever every linkage before the walk begins,
|
|
1362
|
+
* closing that window.
|
|
1363
|
+
*
|
|
1364
|
+
* This CANNOT undo a patch that already fired before sanitize ran — that is
|
|
1365
|
+
* the irreducible "do not IN_PLACE a live-connected attacker tree" caveat —
|
|
1366
|
+
* but it closes everything from sanitize-start onward. Gated on SAFE_FOR_XML
|
|
1367
|
+
* to group with the rest of the declarative-partial-updates handling and
|
|
1368
|
+
* stay overridable, consistent with the codebase.
|
|
1369
|
+
*
|
|
1370
|
+
* Clobber-safe traversal (cached childNodes getter); per-node try/catch so a
|
|
1371
|
+
* clobbered root cannot defeat the sweep of its non-clobbered descendants.
|
|
1372
|
+
*
|
|
1373
|
+
* NOTE (pending real-Chrome confirmation, see test/declarative-patch-probe
|
|
1374
|
+
* .html Q1): this mirrors the existing policy of keeping `for` on
|
|
1375
|
+
* <label>/<output>. If the shipping feature can drive a patch through a
|
|
1376
|
+
* surviving `for`-on-label/output + `id` pair, this pre-pass and the
|
|
1377
|
+
* attribute check at _isBasicCustomElement's caller must additionally drop
|
|
1378
|
+
* that pair on the IN_PLACE path. Left as-is until the taxonomy is verified.
|
|
1379
|
+
*
|
|
1380
|
+
* @param root the in-place root to sweep
|
|
1381
|
+
*/
|
|
1382
|
+
const _neutralizePatchLinkage = function _neutralizePatchLinkage(root) {
|
|
1383
|
+
if (!SAFE_FOR_XML) {
|
|
1384
|
+
return;
|
|
1385
|
+
}
|
|
1386
|
+
const stack = [root];
|
|
1387
|
+
while (stack.length > 0) {
|
|
1388
|
+
const node = stack.pop();
|
|
1389
|
+
const nodeType = getNodeType ? getNodeType(node) : node.nodeType;
|
|
1390
|
+
/* Remove range markers (the target side of a patch linkage): every
|
|
1391
|
+
processing instruction, and any markup-bearing comment. */
|
|
1392
|
+
if (nodeType === NODE_TYPE.processingInstruction || nodeType === NODE_TYPE.comment && regExpTest(COMMENT_MARKUP_PROBE, node.data)) {
|
|
1393
|
+
try {
|
|
1394
|
+
remove(node);
|
|
1395
|
+
} catch (_) {
|
|
1396
|
+
/* Best-effort */
|
|
1397
|
+
}
|
|
1398
|
+
continue;
|
|
1399
|
+
}
|
|
1400
|
+
/* Strip patch-source attributes (the source side) off elements. */
|
|
1401
|
+
if (nodeType === NODE_TYPE.element) {
|
|
1402
|
+
const element = node;
|
|
1403
|
+
const lcTag = transformCaseFunc(getNodeName ? getNodeName(node) : node.nodeName);
|
|
1404
|
+
try {
|
|
1405
|
+
if (element.hasAttribute && element.hasAttribute('patchsrc')) {
|
|
1406
|
+
element.removeAttribute('patchsrc');
|
|
1407
|
+
}
|
|
1408
|
+
if (element.hasAttribute && element.hasAttribute('for') && lcTag !== 'label' && lcTag !== 'output') {
|
|
1409
|
+
element.removeAttribute('for');
|
|
1410
|
+
}
|
|
1411
|
+
} catch (_) {
|
|
1412
|
+
/* Clobbered removeAttribute/hasAttribute on a doomed node — ignore */
|
|
1413
|
+
}
|
|
1414
|
+
}
|
|
1415
|
+
const childNodes = getChildNodes(node);
|
|
1416
|
+
if (childNodes) {
|
|
1417
|
+
for (let i = childNodes.length - 1; i >= 0; --i) {
|
|
1418
|
+
stack.push(childNodes[i]);
|
|
1419
|
+
}
|
|
1420
|
+
}
|
|
1421
|
+
}
|
|
1422
|
+
};
|
|
934
1423
|
/**
|
|
935
1424
|
* _initDocument
|
|
936
1425
|
*
|
|
@@ -952,7 +1441,7 @@ var purify = {exports: {}};
|
|
|
952
1441
|
// Root of XHTML doc must contain xmlns declaration (see https://www.w3.org/TR/xhtml1/normative.html#strict)
|
|
953
1442
|
dirty = '<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>' + dirty + '</body></html>';
|
|
954
1443
|
}
|
|
955
|
-
const dirtyPayload = trustedTypesPolicy ?
|
|
1444
|
+
const dirtyPayload = trustedTypesPolicy ? _createTrustedHTML(dirty) : dirty;
|
|
956
1445
|
/*
|
|
957
1446
|
* Use the DOMParser API by default, fallback later if needs be
|
|
958
1447
|
* DOMParser not work for svg when has multiple root element.
|
|
@@ -988,33 +1477,297 @@ var purify = {exports: {}};
|
|
|
988
1477
|
* @return The created NodeIterator
|
|
989
1478
|
*/
|
|
990
1479
|
const _createNodeIterator = function _createNodeIterator(root) {
|
|
991
|
-
|
|
1480
|
+
/* Read ownerDocument through the cached Node.prototype getter, never the
|
|
1481
|
+
direct property. HTMLFormElement has [LegacyOverrideBuiltIns], so a
|
|
1482
|
+
clobbering child (<input name="ownerDocument"> or a form-associated
|
|
1483
|
+
external input) shadows the prototype getter and makes a direct read
|
|
1484
|
+
return that <input>. createNodeIterator.call(<input>, ...) then throws
|
|
1485
|
+
"Illegal invocation", and on the IN_PLACE path that throw lands before
|
|
1486
|
+
the walk's fail-closed barrier - leaving the caller's live tree, with
|
|
1487
|
+
any already-armed handler in it, un-neutralized. The cached getter
|
|
1488
|
+
returns the real Document regardless of the clobber. */
|
|
1489
|
+
const doc = getOwnerDocument ? getOwnerDocument(root) : root.ownerDocument;
|
|
1490
|
+
return createNodeIterator.call(doc || root, root,
|
|
992
1491
|
// eslint-disable-next-line no-bitwise
|
|
993
1492
|
NodeFilter.SHOW_ELEMENT | NodeFilter.SHOW_COMMENT | NodeFilter.SHOW_TEXT | NodeFilter.SHOW_PROCESSING_INSTRUCTION | NodeFilter.SHOW_CDATA_SECTION, null);
|
|
994
1493
|
};
|
|
1494
|
+
/**
|
|
1495
|
+
* Replace template expression syntax (mustache, ERB, template
|
|
1496
|
+
* literal) with a space; shared by all SAFE_FOR_TEMPLATES scrub
|
|
1497
|
+
* sites. Order matters: mustache, then ERB, then template literal.
|
|
1498
|
+
*
|
|
1499
|
+
* @param value the string to scrub
|
|
1500
|
+
* @returns the scrubbed string
|
|
1501
|
+
*/
|
|
1502
|
+
const _stripTemplateExpressions = function _stripTemplateExpressions(value) {
|
|
1503
|
+
value = stringReplace(value, MUSTACHE_EXPR$1, ' ');
|
|
1504
|
+
value = stringReplace(value, ERB_EXPR$1, ' ');
|
|
1505
|
+
value = stringReplace(value, TMPLIT_EXPR$1, ' ');
|
|
1506
|
+
return value;
|
|
1507
|
+
};
|
|
1508
|
+
/**
|
|
1509
|
+
* Strip template-engine expressions ({{...}}, ${...}, <%...%>) from the
|
|
1510
|
+
* character data of an element subtree. Used as the final safety net for
|
|
1511
|
+
* SAFE_FOR_TEMPLATES on every DOM-returning code path so that expressions
|
|
1512
|
+
* which only form after text-node normalization (e.g. fragments split across
|
|
1513
|
+
* stripped elements) cannot survive into a template-evaluating framework.
|
|
1514
|
+
*
|
|
1515
|
+
* Walks text/comment/CDATA/processing-instruction nodes and mutates `.data`
|
|
1516
|
+
* in place rather than round-tripping through innerHTML. This preserves
|
|
1517
|
+
* descendant node references (important for IN_PLACE callers), avoids a
|
|
1518
|
+
* serialize/reparse cycle, and reads literal character data — which means
|
|
1519
|
+
* `<%...%>` in text content matches the ERB regex against its real bytes
|
|
1520
|
+
* instead of the HTML-entity-escaped form innerHTML would produce.
|
|
1521
|
+
*
|
|
1522
|
+
* Attribute values are not visited here; SAFE_FOR_TEMPLATES handling for
|
|
1523
|
+
* attributes is performed during the per-node `_sanitizeAttributes` pass.
|
|
1524
|
+
*
|
|
1525
|
+
* @param node The root element whose character data should be scrubbed.
|
|
1526
|
+
*/
|
|
1527
|
+
const _scrubTemplateExpressions2 = function _scrubTemplateExpressions(node) {
|
|
1528
|
+
var _node$querySelectorAl;
|
|
1529
|
+
node.normalize();
|
|
1530
|
+
/* Clobber-safe ownerDocument read, same reasoning as _createNodeIterator:
|
|
1531
|
+
under SAFE_FOR_TEMPLATES this runs on the live IN_PLACE root, which may
|
|
1532
|
+
carry a form-named-getter override of ownerDocument. */
|
|
1533
|
+
const doc = getOwnerDocument ? getOwnerDocument(node) : node.ownerDocument;
|
|
1534
|
+
const walker = createNodeIterator.call(doc || node, node,
|
|
1535
|
+
// eslint-disable-next-line no-bitwise
|
|
1536
|
+
NodeFilter.SHOW_TEXT | NodeFilter.SHOW_COMMENT | NodeFilter.SHOW_CDATA_SECTION | NodeFilter.SHOW_PROCESSING_INSTRUCTION, null);
|
|
1537
|
+
let currentNode = walker.nextNode();
|
|
1538
|
+
while (currentNode) {
|
|
1539
|
+
currentNode.data = _stripTemplateExpressions(currentNode.data);
|
|
1540
|
+
currentNode = walker.nextNode();
|
|
1541
|
+
}
|
|
1542
|
+
// NodeIterator does not descend into <template>.content per the DOM spec,
|
|
1543
|
+
// so we must explicitly recurse into each template's content fragment,
|
|
1544
|
+
// mirroring the approach used by _sanitizeShadowDOM.
|
|
1545
|
+
const templates = (_node$querySelectorAl = node.querySelectorAll) === null || _node$querySelectorAl === void 0 ? void 0 : _node$querySelectorAl.call(node, 'template');
|
|
1546
|
+
if (templates) {
|
|
1547
|
+
arrayForEach(templates, tmpl => {
|
|
1548
|
+
if (_isDocumentFragment(tmpl.content)) {
|
|
1549
|
+
_scrubTemplateExpressions2(tmpl.content);
|
|
1550
|
+
}
|
|
1551
|
+
});
|
|
1552
|
+
}
|
|
1553
|
+
};
|
|
995
1554
|
/**
|
|
996
1555
|
* _isClobbered
|
|
997
1556
|
*
|
|
1557
|
+
* Detect DOM-clobbering on HTMLFormElement nodes. Form is the only HTML
|
|
1558
|
+
* interface with [LegacyOverrideBuiltIns]; a descendant element with a
|
|
1559
|
+
* `name` attribute matching a prototype property shadows that property
|
|
1560
|
+
* on direct reads. We use this check at the IN_PLACE entry-point and
|
|
1561
|
+
* during attribute sanitization to refuse clobbered forms.
|
|
1562
|
+
*
|
|
998
1563
|
* @param element element to check for clobbering attacks
|
|
999
1564
|
* @return true if clobbered, false if safe
|
|
1000
1565
|
*/
|
|
1001
1566
|
const _isClobbered = function _isClobbered(element) {
|
|
1002
|
-
|
|
1567
|
+
// Realm-independent tag-name probe. If we can't determine the tag
|
|
1568
|
+
// name at all, we can't reason about clobbering — return false
|
|
1569
|
+
// (the caller's other defences still apply).
|
|
1570
|
+
const realTagName = getNodeName ? getNodeName(element) : null;
|
|
1571
|
+
if (typeof realTagName !== 'string') {
|
|
1572
|
+
return false;
|
|
1573
|
+
}
|
|
1574
|
+
if (transformCaseFunc(realTagName) !== 'form') {
|
|
1575
|
+
return false;
|
|
1576
|
+
}
|
|
1577
|
+
return typeof element.nodeName !== 'string' || typeof element.textContent !== 'string' || typeof element.removeChild !== 'function' ||
|
|
1578
|
+
// Realm-safe NamedNodeMap detection: equality against the cached
|
|
1579
|
+
// prototype getter. Clobbered .attributes (e.g. <input name="attributes">)
|
|
1580
|
+
// makes the direct read diverge from the cached read; a clean form
|
|
1581
|
+
// (same-realm OR foreign-realm) has both reads pointing at the same
|
|
1582
|
+
// canonical NamedNodeMap.
|
|
1583
|
+
element.attributes !== getAttributes(element) || typeof element.removeAttribute !== 'function' || typeof element.setAttribute !== 'function' || typeof element.namespaceURI !== 'string' || typeof element.insertBefore !== 'function' || typeof element.hasChildNodes !== 'function' ||
|
|
1584
|
+
// NodeType clobbering probe. Cached Node.prototype.nodeType getter
|
|
1585
|
+
// returns the integer 1 for any Element regardless of realm; direct
|
|
1586
|
+
// read on a clobbered form (e.g. <input name="nodeType">) returns
|
|
1587
|
+
// the named child element. Cheap addition — nodeType is read from
|
|
1588
|
+
// an internal slot, no serialization cost — and removes a residual
|
|
1589
|
+
// clobbering surface used by several mXSS / PI / comment branches
|
|
1590
|
+
// in _sanitizeElements that compare currentNode.nodeType directly.
|
|
1591
|
+
element.nodeType !== getNodeType(element) ||
|
|
1592
|
+
// HTMLFormElement has [LegacyOverrideBuiltIns]: a descendant named
|
|
1593
|
+
// "childNodes" shadows the prototype getter. Direct reads of
|
|
1594
|
+
// form.childNodes from a clobbered form return the named child
|
|
1595
|
+
// instead of the real NodeList, so any walk that reads it directly
|
|
1596
|
+
// skips the form's real children. Compare the direct read to the
|
|
1597
|
+
// cached Node.prototype getter — when the form's named-property
|
|
1598
|
+
// getter intercepts the read, the two values differ and we flag
|
|
1599
|
+
// the form. This catches every clobbering child type (input,
|
|
1600
|
+
// select, etc.) regardless of whether the named child happens to
|
|
1601
|
+
// carry a numeric .length, which a typeof-based probe would miss
|
|
1602
|
+
// (e.g. HTMLSelectElement.length is a defined unsigned-long).
|
|
1603
|
+
element.childNodes !== getChildNodes(element);
|
|
1003
1604
|
};
|
|
1004
1605
|
/**
|
|
1005
|
-
* Checks whether the given
|
|
1606
|
+
* Checks whether the given value is a DocumentFragment from any realm.
|
|
1607
|
+
*
|
|
1608
|
+
* The realm-independent replacement reads `nodeType` through the cached
|
|
1609
|
+
* Node.prototype getter and compares to the DOCUMENT_FRAGMENT_NODE
|
|
1610
|
+
* constant (11). nodeType is a numeric value resolved from the node's
|
|
1611
|
+
* internal slot, identical across realms for the same kind of node.
|
|
1612
|
+
*
|
|
1613
|
+
* @param value object to check
|
|
1614
|
+
* @return true if value is a DocumentFragment-shaped node from any realm
|
|
1615
|
+
*/
|
|
1616
|
+
const _isDocumentFragment = function _isDocumentFragment(value) {
|
|
1617
|
+
if (!getNodeType || typeof value !== 'object' || value === null) {
|
|
1618
|
+
return false;
|
|
1619
|
+
}
|
|
1620
|
+
try {
|
|
1621
|
+
return getNodeType(value) === NODE_TYPE.documentFragment;
|
|
1622
|
+
} catch (_) {
|
|
1623
|
+
return false;
|
|
1624
|
+
}
|
|
1625
|
+
};
|
|
1626
|
+
/**
|
|
1627
|
+
* Checks whether the given object is a DOM node, including nodes that
|
|
1628
|
+
* originate from a different window/realm (e.g. an iframe's
|
|
1629
|
+
* contentDocument). The previous `value instanceof Node` check was
|
|
1630
|
+
* realm-bound: nodes from a different window failed it, causing
|
|
1631
|
+
* sanitize() to silently stringify them and reset IN_PLACE to false,
|
|
1632
|
+
* returning the original node unsanitized. See GHSA-4w3q-35jp-p934.
|
|
1006
1633
|
*
|
|
1007
1634
|
* @param value object to check whether it's a DOM node
|
|
1008
|
-
* @return true
|
|
1635
|
+
* @return true if value is a DOM node from any realm
|
|
1009
1636
|
*/
|
|
1010
1637
|
const _isNode = function _isNode(value) {
|
|
1011
|
-
|
|
1638
|
+
if (!getNodeType || typeof value !== 'object' || value === null) {
|
|
1639
|
+
return false;
|
|
1640
|
+
}
|
|
1641
|
+
try {
|
|
1642
|
+
return typeof getNodeType(value) === 'number';
|
|
1643
|
+
} catch (_) {
|
|
1644
|
+
return false;
|
|
1645
|
+
}
|
|
1012
1646
|
};
|
|
1013
1647
|
function _executeHooks(hooks, currentNode, data) {
|
|
1648
|
+
if (hooks.length === 0) {
|
|
1649
|
+
return;
|
|
1650
|
+
}
|
|
1014
1651
|
arrayForEach(hooks, hook => {
|
|
1015
1652
|
hook.call(DOMPurify, currentNode, data, CONFIG);
|
|
1016
1653
|
});
|
|
1017
1654
|
}
|
|
1655
|
+
/**
|
|
1656
|
+
* Structural-threat checks that condemn a node regardless of the
|
|
1657
|
+
* allowlists: mXSS via namespace confusion, risky CSS construction,
|
|
1658
|
+
* processing instructions, markup-bearing comments. Pure predicate;
|
|
1659
|
+
* the caller removes. Check order is load-bearing.
|
|
1660
|
+
*
|
|
1661
|
+
* @param currentNode the node to inspect
|
|
1662
|
+
* @param tagName the node's transformCaseFunc'd tag name
|
|
1663
|
+
* @return true if the node must be removed
|
|
1664
|
+
*/
|
|
1665
|
+
const _isUnsafeNode = function _isUnsafeNode(currentNode, tagName) {
|
|
1666
|
+
/* Detect mXSS attempts abusing namespace confusion */
|
|
1667
|
+
if (SAFE_FOR_XML && currentNode.hasChildNodes() && !_isNode(currentNode.firstElementChild) && regExpTest(ELEMENT_MARKUP_PROBE, currentNode.textContent) && regExpTest(ELEMENT_MARKUP_PROBE, currentNode.innerHTML)) {
|
|
1668
|
+
return true;
|
|
1669
|
+
}
|
|
1670
|
+
/* Remove risky CSS construction leading to mXSS */
|
|
1671
|
+
if (SAFE_FOR_XML && currentNode.namespaceURI === HTML_NAMESPACE && tagName === 'style' && _isNode(currentNode.firstElementChild)) {
|
|
1672
|
+
return true;
|
|
1673
|
+
}
|
|
1674
|
+
/* Remove any occurrence of processing instructions */
|
|
1675
|
+
if (currentNode.nodeType === NODE_TYPE.processingInstruction) {
|
|
1676
|
+
return true;
|
|
1677
|
+
}
|
|
1678
|
+
/* Remove any kind of possibly harmful comments */
|
|
1679
|
+
if (SAFE_FOR_XML && currentNode.nodeType === NODE_TYPE.comment && regExpTest(COMMENT_MARKUP_PROBE, currentNode.data)) {
|
|
1680
|
+
return true;
|
|
1681
|
+
}
|
|
1682
|
+
return false;
|
|
1683
|
+
};
|
|
1684
|
+
/**
|
|
1685
|
+
* Handle a node whose tag is forbidden or not allowlisted: keep
|
|
1686
|
+
* allowed custom elements (false return exits _sanitizeElements
|
|
1687
|
+
* early - the namespace and fallback-tag removal checks are
|
|
1688
|
+
* intentionally skipped for kept custom elements), else hoist
|
|
1689
|
+
* content per KEEP_CONTENT and remove.
|
|
1690
|
+
*
|
|
1691
|
+
* A kept custom element is the ONLY case in which this function
|
|
1692
|
+
* returns false, so the caller uses that return value to run the
|
|
1693
|
+
* afterSanitizeElements hook on the kept element and keep the
|
|
1694
|
+
* element-hook lifecycle consistent with normal allowlisted
|
|
1695
|
+
* elements (GHSA-c2j3-45gr-mqc4).
|
|
1696
|
+
*
|
|
1697
|
+
* @param currentNode the disallowed node
|
|
1698
|
+
* @param tagName the node's transformCaseFunc'd tag name
|
|
1699
|
+
* @return true if the node was removed, false if kept
|
|
1700
|
+
*/
|
|
1701
|
+
const _sanitizeDisallowedNode = function _sanitizeDisallowedNode(currentNode, tagName, root) {
|
|
1702
|
+
/* Check if we have a custom element to handle */
|
|
1703
|
+
if (!FORBID_TAGS[tagName] && _isBasicCustomElement(tagName)) {
|
|
1704
|
+
if (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof RegExp && regExpTest(CUSTOM_ELEMENT_HANDLING.tagNameCheck, tagName)) {
|
|
1705
|
+
return false;
|
|
1706
|
+
}
|
|
1707
|
+
if (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof Function && CUSTOM_ELEMENT_HANDLING.tagNameCheck(tagName)) {
|
|
1708
|
+
return false;
|
|
1709
|
+
}
|
|
1710
|
+
}
|
|
1711
|
+
/* Keep content except for bad-listed elements.
|
|
1712
|
+
Use the cached prototype getters exclusively — the previous code
|
|
1713
|
+
had `|| currentNode.parentNode` / `|| currentNode.childNodes`
|
|
1714
|
+
fallbacks, but the cached getters always return the canonical
|
|
1715
|
+
value (or null for a real parent-less node), so the fallback
|
|
1716
|
+
path was dead in safe cases and a clobbering surface in unsafe
|
|
1717
|
+
ones. Falsy cached results stay falsy; the `if (childNodes &&
|
|
1718
|
+
parentNode)` check already gates correctly. */
|
|
1719
|
+
if (KEEP_CONTENT && !FORBID_CONTENTS[tagName]) {
|
|
1720
|
+
const parentNode = getParentNode(currentNode);
|
|
1721
|
+
const childNodes = getChildNodes(currentNode);
|
|
1722
|
+
if (childNodes && parentNode) {
|
|
1723
|
+
const childCount = childNodes.length;
|
|
1724
|
+
/* Hoist by moving each child up one level rather than deep-cloning
|
|
1725
|
+
it. Moving transfers every descendant exactly once, so a chain of
|
|
1726
|
+
nested disallowed elements costs O(n) instead of the O(n^2) that
|
|
1727
|
+
re-cloning the shrinking subtree at each level produced; it also
|
|
1728
|
+
empties the removed original, so `DOMPurify.removed` no longer
|
|
1729
|
+
pins whole subtrees. Moving preserves the in-place guarantee too:
|
|
1730
|
+
an original carrying already-queued resource events (`<img
|
|
1731
|
+
onerror>`, `<video>`/`<audio>` error, lazy/`onload`, …) is
|
|
1732
|
+
relocated and sanitised rather than left detached but still armed.
|
|
1733
|
+
The sole case that must clone is removing the walk root itself.
|
|
1734
|
+
The result is serialised from the root's subtree, so a restrictive
|
|
1735
|
+
ALLOWED_TAGS that strips the root (`body` on the string path) must
|
|
1736
|
+
leave the content inside it, which only cloning does. In IN_PLACE
|
|
1737
|
+
the root is pre-validated as an allowed tag and so is never removed
|
|
1738
|
+
here, so that path always takes the move branch.
|
|
1739
|
+
`childNodes` is live; a tail-to-head walk keeps `childNodes[i]`
|
|
1740
|
+
valid whether we move (drops the trailing entry) or clone (leaves
|
|
1741
|
+
the list intact). */
|
|
1742
|
+
for (let i = childCount - 1; i >= 0; --i) {
|
|
1743
|
+
const hoisted = currentNode === root ? cloneNode(childNodes[i], true) : childNodes[i];
|
|
1744
|
+
parentNode.insertBefore(hoisted, getNextSibling(currentNode));
|
|
1745
|
+
}
|
|
1746
|
+
}
|
|
1747
|
+
}
|
|
1748
|
+
_forceRemove(currentNode);
|
|
1749
|
+
return true;
|
|
1750
|
+
};
|
|
1751
|
+
/**
|
|
1752
|
+
* Fork a hook-mutable allowlist off its shared binding the first time a
|
|
1753
|
+
* (possibly lazily-installed) uponSanitize* hook is about to see it, so the
|
|
1754
|
+
* hook cannot widen the per-instance default or the setConfig binding by
|
|
1755
|
+
* reference and leak past the call. Returns the set unchanged once it is
|
|
1756
|
+
* already call-local, so repeated calls across elements are idempotent.
|
|
1757
|
+
*
|
|
1758
|
+
* @param hookList the uponSanitize* hook array for this event
|
|
1759
|
+
* @param set the current ALLOWED_TAGS / ALLOWED_ATTR binding
|
|
1760
|
+
* @param defaultSet the per-instance DEFAULT_ALLOWED_* constant
|
|
1761
|
+
* @param setConfigSet the captured setConfig() binding, or null
|
|
1762
|
+
* @return a call-local clone if a hook is present and set is still shared,
|
|
1763
|
+
* else set unchanged
|
|
1764
|
+
*/
|
|
1765
|
+
const _forkSharedAllowlist = function _forkSharedAllowlist(hookList, set, defaultSet, setConfigSet) {
|
|
1766
|
+
if (hookList.length === 0) {
|
|
1767
|
+
return set;
|
|
1768
|
+
}
|
|
1769
|
+
return set === defaultSet || set === setConfigSet ? clone(set) : set;
|
|
1770
|
+
};
|
|
1018
1771
|
/**
|
|
1019
1772
|
* _sanitizeElements
|
|
1020
1773
|
*
|
|
@@ -1024,86 +1777,112 @@ var purify = {exports: {}};
|
|
|
1024
1777
|
* @param currentNode to check for permission to exist
|
|
1025
1778
|
* @return true if node was killed, false if left alive
|
|
1026
1779
|
*/
|
|
1027
|
-
|
|
1028
|
-
|
|
1780
|
+
// eslint-disable-next-line complexity
|
|
1781
|
+
const _sanitizeElements = function _sanitizeElements(currentNode, root) {
|
|
1029
1782
|
/* Execute a hook if present */
|
|
1030
1783
|
_executeHooks(hooks.beforeSanitizeElements, currentNode, null);
|
|
1784
|
+
/* A hook may have detached the node - treat it as removed (see the
|
|
1785
|
+
detached-node comment after the uponSanitizeElement hook below). On
|
|
1786
|
+
the IN_PLACE path, neutralize the detached subtree first so a queued
|
|
1787
|
+
resource handler on it cannot fire in page scope after we return. */
|
|
1788
|
+
if (currentNode !== root && getParentNode(currentNode) === null) {
|
|
1789
|
+
if (IN_PLACE) {
|
|
1790
|
+
_neutralizeSubtree(currentNode);
|
|
1791
|
+
}
|
|
1792
|
+
return true;
|
|
1793
|
+
}
|
|
1031
1794
|
/* Check if element is clobbered or can clobber */
|
|
1032
1795
|
if (_isClobbered(currentNode)) {
|
|
1033
1796
|
_forceRemove(currentNode);
|
|
1034
1797
|
return true;
|
|
1035
1798
|
}
|
|
1036
1799
|
/* Now let's check the element's type and name */
|
|
1037
|
-
const tagName = transformCaseFunc(currentNode.nodeName);
|
|
1800
|
+
const tagName = transformCaseFunc(getNodeName ? getNodeName(currentNode) : currentNode.nodeName);
|
|
1801
|
+
/* Close the pre-walk clone-guard's timing gap: an uponSanitizeElement
|
|
1802
|
+
hook may have been installed after that guard sampled the hook arrays
|
|
1803
|
+
(e.g. lazily from beforeSanitizeElements), leaving ALLOWED_TAGS still
|
|
1804
|
+
aliasing a shared binding that a widening hook would mutate by
|
|
1805
|
+
reference. Fork it before exposing it to the hook. */
|
|
1806
|
+
ALLOWED_TAGS = _forkSharedAllowlist(hooks.uponSanitizeElement, ALLOWED_TAGS, DEFAULT_ALLOWED_TAGS, SET_CONFIG_ALLOWED_TAGS);
|
|
1038
1807
|
/* Execute a hook if present */
|
|
1039
1808
|
_executeHooks(hooks.uponSanitizeElement, currentNode, {
|
|
1040
1809
|
tagName,
|
|
1041
1810
|
allowedTags: ALLOWED_TAGS
|
|
1042
1811
|
});
|
|
1043
|
-
/*
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1812
|
+
/* A hook may have detached the node from the tree — a long-standing
|
|
1813
|
+
user pattern (issue #469; draw.io-style foreignObject filtering).
|
|
1814
|
+
Per the cached, unclobberable parentNode getter the node is
|
|
1815
|
+
genuinely out of the tree, so it can reach neither the serialized
|
|
1816
|
+
output nor an IN_PLACE live tree; treat it as removed and stop
|
|
1817
|
+
processing it. Without this guard, the unsafe-node / namespace
|
|
1818
|
+
checks below would call _forceRemove on a parentless node and hit
|
|
1819
|
+
the REPORT-3 fail-closed throw — which exists for nodes DOMPurify
|
|
1820
|
+
wants gone but *cannot* detach (clobbered / parentless roots), the
|
|
1821
|
+
opposite of a node that is already safely gone. The walk root is
|
|
1822
|
+
exempt: a detached IN_PLACE root is legitimate input and must still
|
|
1823
|
+
be fully sanitized, and a kill-decision on it must keep hitting the
|
|
1824
|
+
REPORT-3 throw. Nodes detached by hooks stay the hook's
|
|
1825
|
+
responsibility for placement: they are not recorded in
|
|
1826
|
+
DOMPurify.removed, so the post-walk IN_PLACE pass (which iterates
|
|
1827
|
+
DOMPurify.removed) does not reach them. But a hook-detached subtree
|
|
1828
|
+
can still hold a queued resource-event handler - e.g. an <img onload>
|
|
1829
|
+
that began loading when the caller built the live tree - which fires
|
|
1830
|
+
in page scope after sanitize returns even though the handler never
|
|
1831
|
+
reached the returned tree. That is the audit-5 F1 hazard, and the
|
|
1832
|
+
documented node.remove() hook pattern walks straight into it. So on
|
|
1833
|
+
the IN_PLACE path we neutralize the detached subtree inline here,
|
|
1834
|
+
stripping its non-allow-listed attributes before returning, exactly
|
|
1835
|
+
as the post-walk pass does for _forceRemove'd subtrees. */
|
|
1836
|
+
if (currentNode !== root && getParentNode(currentNode) === null) {
|
|
1837
|
+
if (IN_PLACE) {
|
|
1838
|
+
_neutralizeSubtree(currentNode);
|
|
1839
|
+
}
|
|
1051
1840
|
return true;
|
|
1052
1841
|
}
|
|
1053
|
-
/* Remove
|
|
1054
|
-
if (currentNode
|
|
1055
|
-
_forceRemove(currentNode);
|
|
1056
|
-
return true;
|
|
1057
|
-
}
|
|
1058
|
-
/* Remove any kind of possibly harmful comments */
|
|
1059
|
-
if (SAFE_FOR_XML && currentNode.nodeType === NODE_TYPE.comment && regExpTest(/<[/\w]/g, currentNode.data)) {
|
|
1842
|
+
/* Remove mXSS vectors, processing instructions and risky comments */
|
|
1843
|
+
if (_isUnsafeNode(currentNode, tagName)) {
|
|
1060
1844
|
_forceRemove(currentNode);
|
|
1061
1845
|
return true;
|
|
1062
1846
|
}
|
|
1063
1847
|
/* Remove element if anything forbids its presence */
|
|
1064
1848
|
if (FORBID_TAGS[tagName] || !(EXTRA_ELEMENT_HANDLING.tagCheck instanceof Function && EXTRA_ELEMENT_HANDLING.tagCheck(tagName)) && !ALLOWED_TAGS[tagName]) {
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
const childCount = childNodes.length;
|
|
1080
|
-
for (let i = childCount - 1; i >= 0; --i) {
|
|
1081
|
-
const childClone = cloneNode(childNodes[i], true);
|
|
1082
|
-
childClone.__removalCount = (currentNode.__removalCount || 0) + 1;
|
|
1083
|
-
parentNode.insertBefore(childClone, getNextSibling(currentNode));
|
|
1084
|
-
}
|
|
1085
|
-
}
|
|
1849
|
+
const removed = _sanitizeDisallowedNode(currentNode, tagName, root);
|
|
1850
|
+
/* A false return means the node is a custom element kept via
|
|
1851
|
+
CUSTOM_ELEMENT_HANDLING - the only keep path through
|
|
1852
|
+
_sanitizeDisallowedNode. Run afterSanitizeElements on it so the
|
|
1853
|
+
element-hook lifecycle matches normal allowlisted elements: a
|
|
1854
|
+
security policy applied in this hook (e.g. stripping an attribute
|
|
1855
|
+
from every surviving element) must not silently skip kept custom
|
|
1856
|
+
elements (GHSA-c2j3-45gr-mqc4). This mirrors the normal-element
|
|
1857
|
+
tail below - the hook runs, then the walker's subsequent
|
|
1858
|
+
_sanitizeAttributes pass sanitizes the element's attributes. The
|
|
1859
|
+
deliberately skipped namespace and fallback-tag removal checks stay
|
|
1860
|
+
skipped; they are removal decisions, not the hook contract. */
|
|
1861
|
+
if (removed === false) {
|
|
1862
|
+
_executeHooks(hooks.afterSanitizeElements, currentNode, null);
|
|
1086
1863
|
}
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1864
|
+
return removed;
|
|
1865
|
+
}
|
|
1866
|
+
/* Check whether element has a valid namespace.
|
|
1867
|
+
Realm-safe check (GHSA-hpcv-96wg-7vj8): use the cached Node.prototype
|
|
1868
|
+
nodeType getter rather than `instanceof Element`, which is realm-
|
|
1869
|
+
bound and short-circuits to false for any node minted in a different
|
|
1870
|
+
realm — letting a foreign-realm element with a forbidden namespace
|
|
1871
|
+
slip past the namespace check entirely. */
|
|
1872
|
+
const nt = getNodeType ? getNodeType(currentNode) : currentNode.nodeType;
|
|
1873
|
+
if (nt === NODE_TYPE.element && !_checkValidNamespace(currentNode)) {
|
|
1092
1874
|
_forceRemove(currentNode);
|
|
1093
1875
|
return true;
|
|
1094
1876
|
}
|
|
1095
1877
|
/* Make sure that older browsers don't get fallback-tag mXSS */
|
|
1096
|
-
if ((tagName === 'noscript' || tagName === 'noembed' || tagName === 'noframes') && regExpTest(
|
|
1878
|
+
if ((tagName === 'noscript' || tagName === 'noembed' || tagName === 'noframes') && regExpTest(FALLBACK_TAG_CLOSE, currentNode.innerHTML)) {
|
|
1097
1879
|
_forceRemove(currentNode);
|
|
1098
1880
|
return true;
|
|
1099
1881
|
}
|
|
1100
1882
|
/* Sanitize element content to be template-safe */
|
|
1101
1883
|
if (SAFE_FOR_TEMPLATES && currentNode.nodeType === NODE_TYPE.text) {
|
|
1102
1884
|
/* Get the element's text content */
|
|
1103
|
-
content = currentNode.textContent;
|
|
1104
|
-
arrayForEach([MUSTACHE_EXPR, ERB_EXPR, TMPLIT_EXPR], expr => {
|
|
1105
|
-
content = stringReplace(content, expr, ' ');
|
|
1106
|
-
});
|
|
1885
|
+
const content = _stripTemplateExpressions(currentNode.textContent);
|
|
1107
1886
|
if (currentNode.textContent !== content) {
|
|
1108
1887
|
arrayPush(DOMPurify.removed, {
|
|
1109
1888
|
element: currentNode.cloneNode()
|
|
@@ -1129,15 +1908,43 @@ var purify = {exports: {}};
|
|
|
1129
1908
|
if (FORBID_ATTR[lcName]) {
|
|
1130
1909
|
return false;
|
|
1131
1910
|
}
|
|
1911
|
+
/* Reject declarative-partial-updates patch-linkage attributes
|
|
1912
|
+
(https://github.com/WICG/declarative-partial-updates).
|
|
1913
|
+
Empirical note (Chrome 150, verified — see
|
|
1914
|
+
test/declarative-patch-probe-v3.html): expansion is NOT applied after
|
|
1915
|
+
sanitization. For the string path it fires during sanitize()'s own
|
|
1916
|
+
parse, so the walk sees and sanitizes the fully materialized expanded
|
|
1917
|
+
tree — teleports into MathML/SVG integration points included; a
|
|
1918
|
+
weaponized `<template for>`->`<img onerror>` comes back with the handler
|
|
1919
|
+
stripped. For the IN_PLACE path it fires on connection, before the walk.
|
|
1920
|
+
Either way DOMPurify is NOT blind to the patch.
|
|
1921
|
+
This removal is therefore defense-in-depth rather than the sole barrier:
|
|
1922
|
+
it prevents live linkage from surviving into the OUTPUT and re-expanding
|
|
1923
|
+
in the caller's context, and keeps behaviour deterministic if a future
|
|
1924
|
+
engine defers expansion. `for` is legitimate only on <label>/<output>;
|
|
1925
|
+
anywhere else (notably <template for>) it links the element to a patch
|
|
1926
|
+
target and teleports or removes an arbitrary DOM range by id/marker name.
|
|
1927
|
+
`patchsrc` fetches remote markup and is treated as a script-loading
|
|
1928
|
+
mechanism (CSP). Gated on SAFE_FOR_XML so the removal groups with the
|
|
1929
|
+
other structural-threat checks and stays overridable, consistent with
|
|
1930
|
+
the rest of the codebase. PI range markers are already removed by
|
|
1931
|
+
_isUnsafeNode. */
|
|
1932
|
+
if (SAFE_FOR_XML && lcName === 'patchsrc') {
|
|
1933
|
+
return false;
|
|
1934
|
+
}
|
|
1935
|
+
if (SAFE_FOR_XML && lcName === 'for' && lcTag !== 'label' && lcTag !== 'output') {
|
|
1936
|
+
return false;
|
|
1937
|
+
}
|
|
1132
1938
|
/* Make sure attribute cannot clobber */
|
|
1133
1939
|
if (SANITIZE_DOM && (lcName === 'id' || lcName === 'name') && (value in document || value in formElement)) {
|
|
1134
1940
|
return false;
|
|
1135
1941
|
}
|
|
1942
|
+
const nameIsPermitted = ALLOWED_ATTR[lcName] || EXTRA_ELEMENT_HANDLING.attributeCheck instanceof Function && EXTRA_ELEMENT_HANDLING.attributeCheck(lcName, lcTag);
|
|
1136
1943
|
/* Allow valid data-* attributes: At least one character after "-"
|
|
1137
1944
|
(https://html.spec.whatwg.org/multipage/dom.html#embedding-custom-non-visible-data-with-the-data-*-attributes)
|
|
1138
1945
|
XML-compatible (https://html.spec.whatwg.org/multipage/infrastructure.html#xml-compatible and http://www.w3.org/TR/xml/#d0e804)
|
|
1139
1946
|
We don't need to check the value; it's always URI safe. */
|
|
1140
|
-
if (ALLOW_DATA_ATTR &&
|
|
1947
|
+
if (ALLOW_DATA_ATTR && regExpTest(DATA_ATTR$1, lcName)) ; else if (ALLOW_ARIA_ATTR && regExpTest(ARIA_ATTR$1, lcName)) ; else if (!nameIsPermitted) {
|
|
1141
1948
|
if (
|
|
1142
1949
|
// First condition does a very basic check if a) it's basically a valid custom element tagname AND
|
|
1143
1950
|
// b) if the tagName passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.tagNameCheck
|
|
@@ -1149,11 +1956,15 @@ var purify = {exports: {}};
|
|
|
1149
1956
|
return false;
|
|
1150
1957
|
}
|
|
1151
1958
|
/* Check value is safe. First, is attr inert? If so, is safe */
|
|
1152
|
-
} else if (URI_SAFE_ATTRIBUTES[lcName]) ; else if (regExpTest(IS_ALLOWED_URI$1, stringReplace(value, ATTR_WHITESPACE, ''))) ; else if ((lcName === 'src' || lcName === 'xlink:href' || lcName === 'href') && lcTag !== 'script' && stringIndexOf(value, 'data:') === 0 && DATA_URI_TAGS[lcTag]) ; else if (ALLOW_UNKNOWN_PROTOCOLS && !regExpTest(IS_SCRIPT_OR_DATA, stringReplace(value, ATTR_WHITESPACE, ''))) ; else if (value) {
|
|
1959
|
+
} else if (URI_SAFE_ATTRIBUTES[lcName]) ; else if (regExpTest(IS_ALLOWED_URI$1, stringReplace(value, ATTR_WHITESPACE$1, ''))) ; else if ((lcName === 'src' || lcName === 'xlink:href' || lcName === 'href') && lcTag !== 'script' && stringIndexOf(value, 'data:') === 0 && DATA_URI_TAGS[lcTag]) ; else if (ALLOW_UNKNOWN_PROTOCOLS && !regExpTest(IS_SCRIPT_OR_DATA$1, stringReplace(value, ATTR_WHITESPACE$1, ''))) ; else if (value) {
|
|
1153
1960
|
return false;
|
|
1154
1961
|
} else ;
|
|
1155
1962
|
return true;
|
|
1156
1963
|
};
|
|
1964
|
+
/* Names the HTML spec reserves from valid-custom-element-name; these must
|
|
1965
|
+
* never be treated as basic custom elements even when a permissive
|
|
1966
|
+
* CUSTOM_ELEMENT_HANDLING.tagNameCheck is configured. */
|
|
1967
|
+
const RESERVED_CUSTOM_ELEMENT_NAMES = addToSet({}, ['annotation-xml', 'color-profile', 'font-face', 'font-face-format', 'font-face-name', 'font-face-src', 'font-face-uri', 'missing-glyph']);
|
|
1157
1968
|
/**
|
|
1158
1969
|
* _isBasicCustomElement
|
|
1159
1970
|
* checks if at least one dash is included in tagName, and it's not the first char
|
|
@@ -1163,7 +1974,64 @@ var purify = {exports: {}};
|
|
|
1163
1974
|
* @returns Returns true if the tag name meets the basic criteria for a custom element, otherwise false.
|
|
1164
1975
|
*/
|
|
1165
1976
|
const _isBasicCustomElement = function _isBasicCustomElement(tagName) {
|
|
1166
|
-
return tagName
|
|
1977
|
+
return !RESERVED_CUSTOM_ELEMENT_NAMES[stringToLowerCase(tagName)] && regExpTest(CUSTOM_ELEMENT$1, tagName);
|
|
1978
|
+
};
|
|
1979
|
+
/**
|
|
1980
|
+
* Wrap an attribute value in the matching Trusted Types object when
|
|
1981
|
+
* the active policy requires it. Namespaced attributes pass through
|
|
1982
|
+
* unchanged (no TT support yet, see
|
|
1983
|
+
* https://bugs.chromium.org/p/chromium/issues/detail?id=1305293).
|
|
1984
|
+
*
|
|
1985
|
+
* @param lcTag lowercase tag name of the containing element
|
|
1986
|
+
* @param lcName lowercase attribute name
|
|
1987
|
+
* @param namespaceURI the attribute's namespace, if any
|
|
1988
|
+
* @param value the attribute value to wrap
|
|
1989
|
+
* @return the value, wrapped when Trusted Types demand it
|
|
1990
|
+
*/
|
|
1991
|
+
const _applyTrustedTypesToAttribute = function _applyTrustedTypesToAttribute(lcTag, lcName, namespaceURI, value) {
|
|
1992
|
+
if (trustedTypesPolicy && typeof trustedTypes === 'object' && typeof trustedTypes.getAttributeType === 'function' && !namespaceURI) {
|
|
1993
|
+
switch (trustedTypes.getAttributeType(lcTag, lcName)) {
|
|
1994
|
+
case 'TrustedHTML':
|
|
1995
|
+
{
|
|
1996
|
+
return _createTrustedHTML(value);
|
|
1997
|
+
}
|
|
1998
|
+
case 'TrustedScriptURL':
|
|
1999
|
+
{
|
|
2000
|
+
return _createTrustedScriptURL(value);
|
|
2001
|
+
}
|
|
2002
|
+
}
|
|
2003
|
+
}
|
|
2004
|
+
return value;
|
|
2005
|
+
};
|
|
2006
|
+
/**
|
|
2007
|
+
* Write a modified attribute value back onto the element. On
|
|
2008
|
+
* success, re-probe for clobbering introduced by the new value and
|
|
2009
|
+
* remove the element when found; otherwise pop the removal entry
|
|
2010
|
+
* recorded by the earlier _removeAttribute (long-standing pairing
|
|
2011
|
+
* with the SANITIZE_NAMED_PROPS path - do not "fix" casually). On
|
|
2012
|
+
* failure, remove the attribute instead.
|
|
2013
|
+
*
|
|
2014
|
+
* @param currentNode the element carrying the attribute
|
|
2015
|
+
* @param name the attribute name as present on the element
|
|
2016
|
+
* @param namespaceURI the attribute's namespace, if any
|
|
2017
|
+
* @param value the new attribute value
|
|
2018
|
+
*/
|
|
2019
|
+
const _setAttributeValue = function _setAttributeValue(currentNode, name, namespaceURI, value) {
|
|
2020
|
+
try {
|
|
2021
|
+
if (namespaceURI) {
|
|
2022
|
+
currentNode.setAttributeNS(namespaceURI, name, value);
|
|
2023
|
+
} else {
|
|
2024
|
+
/* Fallback to setAttribute() for browser-unrecognized namespaces e.g. "x-schema". */
|
|
2025
|
+
currentNode.setAttribute(name, value);
|
|
2026
|
+
}
|
|
2027
|
+
if (_isClobbered(currentNode)) {
|
|
2028
|
+
_forceRemove(currentNode);
|
|
2029
|
+
} else {
|
|
2030
|
+
arrayPop(DOMPurify.removed);
|
|
2031
|
+
}
|
|
2032
|
+
} catch (_) {
|
|
2033
|
+
_removeAttribute(name, currentNode);
|
|
2034
|
+
}
|
|
1167
2035
|
};
|
|
1168
2036
|
/**
|
|
1169
2037
|
* _sanitizeAttributes
|
|
@@ -1178,13 +2046,14 @@ var purify = {exports: {}};
|
|
|
1178
2046
|
const _sanitizeAttributes = function _sanitizeAttributes(currentNode) {
|
|
1179
2047
|
/* Execute a hook if present */
|
|
1180
2048
|
_executeHooks(hooks.beforeSanitizeAttributes, currentNode, null);
|
|
1181
|
-
const
|
|
1182
|
-
attributes
|
|
1183
|
-
} = currentNode;
|
|
2049
|
+
const attributes = currentNode.attributes;
|
|
1184
2050
|
/* Check if we have attributes; if not we might have a text node */
|
|
1185
2051
|
if (!attributes || _isClobbered(currentNode)) {
|
|
1186
2052
|
return;
|
|
1187
2053
|
}
|
|
2054
|
+
/* Same lazy-install guard as uponSanitizeElement (see there): fork the
|
|
2055
|
+
attribute allowlist off its shared binding before a hook can see it. */
|
|
2056
|
+
ALLOWED_ATTR = _forkSharedAllowlist(hooks.uponSanitizeAttribute, ALLOWED_ATTR, DEFAULT_ALLOWED_ATTR, SET_CONFIG_ALLOWED_ATTR);
|
|
1188
2057
|
const hookEvent = {
|
|
1189
2058
|
attrName: '',
|
|
1190
2059
|
attrValue: '',
|
|
@@ -1193,14 +2062,13 @@ var purify = {exports: {}};
|
|
|
1193
2062
|
forceKeepAttr: undefined
|
|
1194
2063
|
};
|
|
1195
2064
|
let l = attributes.length;
|
|
2065
|
+
const lcTag = transformCaseFunc(currentNode.nodeName);
|
|
1196
2066
|
/* Go backwards over all attributes; safely remove bad ones */
|
|
1197
2067
|
while (l--) {
|
|
1198
2068
|
const attr = attributes[l];
|
|
1199
|
-
const
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
value: attrValue
|
|
1203
|
-
} = attr;
|
|
2069
|
+
const name = attr.name,
|
|
2070
|
+
namespaceURI = attr.namespaceURI,
|
|
2071
|
+
attrValue = attr.value;
|
|
1204
2072
|
const lcName = transformCaseFunc(name);
|
|
1205
2073
|
const initValue = attrValue;
|
|
1206
2074
|
let value = name === 'value' ? initValue : stringTrim(initValue);
|
|
@@ -1214,12 +2082,14 @@ var purify = {exports: {}};
|
|
|
1214
2082
|
/* Full DOM Clobbering protection via namespace isolation,
|
|
1215
2083
|
* Prefix id and name attributes with `user-content-`
|
|
1216
2084
|
*/
|
|
1217
|
-
if (SANITIZE_NAMED_PROPS && (lcName === 'id' || lcName === 'name')) {
|
|
2085
|
+
if (SANITIZE_NAMED_PROPS && (lcName === 'id' || lcName === 'name') && stringIndexOf(value, SANITIZE_NAMED_PROPS_PREFIX) !== 0) {
|
|
1218
2086
|
// Remove the attribute with this value
|
|
1219
2087
|
_removeAttribute(name, currentNode);
|
|
1220
2088
|
// Prefix the value and later re-create the attribute with the sanitized value
|
|
1221
2089
|
value = SANITIZE_NAMED_PROPS_PREFIX + value;
|
|
1222
2090
|
}
|
|
2091
|
+
// Else: already prefixed, leave the attribute alone — the prefix is
|
|
2092
|
+
// itself the clobbering protection, and re-applying it is incorrect.
|
|
1223
2093
|
/* Work around a security issue with comments inside attributes */
|
|
1224
2094
|
if (SAFE_FOR_XML && regExpTest(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i, value)) {
|
|
1225
2095
|
_removeAttribute(name, currentNode);
|
|
@@ -1230,7 +2100,7 @@ var purify = {exports: {}};
|
|
|
1230
2100
|
_removeAttribute(name, currentNode);
|
|
1231
2101
|
continue;
|
|
1232
2102
|
}
|
|
1233
|
-
/* Did the hooks
|
|
2103
|
+
/* Did the hooks force-keep the attribute? */
|
|
1234
2104
|
if (hookEvent.forceKeepAttr) {
|
|
1235
2105
|
continue;
|
|
1236
2106
|
}
|
|
@@ -1240,56 +2110,24 @@ var purify = {exports: {}};
|
|
|
1240
2110
|
continue;
|
|
1241
2111
|
}
|
|
1242
2112
|
/* Work around a security issue in jQuery 3.0 */
|
|
1243
|
-
if (!ALLOW_SELF_CLOSE_IN_ATTR && regExpTest(
|
|
2113
|
+
if (!ALLOW_SELF_CLOSE_IN_ATTR && regExpTest(SELF_CLOSING_TAG, value)) {
|
|
1244
2114
|
_removeAttribute(name, currentNode);
|
|
1245
2115
|
continue;
|
|
1246
2116
|
}
|
|
1247
2117
|
/* Sanitize attribute content to be template-safe */
|
|
1248
2118
|
if (SAFE_FOR_TEMPLATES) {
|
|
1249
|
-
|
|
1250
|
-
value = stringReplace(value, expr, ' ');
|
|
1251
|
-
});
|
|
2119
|
+
value = _stripTemplateExpressions(value);
|
|
1252
2120
|
}
|
|
1253
2121
|
/* Is `value` valid for this attribute? */
|
|
1254
|
-
const lcTag = transformCaseFunc(currentNode.nodeName);
|
|
1255
2122
|
if (!_isValidAttribute(lcTag, lcName, value)) {
|
|
1256
2123
|
_removeAttribute(name, currentNode);
|
|
1257
2124
|
continue;
|
|
1258
2125
|
}
|
|
1259
2126
|
/* Handle attributes that require Trusted Types */
|
|
1260
|
-
|
|
1261
|
-
if (namespaceURI) ; else {
|
|
1262
|
-
switch (trustedTypes.getAttributeType(lcTag, lcName)) {
|
|
1263
|
-
case 'TrustedHTML':
|
|
1264
|
-
{
|
|
1265
|
-
value = trustedTypesPolicy.createHTML(value);
|
|
1266
|
-
break;
|
|
1267
|
-
}
|
|
1268
|
-
case 'TrustedScriptURL':
|
|
1269
|
-
{
|
|
1270
|
-
value = trustedTypesPolicy.createScriptURL(value);
|
|
1271
|
-
break;
|
|
1272
|
-
}
|
|
1273
|
-
}
|
|
1274
|
-
}
|
|
1275
|
-
}
|
|
2127
|
+
value = _applyTrustedTypesToAttribute(lcTag, lcName, namespaceURI, value);
|
|
1276
2128
|
/* Handle invalid data-* attribute set by try-catching it */
|
|
1277
2129
|
if (value !== initValue) {
|
|
1278
|
-
|
|
1279
|
-
if (namespaceURI) {
|
|
1280
|
-
currentNode.setAttributeNS(namespaceURI, name, value);
|
|
1281
|
-
} else {
|
|
1282
|
-
/* Fallback to setAttribute() for browser-unrecognized namespaces e.g. "x-schema". */
|
|
1283
|
-
currentNode.setAttribute(name, value);
|
|
1284
|
-
}
|
|
1285
|
-
if (_isClobbered(currentNode)) {
|
|
1286
|
-
_forceRemove(currentNode);
|
|
1287
|
-
} else {
|
|
1288
|
-
arrayPop(DOMPurify.removed);
|
|
1289
|
-
}
|
|
1290
|
-
} catch (_) {
|
|
1291
|
-
_removeAttribute(name, currentNode);
|
|
1292
|
-
}
|
|
2130
|
+
_setAttributeValue(currentNode, name, namespaceURI, value);
|
|
1293
2131
|
}
|
|
1294
2132
|
}
|
|
1295
2133
|
/* Execute a hook if present */
|
|
@@ -1309,17 +2147,136 @@ var purify = {exports: {}};
|
|
|
1309
2147
|
/* Execute a hook if present */
|
|
1310
2148
|
_executeHooks(hooks.uponSanitizeShadowNode, shadowNode, null);
|
|
1311
2149
|
/* Sanitize tags and elements */
|
|
1312
|
-
_sanitizeElements(shadowNode);
|
|
2150
|
+
_sanitizeElements(shadowNode, fragment);
|
|
1313
2151
|
/* Check attributes next */
|
|
1314
2152
|
_sanitizeAttributes(shadowNode);
|
|
1315
|
-
/* Deep shadow DOM detected
|
|
1316
|
-
|
|
2153
|
+
/* Deep shadow DOM detected.
|
|
2154
|
+
Realm-safe check (GHSA-hpcv-96wg-7vj8): use nodeType against the
|
|
2155
|
+
DOCUMENT_FRAGMENT_NODE constant rather than instanceof, so we
|
|
2156
|
+
recurse into <template>.content from foreign realms too. */
|
|
2157
|
+
if (_isDocumentFragment(shadowNode.content)) {
|
|
1317
2158
|
_sanitizeShadowDOM2(shadowNode.content);
|
|
1318
2159
|
}
|
|
2160
|
+
/* An element iterated here may itself host an attached
|
|
2161
|
+
shadow root. The default NodeIterator does not enter shadow
|
|
2162
|
+
trees, so a shadow root nested inside template.content was
|
|
2163
|
+
previously reached by no walk at all (the pre-pass at
|
|
2164
|
+
_sanitizeAttachedShadowRoots descends via childNodes, which
|
|
2165
|
+
doesn't enter template.content; the template-content recursion
|
|
2166
|
+
above iterates the content but never inspected shadowRoot).
|
|
2167
|
+
Walk it explicitly. The nodeType guard avoids reading
|
|
2168
|
+
shadowRoot off text / comment / CDATA / PI nodes that the
|
|
2169
|
+
iterator also surfaces. */
|
|
2170
|
+
const shadowNodeType = getNodeType ? getNodeType(shadowNode) : shadowNode.nodeType;
|
|
2171
|
+
if (shadowNodeType === NODE_TYPE.element) {
|
|
2172
|
+
const innerSr = getShadowRoot(shadowNode);
|
|
2173
|
+
if (_isDocumentFragment(innerSr)) {
|
|
2174
|
+
_sanitizeAttachedShadowRoots(innerSr);
|
|
2175
|
+
_sanitizeShadowDOM2(innerSr);
|
|
2176
|
+
}
|
|
2177
|
+
}
|
|
1319
2178
|
}
|
|
1320
2179
|
/* Execute a hook if present */
|
|
1321
2180
|
_executeHooks(hooks.afterSanitizeShadowDOM, fragment, null);
|
|
1322
2181
|
};
|
|
2182
|
+
/**
|
|
2183
|
+
* _sanitizeAttachedShadowRoots
|
|
2184
|
+
*
|
|
2185
|
+
* Walks `root` and feeds every attached shadow root we encounter into
|
|
2186
|
+
* the existing _sanitizeShadowDOM pipeline. The default node iterator
|
|
2187
|
+
* does not descend into shadow trees, so nodes inside an attached
|
|
2188
|
+
* shadow root would otherwise be skipped entirely.
|
|
2189
|
+
*
|
|
2190
|
+
* Two real input paths put attached shadow roots in front of us:
|
|
2191
|
+
* 1. IN_PLACE on a DOM node that already has shadow roots attached.
|
|
2192
|
+
* 2. DOM-node input where importNode(dirty, true) deep-clones the
|
|
2193
|
+
* shadow root because it was created with `clonable: true`.
|
|
2194
|
+
*
|
|
2195
|
+
* This pass runs once, up front, so the main iteration loop (and the
|
|
2196
|
+
* existing _sanitizeShadowDOM template-content recursion) stay
|
|
2197
|
+
* untouched — string-input paths are not affected.
|
|
2198
|
+
*
|
|
2199
|
+
* @param root the subtree root to walk for attached shadow roots
|
|
2200
|
+
*/
|
|
2201
|
+
const _sanitizeAttachedShadowRoots = function _sanitizeAttachedShadowRoots(root) {
|
|
2202
|
+
/* Iterative (explicit stack) rather than per-child recursion. DOM APIs
|
|
2203
|
+
impose no depth cap, so an attacker-shaped tree (JSON/CRDT/editor data
|
|
2204
|
+
built straight into the DOM — the IN_PLACE surface) deeper than the JS
|
|
2205
|
+
call-stack budget would otherwise overflow native recursion here and
|
|
2206
|
+
throw at the IN_PLACE entry pre-pass, before a single node is
|
|
2207
|
+
sanitized, leaving the caller's live tree untouched (fail-open). See
|
|
2208
|
+
campaign-3 F4. A heap stack keeps depth off the call stack.
|
|
2209
|
+
Each work item is either a node to descend into, or a deferred
|
|
2210
|
+
`_sanitizeShadowDOM` for an already-walked shadow root. The deferred
|
|
2211
|
+
form preserves the original post-order discipline: a shadow root's
|
|
2212
|
+
nested shadow roots are discovered before the outer shadow is
|
|
2213
|
+
sanitized (which may remove hosts). Pushes are in reverse of the
|
|
2214
|
+
desired processing order (LIFO): template content, then children, then
|
|
2215
|
+
the shadow-sanitize, then the shadow walk — so the order matches the
|
|
2216
|
+
previous recursion exactly. */
|
|
2217
|
+
const stack = [{
|
|
2218
|
+
node: root,
|
|
2219
|
+
shadow: null
|
|
2220
|
+
}];
|
|
2221
|
+
while (stack.length > 0) {
|
|
2222
|
+
const item = stack.pop();
|
|
2223
|
+
/* Deferred shadow-DOM sanitisation: runs after its subtree was walked. */
|
|
2224
|
+
if (item.shadow) {
|
|
2225
|
+
_sanitizeShadowDOM2(item.shadow);
|
|
2226
|
+
continue;
|
|
2227
|
+
}
|
|
2228
|
+
const node = item.node;
|
|
2229
|
+
const nodeType = getNodeType ? getNodeType(node) : node.nodeType;
|
|
2230
|
+
const isElement = nodeType === NODE_TYPE.element;
|
|
2231
|
+
/* (pushed last → processed first) Children, snapshotted in reverse so
|
|
2232
|
+
the first child is processed first. Snapshotting matters because a
|
|
2233
|
+
hook may detach siblings mid-walk. */
|
|
2234
|
+
const childNodes = getChildNodes(node);
|
|
2235
|
+
if (childNodes) {
|
|
2236
|
+
for (let i = childNodes.length - 1; i >= 0; --i) {
|
|
2237
|
+
stack.push({
|
|
2238
|
+
node: childNodes[i],
|
|
2239
|
+
shadow: null
|
|
2240
|
+
});
|
|
2241
|
+
}
|
|
2242
|
+
}
|
|
2243
|
+
/* (pushed before children → processed after them, matching the old
|
|
2244
|
+
"template content last" order) When the node is a <template>,
|
|
2245
|
+
descend into its content. */
|
|
2246
|
+
if (isElement) {
|
|
2247
|
+
const rootName = getNodeName ? getNodeName(node) : null;
|
|
2248
|
+
if (typeof rootName === 'string' && transformCaseFunc(rootName) === 'template') {
|
|
2249
|
+
const content = node.content;
|
|
2250
|
+
if (_isDocumentFragment(content)) {
|
|
2251
|
+
stack.push({
|
|
2252
|
+
node: content,
|
|
2253
|
+
shadow: null
|
|
2254
|
+
});
|
|
2255
|
+
}
|
|
2256
|
+
}
|
|
2257
|
+
}
|
|
2258
|
+
/* Shadow root (processed first): walk its subtree, then sanitise it.
|
|
2259
|
+
Realm-safe check (GHSA-hpcv-96wg-7vj8): nodeType-based detection
|
|
2260
|
+
rather than `instanceof DocumentFragment`, which is realm-bound and
|
|
2261
|
+
silently skipped foreign-realm shadow roots (e.g.
|
|
2262
|
+
iframe.contentDocument attachShadow). */
|
|
2263
|
+
if (isElement) {
|
|
2264
|
+
const sr = getShadowRoot(node);
|
|
2265
|
+
if (_isDocumentFragment(sr)) {
|
|
2266
|
+
/* Push the deferred sanitise first so it pops after the shadow
|
|
2267
|
+
walk we push next, i.e. nested shadow roots are discovered
|
|
2268
|
+
before this one is sanitised. */
|
|
2269
|
+
stack.push({
|
|
2270
|
+
node: null,
|
|
2271
|
+
shadow: sr
|
|
2272
|
+
}, {
|
|
2273
|
+
node: sr,
|
|
2274
|
+
shadow: null
|
|
2275
|
+
});
|
|
2276
|
+
}
|
|
2277
|
+
}
|
|
2278
|
+
}
|
|
2279
|
+
};
|
|
1323
2280
|
// eslint-disable-next-line complexity
|
|
1324
2281
|
DOMPurify.sanitize = function (dirty) {
|
|
1325
2282
|
let cfg = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
@@ -1336,13 +2293,9 @@ var purify = {exports: {}};
|
|
|
1336
2293
|
}
|
|
1337
2294
|
/* Stringify, in case dirty is an object */
|
|
1338
2295
|
if (typeof dirty !== 'string' && !_isNode(dirty)) {
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
throw typeErrorCreate('dirty is not a string, aborting');
|
|
1343
|
-
}
|
|
1344
|
-
} else {
|
|
1345
|
-
throw typeErrorCreate('toString is not a function');
|
|
2296
|
+
dirty = stringifyValue(dirty);
|
|
2297
|
+
if (typeof dirty !== 'string') {
|
|
2298
|
+
throw typeErrorCreate('dirty is not a string, aborting');
|
|
1346
2299
|
}
|
|
1347
2300
|
}
|
|
1348
2301
|
/* Return dirty HTML if DOMPurify cannot run */
|
|
@@ -1350,24 +2303,90 @@ var purify = {exports: {}};
|
|
|
1350
2303
|
return dirty;
|
|
1351
2304
|
}
|
|
1352
2305
|
/* Assign config vars */
|
|
1353
|
-
if (
|
|
2306
|
+
if (SET_CONFIG) {
|
|
2307
|
+
/* Persistent setConfig() path: _parseConfig is skipped, so the sets are
|
|
2308
|
+
* not re-derived per call. Restore them from the pristine bindings
|
|
2309
|
+
* captured at setConfig() time so a previous call's hook clone (mutated
|
|
2310
|
+
* below) does not carry over. */
|
|
2311
|
+
ALLOWED_TAGS = SET_CONFIG_ALLOWED_TAGS;
|
|
2312
|
+
ALLOWED_ATTR = SET_CONFIG_ALLOWED_ATTR;
|
|
2313
|
+
} else {
|
|
1354
2314
|
_parseConfig(cfg);
|
|
1355
2315
|
}
|
|
2316
|
+
/* Clone the hook-mutable allowlists before the walk whenever an
|
|
2317
|
+
* uponSanitize* hook is registered. The hook event exposes ALLOWED_TAGS
|
|
2318
|
+
* and ALLOWED_ATTR by reference (as allowedTags / allowedAttributes), so
|
|
2319
|
+
* a hook that widens them would otherwise mutate the shared set
|
|
2320
|
+
* permanently: across later calls and across every element. Cloning per
|
|
2321
|
+
* walk keeps documented in-call widening working while scoping it to the
|
|
2322
|
+
* call. A single guard for both config paths - the per-call path rebinds
|
|
2323
|
+
* the sets in _parseConfig each call, the persistent path restores them
|
|
2324
|
+
* from the captured bindings just above - so the two cannot diverge. */
|
|
2325
|
+
if (hooks.uponSanitizeElement.length > 0 || hooks.uponSanitizeAttribute.length > 0) {
|
|
2326
|
+
ALLOWED_TAGS = clone(ALLOWED_TAGS);
|
|
2327
|
+
}
|
|
2328
|
+
if (hooks.uponSanitizeAttribute.length > 0) {
|
|
2329
|
+
ALLOWED_ATTR = clone(ALLOWED_ATTR);
|
|
2330
|
+
}
|
|
1356
2331
|
/* Clean up removed elements */
|
|
1357
2332
|
DOMPurify.removed = [];
|
|
1358
|
-
/*
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
2333
|
+
/* Resolve IN_PLACE for this call without mutating persistent config.
|
|
2334
|
+
Writing the IN_PLACE closure variable here leaks under setConfig(),
|
|
2335
|
+
where _parseConfig is skipped on later calls: a single string call would
|
|
2336
|
+
disable in-place mode for every subsequent node call, returning a
|
|
2337
|
+
sanitized copy while leaving the caller's node — which in-place callers
|
|
2338
|
+
keep using and whose return value they ignore — unsanitized. REPORT-2. */
|
|
2339
|
+
const inPlace = IN_PLACE && typeof dirty !== 'string' && _isNode(dirty);
|
|
2340
|
+
if (inPlace) {
|
|
2341
|
+
/* Declarative-partial-updates / streaming pre-pass: sever every patch
|
|
2342
|
+
linkage across the live tree BEFORE the walk, so no patch can fire
|
|
2343
|
+
mid-walk and inject into an already-processed region. Runs first, so
|
|
2344
|
+
it also covers the forbidden/clobbered roots that throw below. */
|
|
2345
|
+
_neutralizePatchLinkage(dirty);
|
|
2346
|
+
/* Do some early pre-sanitization to avoid unsafe root nodes.
|
|
2347
|
+
Read nodeName through the cached prototype getter — a clobbering
|
|
2348
|
+
child named "nodeName" on the form root would otherwise shadow
|
|
2349
|
+
the property and let this check skip the root-allowlist
|
|
2350
|
+
validation entirely. */
|
|
2351
|
+
const nn = getNodeName ? getNodeName(dirty) : dirty.nodeName;
|
|
2352
|
+
if (typeof nn === 'string') {
|
|
2353
|
+
const tagName = transformCaseFunc(nn);
|
|
1366
2354
|
if (!ALLOWED_TAGS[tagName] || FORBID_TAGS[tagName]) {
|
|
2355
|
+
/* Fail closed on a live root: neutralize handlers/children before
|
|
2356
|
+
throwing, exactly as the mid-walk abort path does. */
|
|
2357
|
+
_neutralizeRoot(dirty);
|
|
1367
2358
|
throw typeErrorCreate('root node is forbidden and cannot be sanitized in-place');
|
|
1368
2359
|
}
|
|
1369
2360
|
}
|
|
1370
|
-
|
|
2361
|
+
/* Pre-flight the root through _isClobbered. The iterator-driven
|
|
2362
|
+
removal path can not detach a parent-less root: _forceRemove
|
|
2363
|
+
falls through to Element.prototype.remove(), which per spec
|
|
2364
|
+
is a no-op on a node with no parent. A clobbered root would
|
|
2365
|
+
then survive the main loop with its attributes uninspected,
|
|
2366
|
+
because _sanitizeAttributes early-returns on _isClobbered. The
|
|
2367
|
+
result would be an attacker-controlled form, complete with any
|
|
2368
|
+
event-handler attributes the caller passed in, handed back to
|
|
2369
|
+
the application unsanitized. Refuse to sanitize such a root
|
|
2370
|
+
the same way we refuse a forbidden tag. GHSA-r47g-fvhr-h676. */
|
|
2371
|
+
if (_isClobbered(dirty)) {
|
|
2372
|
+
/* Fail closed on a live clobbered root before throwing.
|
|
2373
|
+
_neutralizeRoot's reads are clobber-safe (cached getters); the
|
|
2374
|
+
form's non-clobbered descendants, e.g. an armed <img>, are scrubbed. */
|
|
2375
|
+
_neutralizeRoot(dirty);
|
|
2376
|
+
throw typeErrorCreate('root node is clobbered and cannot be sanitized in-place');
|
|
2377
|
+
}
|
|
2378
|
+
/* Sanitize attached shadow roots before the main iterator runs.
|
|
2379
|
+
The iterator does not descend into shadow trees. Same fail-closed
|
|
2380
|
+
barrier as the main walk (campaign-3 F2): a custom-element reaction
|
|
2381
|
+
inside a shadow root could abort this pre-pass before the walk runs,
|
|
2382
|
+
which would otherwise leave the entire live tree unsanitized. */
|
|
2383
|
+
try {
|
|
2384
|
+
_sanitizeAttachedShadowRoots(dirty);
|
|
2385
|
+
} catch (error) {
|
|
2386
|
+
_neutralizeRoot(dirty);
|
|
2387
|
+
throw error;
|
|
2388
|
+
}
|
|
2389
|
+
} else if (_isNode(dirty)) {
|
|
1371
2390
|
/* If dirty is a DOM element, append to an empty document to avoid
|
|
1372
2391
|
elements being stripped by the parser */
|
|
1373
2392
|
body = _initDocument('<!---->');
|
|
@@ -1381,12 +2400,18 @@ var purify = {exports: {}};
|
|
|
1381
2400
|
// eslint-disable-next-line unicorn/prefer-dom-node-append
|
|
1382
2401
|
body.appendChild(importedNode);
|
|
1383
2402
|
}
|
|
2403
|
+
/* Clonable shadow roots are deep-cloned by importNode(); sanitize
|
|
2404
|
+
them before the main iterator runs, since the iterator does not
|
|
2405
|
+
descend into shadow trees. The walk routes every read through a
|
|
2406
|
+
cached prototype getter so clobbering descendants on a form root
|
|
2407
|
+
cannot hide a shadow host from this pass. */
|
|
2408
|
+
_sanitizeAttachedShadowRoots(importedNode);
|
|
1384
2409
|
} else {
|
|
1385
2410
|
/* Exit directly if we have nothing to do */
|
|
1386
2411
|
if (!RETURN_DOM && !SAFE_FOR_TEMPLATES && !WHOLE_DOCUMENT &&
|
|
1387
2412
|
// eslint-disable-next-line unicorn/prefer-includes
|
|
1388
2413
|
dirty.indexOf('<') === -1) {
|
|
1389
|
-
return trustedTypesPolicy && RETURN_TRUSTED_TYPE ?
|
|
2414
|
+
return trustedTypesPolicy && RETURN_TRUSTED_TYPE ? _createTrustedHTML(dirty) : dirty;
|
|
1390
2415
|
}
|
|
1391
2416
|
/* Initialize the document to work on */
|
|
1392
2417
|
body = _initDocument(dirty);
|
|
@@ -1400,31 +2425,71 @@ var purify = {exports: {}};
|
|
|
1400
2425
|
_forceRemove(body.firstChild);
|
|
1401
2426
|
}
|
|
1402
2427
|
/* Get node iterator */
|
|
1403
|
-
const
|
|
1404
|
-
/* Now start iterating over the created document
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
2428
|
+
const walkRoot = inPlace ? dirty : body;
|
|
2429
|
+
/* Now start iterating over the created document.
|
|
2430
|
+
The walk runs inside an exception barrier (campaign-3 F2): a re-entrant
|
|
2431
|
+
engine/custom-element mutation can detach a node mid-walk so
|
|
2432
|
+
`_forceRemove`'s parentless guard throws, aborting the loop. Without the
|
|
2433
|
+
barrier the caller's in-place tree would be left half-sanitized with the
|
|
2434
|
+
unvisited tail still armed. _createNodeIterator itself is inside the
|
|
2435
|
+
barrier too: constructing the iterator dereferences the root's document,
|
|
2436
|
+
and any failure there (e.g. an exotic/clobbered root) must still fail
|
|
2437
|
+
closed rather than skip the neutralize. On any throw we fail closed -
|
|
2438
|
+
strip the in-place root bare - then rethrow so the existing throw
|
|
2439
|
+
contract is preserved. (String/DOM-copy paths never return the partial
|
|
2440
|
+
body, so the propagating throw is already fail-closed there.) */
|
|
2441
|
+
try {
|
|
2442
|
+
const nodeIterator = _createNodeIterator(walkRoot);
|
|
2443
|
+
while (currentNode = nodeIterator.nextNode()) {
|
|
2444
|
+
/* Sanitize tags and elements */
|
|
2445
|
+
_sanitizeElements(currentNode, walkRoot);
|
|
2446
|
+
/* Check attributes next */
|
|
2447
|
+
_sanitizeAttributes(currentNode);
|
|
2448
|
+
/* Shadow DOM detected, sanitize it.
|
|
2449
|
+
Realm-safe check (GHSA-hpcv-96wg-7vj8): nodeType-based detection
|
|
2450
|
+
instead of instanceof, so foreign-realm <template>.content is
|
|
2451
|
+
walked correctly. */
|
|
2452
|
+
if (_isDocumentFragment(currentNode.content)) {
|
|
2453
|
+
_sanitizeShadowDOM2(currentNode.content);
|
|
2454
|
+
}
|
|
1413
2455
|
}
|
|
2456
|
+
} catch (error) {
|
|
2457
|
+
if (inPlace) {
|
|
2458
|
+
_neutralizeRoot(dirty);
|
|
2459
|
+
/* Nodes _forceRemove'd earlier in the aborted walk are already
|
|
2460
|
+
detached from the root, so _neutralizeRoot's subtree pass does not
|
|
2461
|
+
reach them. Defuse them too, mirroring the success-path loop below. */
|
|
2462
|
+
arrayForEach(DOMPurify.removed, entry => {
|
|
2463
|
+
if (entry.element) {
|
|
2464
|
+
_neutralizeSubtree(entry.element);
|
|
2465
|
+
}
|
|
2466
|
+
});
|
|
2467
|
+
}
|
|
2468
|
+
throw error;
|
|
1414
2469
|
}
|
|
1415
2470
|
/* If we sanitized `dirty` in-place, return it. */
|
|
1416
|
-
if (
|
|
2471
|
+
if (inPlace) {
|
|
2472
|
+
/* Fail-closed completion of the audit-5 F1 fix: every node removed from
|
|
2473
|
+
the caller's live tree is detached but may still hold a queued
|
|
2474
|
+
resource-event handler that fires in page scope after we return. The
|
|
2475
|
+
move-hoist covers only disallowed-tag KEEP_CONTENT removals; strip the
|
|
2476
|
+
non-allow-listed attributes off every other removed subtree (clobber,
|
|
2477
|
+
mXSS, namespace, comments, KEEP_CONTENT:false, …) so those handlers are
|
|
2478
|
+
cancelled before any event can fire. Runs synchronously, pre-return. */
|
|
2479
|
+
arrayForEach(DOMPurify.removed, entry => {
|
|
2480
|
+
if (entry.element) {
|
|
2481
|
+
_neutralizeSubtree(entry.element);
|
|
2482
|
+
}
|
|
2483
|
+
});
|
|
2484
|
+
if (SAFE_FOR_TEMPLATES) {
|
|
2485
|
+
_scrubTemplateExpressions2(dirty);
|
|
2486
|
+
}
|
|
1417
2487
|
return dirty;
|
|
1418
2488
|
}
|
|
1419
2489
|
/* Return sanitized string or DOM */
|
|
1420
2490
|
if (RETURN_DOM) {
|
|
1421
2491
|
if (SAFE_FOR_TEMPLATES) {
|
|
1422
|
-
body
|
|
1423
|
-
let html = body.innerHTML;
|
|
1424
|
-
arrayForEach([MUSTACHE_EXPR, ERB_EXPR, TMPLIT_EXPR], expr => {
|
|
1425
|
-
html = stringReplace(html, expr, ' ');
|
|
1426
|
-
});
|
|
1427
|
-
body.innerHTML = html;
|
|
2492
|
+
_scrubTemplateExpressions2(body);
|
|
1428
2493
|
}
|
|
1429
2494
|
if (RETURN_DOM_FRAGMENT) {
|
|
1430
2495
|
returnNode = createDocumentFragment.call(body.ownerDocument);
|
|
@@ -1454,20 +2519,28 @@ var purify = {exports: {}};
|
|
|
1454
2519
|
}
|
|
1455
2520
|
/* Sanitize final string template-safe */
|
|
1456
2521
|
if (SAFE_FOR_TEMPLATES) {
|
|
1457
|
-
|
|
1458
|
-
serializedHTML = stringReplace(serializedHTML, expr, ' ');
|
|
1459
|
-
});
|
|
2522
|
+
serializedHTML = _stripTemplateExpressions(serializedHTML);
|
|
1460
2523
|
}
|
|
1461
|
-
return trustedTypesPolicy && RETURN_TRUSTED_TYPE ?
|
|
2524
|
+
return trustedTypesPolicy && RETURN_TRUSTED_TYPE ? _createTrustedHTML(serializedHTML) : serializedHTML;
|
|
1462
2525
|
};
|
|
1463
2526
|
DOMPurify.setConfig = function () {
|
|
1464
2527
|
let cfg = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
1465
2528
|
_parseConfig(cfg);
|
|
1466
2529
|
SET_CONFIG = true;
|
|
2530
|
+
SET_CONFIG_ALLOWED_TAGS = ALLOWED_TAGS;
|
|
2531
|
+
SET_CONFIG_ALLOWED_ATTR = ALLOWED_ATTR;
|
|
1467
2532
|
};
|
|
1468
2533
|
DOMPurify.clearConfig = function () {
|
|
1469
2534
|
CONFIG = null;
|
|
1470
2535
|
SET_CONFIG = false;
|
|
2536
|
+
SET_CONFIG_ALLOWED_TAGS = null;
|
|
2537
|
+
SET_CONFIG_ALLOWED_ATTR = null;
|
|
2538
|
+
// Drop any caller-supplied Trusted Types policy so it cannot poison later
|
|
2539
|
+
// `RETURN_TRUSTED_TYPE` output. The internal default policy (cached, and
|
|
2540
|
+
// never recreated — Trusted Types throws on duplicate names) is restored by
|
|
2541
|
+
// the next `_parseConfig`. See GHSA-vxr8-fq34-vvx9.
|
|
2542
|
+
trustedTypesPolicy = defaultTrustedTypesPolicy;
|
|
2543
|
+
emptyHTML = '';
|
|
1471
2544
|
};
|
|
1472
2545
|
DOMPurify.isValidAttribute = function (tag, attr, value) {
|
|
1473
2546
|
/* Initialize shared config vars if necessary. */
|
|
@@ -1482,9 +2555,19 @@ var purify = {exports: {}};
|
|
|
1482
2555
|
if (typeof hookFunction !== 'function') {
|
|
1483
2556
|
return;
|
|
1484
2557
|
}
|
|
2558
|
+
/* Reject unknown entry points. Without this, a non-hook key (e.g.
|
|
2559
|
+
* '__proto__') indexes off the prototype chain rather than a real
|
|
2560
|
+
* hook array, and arrayPush then writes to Object.prototype. Guard
|
|
2561
|
+
* with an own-property check against the known hook names. */
|
|
2562
|
+
if (!objectHasOwnProperty(hooks, entryPoint)) {
|
|
2563
|
+
return;
|
|
2564
|
+
}
|
|
1485
2565
|
arrayPush(hooks[entryPoint], hookFunction);
|
|
1486
2566
|
};
|
|
1487
2567
|
DOMPurify.removeHook = function (entryPoint, hookFunction) {
|
|
2568
|
+
if (!objectHasOwnProperty(hooks, entryPoint)) {
|
|
2569
|
+
return undefined;
|
|
2570
|
+
}
|
|
1488
2571
|
if (hookFunction !== undefined) {
|
|
1489
2572
|
const index = arrayLastIndexOf(hooks[entryPoint], hookFunction);
|
|
1490
2573
|
return index === -1 ? undefined : arraySplice(hooks[entryPoint], index, 1)[0];
|
|
@@ -1492,6 +2575,9 @@ var purify = {exports: {}};
|
|
|
1492
2575
|
return arrayPop(hooks[entryPoint]);
|
|
1493
2576
|
};
|
|
1494
2577
|
DOMPurify.removeHooks = function (entryPoint) {
|
|
2578
|
+
if (!objectHasOwnProperty(hooks, entryPoint)) {
|
|
2579
|
+
return;
|
|
2580
|
+
}
|
|
1495
2581
|
hooks[entryPoint] = [];
|
|
1496
2582
|
};
|
|
1497
2583
|
DOMPurify.removeAllHooks = function () {
|