tinymce-rails 8.6.0 → 8.8.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.
- checksums.yaml +4 -4
- data/app/assets/source/tinymce/tinymce.js +1206 -290
- data/lib/tinymce/rails/version.rb +2 -2
- data/vendor/assets/javascripts/tinymce/icons/default/icons.js +1 -1
- data/vendor/assets/javascripts/tinymce/plugins/autolink/plugin.js +1 -1
- data/vendor/assets/javascripts/tinymce/plugins/autosave/plugin.js +1 -1
- data/vendor/assets/javascripts/tinymce/plugins/codesample/plugin.js +2 -2
- data/vendor/assets/javascripts/tinymce/plugins/emoticons/plugin.js +1 -1
- data/vendor/assets/javascripts/tinymce/plugins/help/plugin.js +1 -1
- data/vendor/assets/javascripts/tinymce/plugins/image/plugin.js +1 -1
- data/vendor/assets/javascripts/tinymce/plugins/link/plugin.js +1 -1
- data/vendor/assets/javascripts/tinymce/plugins/preview/plugin.js +1 -1
- data/vendor/assets/javascripts/tinymce/plugins/table/plugin.js +1 -1
- data/vendor/assets/javascripts/tinymce/skins/content/dark/content.css +1 -1
- data/vendor/assets/javascripts/tinymce/skins/content/dark/content.js +1 -1
- data/vendor/assets/javascripts/tinymce/skins/content/dark/content.min.css +1 -1
- data/vendor/assets/javascripts/tinymce/skins/ui/oxide/content.css +1 -1
- data/vendor/assets/javascripts/tinymce/skins/ui/oxide/content.inline.css +1 -1
- data/vendor/assets/javascripts/tinymce/skins/ui/oxide/content.inline.js +1 -1
- data/vendor/assets/javascripts/tinymce/skins/ui/oxide/content.inline.min.css +1 -1
- data/vendor/assets/javascripts/tinymce/skins/ui/oxide/content.js +1 -1
- data/vendor/assets/javascripts/tinymce/skins/ui/oxide/content.min.css +1 -1
- data/vendor/assets/javascripts/tinymce/skins/ui/oxide/skin.css +1 -1
- data/vendor/assets/javascripts/tinymce/skins/ui/oxide/skin.js +1 -1
- data/vendor/assets/javascripts/tinymce/skins/ui/oxide/skin.min.css +1 -1
- data/vendor/assets/javascripts/tinymce/skins/ui/oxide-dark/content.css +1 -1
- data/vendor/assets/javascripts/tinymce/skins/ui/oxide-dark/content.inline.css +1 -1
- data/vendor/assets/javascripts/tinymce/skins/ui/oxide-dark/content.inline.js +1 -1
- data/vendor/assets/javascripts/tinymce/skins/ui/oxide-dark/content.inline.min.css +1 -1
- data/vendor/assets/javascripts/tinymce/skins/ui/oxide-dark/content.js +1 -1
- data/vendor/assets/javascripts/tinymce/skins/ui/oxide-dark/content.min.css +1 -1
- data/vendor/assets/javascripts/tinymce/skins/ui/oxide-dark/skin.css +1 -1
- data/vendor/assets/javascripts/tinymce/skins/ui/oxide-dark/skin.js +1 -1
- data/vendor/assets/javascripts/tinymce/skins/ui/oxide-dark/skin.min.css +1 -1
- data/vendor/assets/javascripts/tinymce/skins/ui/tinymce-5/content.css +1 -1
- data/vendor/assets/javascripts/tinymce/skins/ui/tinymce-5/content.inline.css +1 -1
- data/vendor/assets/javascripts/tinymce/skins/ui/tinymce-5/content.inline.js +1 -1
- data/vendor/assets/javascripts/tinymce/skins/ui/tinymce-5/content.inline.min.css +1 -1
- data/vendor/assets/javascripts/tinymce/skins/ui/tinymce-5/content.js +1 -1
- data/vendor/assets/javascripts/tinymce/skins/ui/tinymce-5/content.min.css +1 -1
- data/vendor/assets/javascripts/tinymce/skins/ui/tinymce-5/skin.css +1 -1
- data/vendor/assets/javascripts/tinymce/skins/ui/tinymce-5/skin.js +1 -1
- data/vendor/assets/javascripts/tinymce/skins/ui/tinymce-5/skin.min.css +1 -1
- data/vendor/assets/javascripts/tinymce/skins/ui/tinymce-5-dark/content.css +1 -1
- data/vendor/assets/javascripts/tinymce/skins/ui/tinymce-5-dark/content.inline.css +1 -1
- data/vendor/assets/javascripts/tinymce/skins/ui/tinymce-5-dark/content.inline.js +1 -1
- data/vendor/assets/javascripts/tinymce/skins/ui/tinymce-5-dark/content.inline.min.css +1 -1
- data/vendor/assets/javascripts/tinymce/skins/ui/tinymce-5-dark/content.js +1 -1
- data/vendor/assets/javascripts/tinymce/skins/ui/tinymce-5-dark/content.min.css +1 -1
- data/vendor/assets/javascripts/tinymce/skins/ui/tinymce-5-dark/skin.css +1 -1
- data/vendor/assets/javascripts/tinymce/skins/ui/tinymce-5-dark/skin.js +1 -1
- data/vendor/assets/javascripts/tinymce/skins/ui/tinymce-5-dark/skin.min.css +1 -1
- data/vendor/assets/javascripts/tinymce/themes/silver/theme.js +3 -3
- data/vendor/assets/javascripts/tinymce/tinymce.d.ts +11 -1
- data/vendor/assets/javascripts/tinymce/tinymce.js +5 -5
- metadata +2 -2
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* TinyMCE version 8.
|
|
2
|
+
* TinyMCE version 8.8.0 (2026-07-15)
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
5
|
(function () {
|
|
@@ -573,14 +573,16 @@
|
|
|
573
573
|
}
|
|
574
574
|
return Optional.none();
|
|
575
575
|
};
|
|
576
|
-
const
|
|
576
|
+
const findLastByPredicate = (arr, pred) => {
|
|
577
577
|
for (let i = arr.length - 1; i >= 0; i--) {
|
|
578
578
|
if (pred(arr[i], i)) {
|
|
579
|
-
return Optional.some(i);
|
|
579
|
+
return Optional.some({ v: arr[i], i });
|
|
580
580
|
}
|
|
581
581
|
}
|
|
582
582
|
return Optional.none();
|
|
583
583
|
};
|
|
584
|
+
const findLast = (arr, pred) => findLastByPredicate(arr, pred).map((r) => r.v);
|
|
585
|
+
const findLastIndex = (arr, pred) => findLastByPredicate(arr, pred).map((r) => r.i);
|
|
584
586
|
const flatten$1 = (xs) => {
|
|
585
587
|
// Note, this is possible because push supports multiple arguments:
|
|
586
588
|
// http://jsperf.com/concat-push/6
|
|
@@ -2198,14 +2200,14 @@
|
|
|
2198
2200
|
const siblings = (element) => {
|
|
2199
2201
|
// TODO: Refactor out children so we can just not add self instead of filtering afterwards
|
|
2200
2202
|
const filterSelf = (elements) => filter$5(elements, (x) => !eq(element, x));
|
|
2201
|
-
return parent(element).map(children$
|
|
2203
|
+
return parent(element).map(children$2).map(filterSelf).getOr([]);
|
|
2202
2204
|
};
|
|
2203
2205
|
const prevSibling = (element) => Optional.from(element.dom.previousSibling).map(SugarElement.fromDom);
|
|
2204
2206
|
const nextSibling = (element) => Optional.from(element.dom.nextSibling).map(SugarElement.fromDom);
|
|
2205
2207
|
// This one needs to be reversed, so they're still in DOM order
|
|
2206
2208
|
const prevSiblings = (element) => reverse(toArray(element, prevSibling));
|
|
2207
2209
|
const nextSiblings = (element) => toArray(element, nextSibling);
|
|
2208
|
-
const children$
|
|
2210
|
+
const children$2 = (element) => map$3(element.dom.childNodes, SugarElement.fromDom);
|
|
2209
2211
|
const child$1 = (element, index) => {
|
|
2210
2212
|
const cs = element.dom.childNodes;
|
|
2211
2213
|
return Optional.from(cs[index]).map(SugarElement.fromDom);
|
|
@@ -2442,7 +2444,7 @@
|
|
|
2442
2444
|
// than removing every child node manually.
|
|
2443
2445
|
// The following is (probably) safe for performance as 99.9% of the time the trick works and
|
|
2444
2446
|
// Traverse.children will return an empty array.
|
|
2445
|
-
each$e(children$
|
|
2447
|
+
each$e(children$2(element), (rogue) => {
|
|
2446
2448
|
remove$8(rogue);
|
|
2447
2449
|
});
|
|
2448
2450
|
};
|
|
@@ -2453,7 +2455,7 @@
|
|
|
2453
2455
|
}
|
|
2454
2456
|
};
|
|
2455
2457
|
const unwrap = (wrapper) => {
|
|
2456
|
-
const children = children$
|
|
2458
|
+
const children = children$2(wrapper);
|
|
2457
2459
|
if (children.length > 0) {
|
|
2458
2460
|
after$3(wrapper, children);
|
|
2459
2461
|
}
|
|
@@ -2476,7 +2478,7 @@
|
|
|
2476
2478
|
const mutate = (original, tag) => {
|
|
2477
2479
|
const nu = shallowAs(original, tag);
|
|
2478
2480
|
after$4(original, nu);
|
|
2479
|
-
const children = children$
|
|
2481
|
+
const children = children$2(original);
|
|
2480
2482
|
append(nu, children);
|
|
2481
2483
|
remove$8(original);
|
|
2482
2484
|
return nu;
|
|
@@ -2486,7 +2488,7 @@
|
|
|
2486
2488
|
const doc = scope || document;
|
|
2487
2489
|
const div = doc.createElement('div');
|
|
2488
2490
|
div.innerHTML = html;
|
|
2489
|
-
return children$
|
|
2491
|
+
return children$2(SugarElement.fromDom(div));
|
|
2490
2492
|
};
|
|
2491
2493
|
const fromDom$1 = (nodes) => map$3(nodes, SugarElement.fromDom);
|
|
2492
2494
|
|
|
@@ -2526,6 +2528,14 @@
|
|
|
2526
2528
|
const doc = dom.ownerDocument;
|
|
2527
2529
|
return getShadowRoot(SugarElement.fromDom(dom)).fold(() => doc.body.contains(dom), compose1(inBody, getShadowHost));
|
|
2528
2530
|
};
|
|
2531
|
+
const body = () => getBody(SugarElement.fromDom(document));
|
|
2532
|
+
const getBody = (doc) => {
|
|
2533
|
+
const b = doc.dom.body;
|
|
2534
|
+
if (b === null || b === undefined) {
|
|
2535
|
+
throw new Error('Body is not available yet');
|
|
2536
|
+
}
|
|
2537
|
+
return SugarElement.fromDom(b);
|
|
2538
|
+
};
|
|
2529
2539
|
|
|
2530
2540
|
const internalSet = (dom, property, value) => {
|
|
2531
2541
|
// This is going to hurt. Apologies.
|
|
@@ -2999,11 +3009,11 @@
|
|
|
2999
3009
|
};
|
|
3000
3010
|
|
|
3001
3011
|
const ancestors$1 = (scope, predicate, isRoot) => filter$5(parents$1(scope, isRoot), predicate);
|
|
3002
|
-
const children = (scope, predicate) => filter$5(children$
|
|
3012
|
+
const children$1 = (scope, predicate) => filter$5(children$2(scope), predicate);
|
|
3003
3013
|
const descendants$1 = (scope, predicate) => {
|
|
3004
3014
|
let result = [];
|
|
3005
3015
|
// Recurse.toArray() might help here
|
|
3006
|
-
each$e(children$
|
|
3016
|
+
each$e(children$2(scope), (x) => {
|
|
3007
3017
|
if (predicate(x)) {
|
|
3008
3018
|
result = result.concat([x]);
|
|
3009
3019
|
}
|
|
@@ -3021,6 +3031,10 @@
|
|
|
3021
3031
|
// It may surprise you to learn this is exactly what JQuery does
|
|
3022
3032
|
// TODO: Avoid all this wrapping and unwrapping
|
|
3023
3033
|
ancestors$1(scope, (e) => is$2(e, selector), isRoot);
|
|
3034
|
+
const children = (scope, selector) =>
|
|
3035
|
+
// It may surprise you to learn this is exactly what JQuery does
|
|
3036
|
+
// TODO: Avoid all the wrapping and unwrapping
|
|
3037
|
+
children$1(scope, (e) => is$2(e, selector));
|
|
3024
3038
|
const descendants = (scope, selector) => all(selector, scope);
|
|
3025
3039
|
|
|
3026
3040
|
const ancestor$3 = (scope, predicate, isRoot) => ancestor$5(scope, predicate, isRoot).isSome();
|
|
@@ -3205,6 +3219,20 @@
|
|
|
3205
3219
|
};
|
|
3206
3220
|
const getAtPoint = (win, x, y) => fromPoint$1(win, x, y);
|
|
3207
3221
|
|
|
3222
|
+
const getImageSize = (url) => new Promise((resolve, reject) => {
|
|
3223
|
+
const img = document.createElement('img');
|
|
3224
|
+
img.addEventListener('load', () => {
|
|
3225
|
+
resolve({
|
|
3226
|
+
width: img.naturalWidth,
|
|
3227
|
+
height: img.naturalHeight
|
|
3228
|
+
});
|
|
3229
|
+
});
|
|
3230
|
+
img.addEventListener('error', () => {
|
|
3231
|
+
reject(`Failed to get image dimensions for: ${url}`);
|
|
3232
|
+
});
|
|
3233
|
+
img.src = url;
|
|
3234
|
+
});
|
|
3235
|
+
|
|
3208
3236
|
const get$2 = (_win) => {
|
|
3209
3237
|
const win = _win === undefined ? window : _win;
|
|
3210
3238
|
if (detect$1().browser.isFirefox()) {
|
|
@@ -3660,7 +3688,7 @@
|
|
|
3660
3688
|
const isRoot = (el) => eq(el, rootNode);
|
|
3661
3689
|
each$e(fromDom$1(transparentBlocks), (transparentBlock) => {
|
|
3662
3690
|
ancestor$5(transparentBlock, isBlock, isRoot).each((parentBlock) => {
|
|
3663
|
-
const invalidChildren = children(transparentBlock, (el) => isBlock(el) && !schema.isValidChild(name(parentBlock), name(el)));
|
|
3691
|
+
const invalidChildren = children$1(transparentBlock, (el) => isBlock(el) && !schema.isValidChild(name(parentBlock), name(el)));
|
|
3664
3692
|
if (invalidChildren.length > 0) {
|
|
3665
3693
|
const stateScope = parentElement(parentBlock);
|
|
3666
3694
|
each$e(invalidChildren, (child) => {
|
|
@@ -3711,7 +3739,7 @@
|
|
|
3711
3739
|
// this tries to compensate for that by detecting if that offsets are incorrect and then remove the height
|
|
3712
3740
|
const getTableCaptionDeltaY = (elm) => {
|
|
3713
3741
|
if (browser$2.isFirefox() && name(elm) === 'table') {
|
|
3714
|
-
return firstElement(children$
|
|
3742
|
+
return firstElement(children$2(elm)).filter((elm) => {
|
|
3715
3743
|
return name(elm) === 'caption';
|
|
3716
3744
|
}).bind((caption) => {
|
|
3717
3745
|
return firstElement(nextSiblings(caption)).map((body) => {
|
|
@@ -5594,12 +5622,16 @@
|
|
|
5594
5622
|
let matches;
|
|
5595
5623
|
while ((matches = styleRegExp.exec(css))) {
|
|
5596
5624
|
styleRegExp.lastIndex = matches.index + matches[0].length;
|
|
5597
|
-
let name = matches[1].replace(trimRightRegExp, '')
|
|
5625
|
+
let name = matches[1].replace(trimRightRegExp, '');
|
|
5598
5626
|
let value = matches[2].replace(trimRightRegExp, '');
|
|
5599
5627
|
if (name && value) {
|
|
5600
5628
|
// Decode escaped sequences like \65 -> e
|
|
5601
5629
|
name = decodeHexSequences(name);
|
|
5602
5630
|
value = decodeHexSequences(value);
|
|
5631
|
+
// Custom properties (--*) keep user case; standard names normalize to lowercase
|
|
5632
|
+
if (!name.startsWith('--')) {
|
|
5633
|
+
name = name.toLowerCase();
|
|
5634
|
+
}
|
|
5603
5635
|
// Skip properties with double quotes and sequences like \" \' in their names
|
|
5604
5636
|
// See 'mXSS Attacks: Attacking well-secured Web-Applications by using innerHTML Mutations'
|
|
5605
5637
|
// https://cure53.de/fp170.pdf
|
|
@@ -5614,9 +5646,6 @@
|
|
|
5614
5646
|
if (name === 'font-weight' && value === '700') {
|
|
5615
5647
|
value = 'bold';
|
|
5616
5648
|
}
|
|
5617
|
-
else if (name === 'color' || name === 'background-color') { // Lowercase colors like RED
|
|
5618
|
-
value = value.toLowerCase();
|
|
5619
|
-
}
|
|
5620
5649
|
// Convert RGB colors to HEX
|
|
5621
5650
|
if (getColorFormat(value) === 'rgb') {
|
|
5622
5651
|
fromString(value).each((rgba) => {
|
|
@@ -6591,7 +6620,7 @@
|
|
|
6591
6620
|
const $node = SugarElement.fromDom(n);
|
|
6592
6621
|
if (keepChildren) {
|
|
6593
6622
|
// Unwrap but don't keep any empty text nodes
|
|
6594
|
-
each$e(children$
|
|
6623
|
+
each$e(children$2($node), (child) => {
|
|
6595
6624
|
if (isText$c(child) && child.dom.length === 0) {
|
|
6596
6625
|
remove$8(child);
|
|
6597
6626
|
}
|
|
@@ -12736,7 +12765,7 @@
|
|
|
12736
12765
|
switch (ctx) {
|
|
12737
12766
|
case "invalid-child" /* ChildContext.InvalidChild */: {
|
|
12738
12767
|
finishWrapper();
|
|
12739
|
-
const children = children$
|
|
12768
|
+
const children = children$2(elem);
|
|
12740
12769
|
processElements(children);
|
|
12741
12770
|
finishWrapper();
|
|
12742
12771
|
break;
|
|
@@ -12890,6 +12919,113 @@
|
|
|
12890
12919
|
};
|
|
12891
12920
|
};
|
|
12892
12921
|
|
|
12922
|
+
const announcerContainerId = generate('tiny-aria-announcer');
|
|
12923
|
+
const POLITE_MESSAGE_TTL_MS = 600000; // 10 minutes
|
|
12924
|
+
const CREATE_DELAY_MS = 100; // Delay before creating announcer regions to avoid interfering with screen readers initial announcements.
|
|
12925
|
+
const politeTimestampAttr = 'data-mce-announced-at';
|
|
12926
|
+
const OFFSCREEN_STYLES = {
|
|
12927
|
+
position: 'absolute',
|
|
12928
|
+
left: '-9999px',
|
|
12929
|
+
width: '1px',
|
|
12930
|
+
height: '1px',
|
|
12931
|
+
overflow: 'hidden'
|
|
12932
|
+
};
|
|
12933
|
+
const createRegion = (live) => {
|
|
12934
|
+
const region = SugarElement.fromTag('div');
|
|
12935
|
+
setAll$1(region, {
|
|
12936
|
+
'aria-live': live,
|
|
12937
|
+
'aria-atomic': 'false',
|
|
12938
|
+
'aria-relevant': 'additions'
|
|
12939
|
+
});
|
|
12940
|
+
return region;
|
|
12941
|
+
};
|
|
12942
|
+
const isConnected = (element) => element.dom.isConnected;
|
|
12943
|
+
const createNewState = () => {
|
|
12944
|
+
const container = SugarElement.fromTag('div');
|
|
12945
|
+
const politeRegion = createRegion('polite');
|
|
12946
|
+
const assertiveRegion = createRegion('assertive');
|
|
12947
|
+
set$5(container, 'id', announcerContainerId);
|
|
12948
|
+
setAll(container, OFFSCREEN_STYLES);
|
|
12949
|
+
append$1(container, politeRegion);
|
|
12950
|
+
append$1(container, assertiveRegion);
|
|
12951
|
+
append$1(body(), container);
|
|
12952
|
+
return { container, politeRegion, assertiveRegion };
|
|
12953
|
+
};
|
|
12954
|
+
const cleanupExpiredMessages = (polite, now) => {
|
|
12955
|
+
each$e(children(polite, `div[${politeTimestampAttr}]`), (messageDiv) => {
|
|
12956
|
+
getOpt(messageDiv, politeTimestampAttr)
|
|
12957
|
+
.bind((value) => toInt(value))
|
|
12958
|
+
.filter((announcedAt) => now - announcedAt > POLITE_MESSAGE_TTL_MS)
|
|
12959
|
+
.each(() => remove$8(messageDiv));
|
|
12960
|
+
});
|
|
12961
|
+
};
|
|
12962
|
+
const createAnnouncer = () => {
|
|
12963
|
+
const state = value$1();
|
|
12964
|
+
const mountRegions = async () => {
|
|
12965
|
+
const createNewPendingState = async () => {
|
|
12966
|
+
const promise = new Promise((resolve) => {
|
|
12967
|
+
const newState = createNewState();
|
|
12968
|
+
setTimeout(() => resolve(newState), CREATE_DELAY_MS);
|
|
12969
|
+
});
|
|
12970
|
+
state.set(promise);
|
|
12971
|
+
return promise;
|
|
12972
|
+
};
|
|
12973
|
+
return state.get().fold(createNewPendingState, async (existingPromise) => {
|
|
12974
|
+
const { container } = await existingPromise;
|
|
12975
|
+
if (isConnected(container)) {
|
|
12976
|
+
return existingPromise;
|
|
12977
|
+
}
|
|
12978
|
+
else {
|
|
12979
|
+
// A concurrent caller may have already replaced the stale state while we awaited.
|
|
12980
|
+
// The block after the await runs atomically, so reuse that state if present and
|
|
12981
|
+
// only create a fresh one when the state is still the stale promise we observed.
|
|
12982
|
+
return state.get().filter((current) => current !== existingPromise).getOrThunk(createNewPendingState);
|
|
12983
|
+
}
|
|
12984
|
+
});
|
|
12985
|
+
};
|
|
12986
|
+
const addMessage = (region, message) => {
|
|
12987
|
+
const now = Date.now();
|
|
12988
|
+
cleanupExpiredMessages(region, now);
|
|
12989
|
+
const messageDiv = SugarElement.fromTag('div');
|
|
12990
|
+
set$5(messageDiv, politeTimestampAttr, String(now));
|
|
12991
|
+
append$1(messageDiv, SugarElement.fromText(message));
|
|
12992
|
+
append$1(region, messageDiv);
|
|
12993
|
+
};
|
|
12994
|
+
const polite = async (message) => {
|
|
12995
|
+
const { politeRegion } = await mountRegions();
|
|
12996
|
+
addMessage(politeRegion, message);
|
|
12997
|
+
};
|
|
12998
|
+
const assertive = async (message) => {
|
|
12999
|
+
const { assertiveRegion } = await mountRegions();
|
|
13000
|
+
addMessage(assertiveRegion, message);
|
|
13001
|
+
};
|
|
13002
|
+
return { polite, assertive };
|
|
13003
|
+
};
|
|
13004
|
+
|
|
13005
|
+
const announcer = createAnnouncer();
|
|
13006
|
+
/**
|
|
13007
|
+
* Announces a message to screen readers via an aria-live region, without shifting focus.
|
|
13008
|
+
*
|
|
13009
|
+
* @method announce
|
|
13010
|
+
* @param {String} message The message to announce to screen readers.
|
|
13011
|
+
* @param {Object} options Optional settings.
|
|
13012
|
+
* @param {Boolean} options.assertive If true, uses aria-live="assertive" instead of polite.
|
|
13013
|
+
* @example
|
|
13014
|
+
* tinymce.dom.AriaAnnouncer.announce('Bold on');
|
|
13015
|
+
* tinymce.dom.AriaAnnouncer.announce('Error occurred', { assertive: true });
|
|
13016
|
+
*/
|
|
13017
|
+
const announce = (message, options) => {
|
|
13018
|
+
if (options?.assertive === true) {
|
|
13019
|
+
announcer.assertive(message).catch(noop);
|
|
13020
|
+
}
|
|
13021
|
+
else {
|
|
13022
|
+
announcer.polite(message).catch(noop);
|
|
13023
|
+
}
|
|
13024
|
+
};
|
|
13025
|
+
const AriaAnnouncer = {
|
|
13026
|
+
announce
|
|
13027
|
+
};
|
|
13028
|
+
|
|
12893
13029
|
/**
|
|
12894
13030
|
* Constructs a new BookmarkManager instance for a specific selection instance.
|
|
12895
13031
|
*
|
|
@@ -12954,7 +13090,7 @@
|
|
|
12954
13090
|
};
|
|
12955
13091
|
|
|
12956
13092
|
const clamp$1 = (offset, element) => {
|
|
12957
|
-
const max = isText$c(element) ? get$5(element).length : children$
|
|
13093
|
+
const max = isText$c(element) ? get$5(element).length : children$2(element).length + 1;
|
|
12958
13094
|
if (offset > max) {
|
|
12959
13095
|
return max;
|
|
12960
13096
|
}
|
|
@@ -14226,7 +14362,7 @@
|
|
|
14226
14362
|
editor.dispatch('AfterScrollIntoView', data);
|
|
14227
14363
|
};
|
|
14228
14364
|
const descend = (element, offset) => {
|
|
14229
|
-
const children = children$
|
|
14365
|
+
const children = children$2(element);
|
|
14230
14366
|
if (children.length === 0 || excludeFromDescend(element)) {
|
|
14231
14367
|
return { element, offset };
|
|
14232
14368
|
}
|
|
@@ -14246,7 +14382,7 @@
|
|
|
14246
14382
|
return { element: last, offset: get$5(last).length };
|
|
14247
14383
|
}
|
|
14248
14384
|
else {
|
|
14249
|
-
return { element: last, offset: children$
|
|
14385
|
+
return { element: last, offset: children$2(last).length };
|
|
14250
14386
|
}
|
|
14251
14387
|
}
|
|
14252
14388
|
}
|
|
@@ -15750,7 +15886,7 @@
|
|
|
15750
15886
|
const br = SugarElement.fromHtml('<br data-mce-bogus="1">');
|
|
15751
15887
|
// Remove all bogus elements except caret
|
|
15752
15888
|
if (preserveEmptyCaret) {
|
|
15753
|
-
each$e(children$
|
|
15889
|
+
each$e(children$2(elm), (node) => {
|
|
15754
15890
|
if (!isEmptyCaretFormatElement(node)) {
|
|
15755
15891
|
remove$8(node);
|
|
15756
15892
|
}
|
|
@@ -15922,7 +16058,7 @@
|
|
|
15922
16058
|
// Clean up any additional leftover nodes. If the last block wasn't a direct child, then we also need to clean up siblings
|
|
15923
16059
|
if (!eq(root, lastBlock)) {
|
|
15924
16060
|
const additionalCleanupNodes = is$4(parent(lastBlock), root) ? [] : siblings(lastBlock);
|
|
15925
|
-
each$e(additionalCleanupNodes.concat(children$
|
|
16061
|
+
each$e(additionalCleanupNodes.concat(children$2(root)), (node) => {
|
|
15926
16062
|
if (!eq(node, lastBlock) && !contains(node, lastBlock) && isEmpty$4(editor.schema, node)) {
|
|
15927
16063
|
remove$8(node);
|
|
15928
16064
|
}
|
|
@@ -17695,14 +17831,14 @@
|
|
|
17695
17831
|
});
|
|
17696
17832
|
};
|
|
17697
17833
|
const wrapChildrenInInnerWrapper = (target, wrapper, hasFormat, removeFormatFromElement) => {
|
|
17698
|
-
each$e(children$
|
|
17834
|
+
each$e(children$2(target), (child) => {
|
|
17699
17835
|
if (isElement$8(child) && hasFormat(child)) {
|
|
17700
17836
|
if (removeFormatFromElement(child).isNone()) {
|
|
17701
17837
|
unwrap(child);
|
|
17702
17838
|
}
|
|
17703
17839
|
}
|
|
17704
17840
|
});
|
|
17705
|
-
each$e(children$
|
|
17841
|
+
each$e(children$2(target), (child) => append$1(wrapper, child));
|
|
17706
17842
|
prepend(target, wrapper);
|
|
17707
17843
|
};
|
|
17708
17844
|
const wrapInOuterWrappers = (target, wrappers) => {
|
|
@@ -18492,7 +18628,7 @@
|
|
|
18492
18628
|
}
|
|
18493
18629
|
};
|
|
18494
18630
|
|
|
18495
|
-
/*! @license DOMPurify 3.4.
|
|
18631
|
+
/*! @license DOMPurify 3.4.11 | (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.11/LICENSE */
|
|
18496
18632
|
|
|
18497
18633
|
function _arrayLikeToArray(r, a) {
|
|
18498
18634
|
(null == a || a > r.length) && (a = r.length);
|
|
@@ -18821,16 +18957,31 @@
|
|
|
18821
18957
|
);
|
|
18822
18958
|
const DOCTYPE_NAME = seal(/^html$/i);
|
|
18823
18959
|
const CUSTOM_ELEMENT = seal(/^[a-z][.\w]*(-[.\w]+)+$/i);
|
|
18960
|
+
// Markup-significant character probes used by _sanitizeElements.
|
|
18961
|
+
// Shared module-level instances are safe despite the sticky /g flags:
|
|
18962
|
+
// unapply() resets lastIndex for RegExp receivers before every call.
|
|
18963
|
+
const ELEMENT_MARKUP_PROBE = seal(/<[/\w!]/g);
|
|
18964
|
+
const COMMENT_MARKUP_PROBE = seal(/<[/\w]/g);
|
|
18965
|
+
const FALLBACK_TAG_CLOSE = seal(/<\/no(script|embed|frames)/i);
|
|
18966
|
+
const SELF_CLOSING_TAG = seal(/\/>/i);
|
|
18824
18967
|
|
|
18825
|
-
/* eslint-disable @typescript-eslint/indent */
|
|
18826
18968
|
// https://developer.mozilla.org/en-US/docs/Web/API/Node/nodeType
|
|
18827
18969
|
const NODE_TYPE = {
|
|
18828
18970
|
element: 1,
|
|
18971
|
+
attribute: 2,
|
|
18829
18972
|
text: 3,
|
|
18973
|
+
cdataSection: 4,
|
|
18974
|
+
entityReference: 5,
|
|
18830
18975
|
// Deprecated
|
|
18831
|
-
|
|
18976
|
+
entityNode: 6,
|
|
18977
|
+
// Deprecated
|
|
18978
|
+
processingInstruction: 7,
|
|
18832
18979
|
comment: 8,
|
|
18833
|
-
document: 9
|
|
18980
|
+
document: 9,
|
|
18981
|
+
documentType: 10,
|
|
18982
|
+
documentFragment: 11,
|
|
18983
|
+
notation: 12 // Deprecated
|
|
18984
|
+
};
|
|
18834
18985
|
const getGlobal = function getGlobal() {
|
|
18835
18986
|
return typeof window === 'undefined' ? null : window;
|
|
18836
18987
|
};
|
|
@@ -18885,10 +19036,25 @@
|
|
|
18885
19036
|
uponSanitizeShadowNode: []
|
|
18886
19037
|
};
|
|
18887
19038
|
};
|
|
19039
|
+
/**
|
|
19040
|
+
* Resolve a set-valued configuration option: a fresh set built from
|
|
19041
|
+
* cfg[key] when it is an own array property (seeded with a clone of
|
|
19042
|
+
* options.base when given, case-normalized via options.transform),
|
|
19043
|
+
* the fallback set otherwise.
|
|
19044
|
+
*
|
|
19045
|
+
* @param cfg the cloned, prototype-free configuration object
|
|
19046
|
+
* @param key the configuration property to read
|
|
19047
|
+
* @param fallback the set to use when the option is absent or not an array
|
|
19048
|
+
* @param options transform and optional base set to merge into
|
|
19049
|
+
* @returns the resolved set
|
|
19050
|
+
*/
|
|
19051
|
+
const _resolveSetOption = function _resolveSetOption(cfg, key, fallback, options) {
|
|
19052
|
+
return objectHasOwnProperty(cfg, key) && arrayIsArray(cfg[key]) ? addToSet(options.base ? clone(options.base) : {}, cfg[key], options.transform) : fallback;
|
|
19053
|
+
};
|
|
18888
19054
|
function createDOMPurify() {
|
|
18889
19055
|
let window = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : getGlobal();
|
|
18890
19056
|
const DOMPurify = root => createDOMPurify(root);
|
|
18891
|
-
DOMPurify.version = '3.4.
|
|
19057
|
+
DOMPurify.version = '3.4.11';
|
|
18892
19058
|
DOMPurify.removed = [];
|
|
18893
19059
|
if (!window || !window.document || window.document.nodeType !== NODE_TYPE.document || !window.Element) {
|
|
18894
19060
|
// Not running in a browser, provide a factory function
|
|
@@ -18899,15 +19065,15 @@
|
|
|
18899
19065
|
let document = window.document;
|
|
18900
19066
|
const originalDocument = document;
|
|
18901
19067
|
const currentScript = originalDocument.currentScript;
|
|
18902
|
-
|
|
18903
|
-
HTMLTemplateElement = window.HTMLTemplateElement,
|
|
19068
|
+
window.DocumentFragment;
|
|
19069
|
+
const HTMLTemplateElement = window.HTMLTemplateElement,
|
|
18904
19070
|
Node = window.Node,
|
|
18905
19071
|
Element = window.Element,
|
|
18906
19072
|
NodeFilter = window.NodeFilter,
|
|
18907
|
-
_window$NamedNodeMap = window.NamedNodeMap
|
|
18908
|
-
|
|
18909
|
-
|
|
18910
|
-
DOMParser = window.DOMParser,
|
|
19073
|
+
_window$NamedNodeMap = window.NamedNodeMap;
|
|
19074
|
+
_window$NamedNodeMap === void 0 ? window.NamedNodeMap || window.MozNamedAttrMap : _window$NamedNodeMap;
|
|
19075
|
+
window.HTMLFormElement;
|
|
19076
|
+
const DOMParser = window.DOMParser,
|
|
18911
19077
|
trustedTypes = window.trustedTypes;
|
|
18912
19078
|
const ElementPrototype = Element.prototype;
|
|
18913
19079
|
const cloneNode = lookupGetter(ElementPrototype, 'cloneNode');
|
|
@@ -18915,7 +19081,10 @@
|
|
|
18915
19081
|
const getNextSibling = lookupGetter(ElementPrototype, 'nextSibling');
|
|
18916
19082
|
const getChildNodes = lookupGetter(ElementPrototype, 'childNodes');
|
|
18917
19083
|
const getParentNode = lookupGetter(ElementPrototype, 'parentNode');
|
|
19084
|
+
const getShadowRoot = lookupGetter(ElementPrototype, 'shadowRoot');
|
|
19085
|
+
const getAttributes = lookupGetter(ElementPrototype, 'attributes');
|
|
18918
19086
|
const getNodeType = Node && Node.prototype ? lookupGetter(Node.prototype, 'nodeType') : null;
|
|
19087
|
+
const getNodeName = Node && Node.prototype ? lookupGetter(Node.prototype, 'nodeName') : null;
|
|
18919
19088
|
// As per issue #47, the web-components registry is inherited by a
|
|
18920
19089
|
// new document created via createHTMLDocument. As per the spec
|
|
18921
19090
|
// (http://w3c.github.io/webcomponents/spec/custom/#creating-and-passing-registries)
|
|
@@ -18930,6 +19099,54 @@
|
|
|
18930
19099
|
}
|
|
18931
19100
|
let trustedTypesPolicy;
|
|
18932
19101
|
let emptyHTML = '';
|
|
19102
|
+
// The instance's own internal Trusted Types policy. Unlike a caller-supplied
|
|
19103
|
+
// `TRUSTED_TYPES_POLICY`, this is created at most once — Trusted Types throws
|
|
19104
|
+
// on duplicate policy names — and is the only policy allowed to persist
|
|
19105
|
+
// across configurations and survive `clearConfig()`.
|
|
19106
|
+
let defaultTrustedTypesPolicy;
|
|
19107
|
+
let defaultTrustedTypesPolicyResolved = false;
|
|
19108
|
+
// Tracks whether we are already inside a call to the configured Trusted Types
|
|
19109
|
+
// policy (`createHTML` or `createScriptURL`). If a supplied policy callback
|
|
19110
|
+
// itself calls `DOMPurify.sanitize` (the cause of #1422), `sanitize` would
|
|
19111
|
+
// re-enter the policy and recurse until the stack overflows. We detect that
|
|
19112
|
+
// re-entry and throw a clear, actionable error instead. The guard is shared
|
|
19113
|
+
// across both callbacks, because either one re-entering `sanitize` triggers
|
|
19114
|
+
// the same unbounded recursion.
|
|
19115
|
+
let IN_TRUSTED_TYPES_POLICY = 0;
|
|
19116
|
+
const _assertNotInTrustedTypesPolicy = function _assertNotInTrustedTypesPolicy() {
|
|
19117
|
+
if (IN_TRUSTED_TYPES_POLICY > 0) {
|
|
19118
|
+
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.');
|
|
19119
|
+
}
|
|
19120
|
+
};
|
|
19121
|
+
const _createTrustedHTML = function _createTrustedHTML(html) {
|
|
19122
|
+
_assertNotInTrustedTypesPolicy();
|
|
19123
|
+
IN_TRUSTED_TYPES_POLICY++;
|
|
19124
|
+
try {
|
|
19125
|
+
return trustedTypesPolicy.createHTML(html);
|
|
19126
|
+
} finally {
|
|
19127
|
+
IN_TRUSTED_TYPES_POLICY--;
|
|
19128
|
+
}
|
|
19129
|
+
};
|
|
19130
|
+
const _createTrustedScriptURL = function _createTrustedScriptURL(scriptUrl) {
|
|
19131
|
+
_assertNotInTrustedTypesPolicy();
|
|
19132
|
+
IN_TRUSTED_TYPES_POLICY++;
|
|
19133
|
+
try {
|
|
19134
|
+
return trustedTypesPolicy.createScriptURL(scriptUrl);
|
|
19135
|
+
} finally {
|
|
19136
|
+
IN_TRUSTED_TYPES_POLICY--;
|
|
19137
|
+
}
|
|
19138
|
+
};
|
|
19139
|
+
// Lazily resolve (and cache) the instance's internal default policy.
|
|
19140
|
+
// Resolution is attempted at most once: a successful `createPolicy` cannot be
|
|
19141
|
+
// repeated (Trusted Types throws on duplicate names), and a failed or
|
|
19142
|
+
// unsupported attempt must not be retried on every parse.
|
|
19143
|
+
const _getDefaultTrustedTypesPolicy = function _getDefaultTrustedTypesPolicy() {
|
|
19144
|
+
if (!defaultTrustedTypesPolicyResolved) {
|
|
19145
|
+
defaultTrustedTypesPolicy = _createTrustedTypesPolicy(trustedTypes, currentScript);
|
|
19146
|
+
defaultTrustedTypesPolicyResolved = true;
|
|
19147
|
+
}
|
|
19148
|
+
return defaultTrustedTypesPolicy;
|
|
19149
|
+
};
|
|
18933
19150
|
const _document = document,
|
|
18934
19151
|
implementation = _document.implementation,
|
|
18935
19152
|
createNodeIterator = _document.createNodeIterator,
|
|
@@ -19026,6 +19243,13 @@
|
|
|
19026
19243
|
let WHOLE_DOCUMENT = false;
|
|
19027
19244
|
/* Track whether config is already set on this instance of DOMPurify. */
|
|
19028
19245
|
let SET_CONFIG = false;
|
|
19246
|
+
/* Pristine allowlist bindings captured at setConfig() time. On the
|
|
19247
|
+
* persistent-config path sanitize() restores the sets from these before
|
|
19248
|
+
* the per-walk hook clone-guard, so a hook's in-call widening cannot
|
|
19249
|
+
* carry across calls. Null until setConfig() is called; reset by
|
|
19250
|
+
* clearConfig(). */
|
|
19251
|
+
let SET_CONFIG_ALLOWED_TAGS = null;
|
|
19252
|
+
let SET_CONFIG_ALLOWED_ATTR = null;
|
|
19029
19253
|
/* Decide if all elements (e.g. style, script) must be children of
|
|
19030
19254
|
* document.body. By default, browsers might move them to document.head */
|
|
19031
19255
|
let FORCE_BODY = false;
|
|
@@ -19068,7 +19292,17 @@
|
|
|
19068
19292
|
let USE_PROFILES = {};
|
|
19069
19293
|
/* Tags to ignore content of when KEEP_CONTENT is true */
|
|
19070
19294
|
let FORBID_CONTENTS = null;
|
|
19071
|
-
const DEFAULT_FORBID_CONTENTS = addToSet({}, ['annotation-xml', 'audio', 'colgroup', 'desc', 'foreignobject', 'head', 'iframe', 'math', 'mi', 'mn', 'mo', 'ms', 'mtext', 'noembed', 'noframes', 'noscript', 'plaintext', 'script',
|
|
19295
|
+
const DEFAULT_FORBID_CONTENTS = addToSet({}, ['annotation-xml', 'audio', 'colgroup', 'desc', 'foreignobject', 'head', 'iframe', 'math', 'mi', 'mn', 'mo', 'ms', 'mtext', 'noembed', 'noframes', 'noscript', 'plaintext', 'script',
|
|
19296
|
+
// <selectedcontent> mirrors the selected <option>'s subtree, cloned by
|
|
19297
|
+
// the UA (customizable <select>) — including any on* handlers — and the
|
|
19298
|
+
// engine re-mirrors synchronously whenever a removal changes which
|
|
19299
|
+
// option/selectedcontent is current, even inside DOMPurify's inert
|
|
19300
|
+
// DOMParser document. Hoisting its children on removal re-inserts a fresh
|
|
19301
|
+
// mirror target ahead of the walk, which the engine refills, looping
|
|
19302
|
+
// forever (DoS) and amplifying output. Dropping its content on removal
|
|
19303
|
+
// (rather than hoisting) breaks that cascade; the content is a duplicate
|
|
19304
|
+
// of the option, which is sanitized on its own. See campaign-3 F1/F6.
|
|
19305
|
+
'selectedcontent', 'style', 'svg', 'template', 'thead', 'title', 'video', 'xmp']);
|
|
19072
19306
|
/* Tags that are safe for data: URIs */
|
|
19073
19307
|
let DATA_URI_TAGS = null;
|
|
19074
19308
|
const DEFAULT_DATA_URI_TAGS = addToSet({}, ['audio', 'video', 'img', 'source', 'image', 'track']);
|
|
@@ -19084,8 +19318,10 @@
|
|
|
19084
19318
|
/* Allowed XHTML+XML namespaces */
|
|
19085
19319
|
let ALLOWED_NAMESPACES = null;
|
|
19086
19320
|
const DEFAULT_ALLOWED_NAMESPACES = addToSet({}, [MATHML_NAMESPACE, SVG_NAMESPACE, HTML_NAMESPACE], stringToString);
|
|
19087
|
-
|
|
19088
|
-
let
|
|
19321
|
+
const DEFAULT_MATHML_TEXT_INTEGRATION_POINTS = freeze(['mi', 'mo', 'mn', 'ms', 'mtext']);
|
|
19322
|
+
let MATHML_TEXT_INTEGRATION_POINTS = addToSet({}, DEFAULT_MATHML_TEXT_INTEGRATION_POINTS);
|
|
19323
|
+
const DEFAULT_HTML_INTEGRATION_POINTS = freeze(['annotation-xml']);
|
|
19324
|
+
let HTML_INTEGRATION_POINTS = addToSet({}, DEFAULT_HTML_INTEGRATION_POINTS);
|
|
19089
19325
|
// Certain elements are allowed in both SVG and HTML
|
|
19090
19326
|
// namespace. We need to specify them explicitly
|
|
19091
19327
|
// so that they don't get erroneously deleted from
|
|
@@ -19127,14 +19363,32 @@
|
|
|
19127
19363
|
// HTML tags and attributes are not case-sensitive, converting to lowercase. Keeping XHTML as is.
|
|
19128
19364
|
transformCaseFunc = PARSER_MEDIA_TYPE === 'application/xhtml+xml' ? stringToString : stringToLowerCase;
|
|
19129
19365
|
/* Set configuration parameters */
|
|
19130
|
-
ALLOWED_TAGS =
|
|
19131
|
-
|
|
19132
|
-
|
|
19133
|
-
|
|
19134
|
-
|
|
19135
|
-
|
|
19136
|
-
|
|
19137
|
-
|
|
19366
|
+
ALLOWED_TAGS = _resolveSetOption(cfg, 'ALLOWED_TAGS', DEFAULT_ALLOWED_TAGS, {
|
|
19367
|
+
transform: transformCaseFunc
|
|
19368
|
+
});
|
|
19369
|
+
ALLOWED_ATTR = _resolveSetOption(cfg, 'ALLOWED_ATTR', DEFAULT_ALLOWED_ATTR, {
|
|
19370
|
+
transform: transformCaseFunc
|
|
19371
|
+
});
|
|
19372
|
+
ALLOWED_NAMESPACES = _resolveSetOption(cfg, 'ALLOWED_NAMESPACES', DEFAULT_ALLOWED_NAMESPACES, {
|
|
19373
|
+
transform: stringToString
|
|
19374
|
+
});
|
|
19375
|
+
URI_SAFE_ATTRIBUTES = _resolveSetOption(cfg, 'ADD_URI_SAFE_ATTR', DEFAULT_URI_SAFE_ATTRIBUTES, {
|
|
19376
|
+
transform: transformCaseFunc,
|
|
19377
|
+
base: DEFAULT_URI_SAFE_ATTRIBUTES
|
|
19378
|
+
});
|
|
19379
|
+
DATA_URI_TAGS = _resolveSetOption(cfg, 'ADD_DATA_URI_TAGS', DEFAULT_DATA_URI_TAGS, {
|
|
19380
|
+
transform: transformCaseFunc,
|
|
19381
|
+
base: DEFAULT_DATA_URI_TAGS
|
|
19382
|
+
});
|
|
19383
|
+
FORBID_CONTENTS = _resolveSetOption(cfg, 'FORBID_CONTENTS', DEFAULT_FORBID_CONTENTS, {
|
|
19384
|
+
transform: transformCaseFunc
|
|
19385
|
+
});
|
|
19386
|
+
FORBID_TAGS = _resolveSetOption(cfg, 'FORBID_TAGS', clone({}), {
|
|
19387
|
+
transform: transformCaseFunc
|
|
19388
|
+
});
|
|
19389
|
+
FORBID_ATTR = _resolveSetOption(cfg, 'FORBID_ATTR', clone({}), {
|
|
19390
|
+
transform: transformCaseFunc
|
|
19391
|
+
});
|
|
19138
19392
|
USE_PROFILES = objectHasOwnProperty(cfg, 'USE_PROFILES') ? cfg.USE_PROFILES && typeof cfg.USE_PROFILES === 'object' ? clone(cfg.USE_PROFILES) : cfg.USE_PROFILES : false;
|
|
19139
19393
|
ALLOW_ARIA_ATTR = cfg.ALLOW_ARIA_ATTR !== false; // Default true
|
|
19140
19394
|
ALLOW_DATA_ATTR = cfg.ALLOW_DATA_ATTR !== false; // Default true
|
|
@@ -19153,8 +19407,8 @@
|
|
|
19153
19407
|
IN_PLACE = cfg.IN_PLACE || false; // Default false
|
|
19154
19408
|
IS_ALLOWED_URI$1 = isRegex(cfg.ALLOWED_URI_REGEXP) ? cfg.ALLOWED_URI_REGEXP : IS_ALLOWED_URI; // Default regexp
|
|
19155
19409
|
NAMESPACE = typeof cfg.NAMESPACE === 'string' ? cfg.NAMESPACE : HTML_NAMESPACE; // Default HTML namespace
|
|
19156
|
-
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({},
|
|
19157
|
-
HTML_INTEGRATION_POINTS = objectHasOwnProperty(cfg, 'HTML_INTEGRATION_POINTS') && cfg.HTML_INTEGRATION_POINTS && typeof cfg.HTML_INTEGRATION_POINTS === 'object' ? clone(cfg.HTML_INTEGRATION_POINTS) : addToSet({},
|
|
19410
|
+
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
|
|
19411
|
+
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
|
|
19158
19412
|
const customElementHandling = objectHasOwnProperty(cfg, 'CUSTOM_ELEMENT_HANDLING') && cfg.CUSTOM_ELEMENT_HANDLING && typeof cfg.CUSTOM_ELEMENT_HANDLING === 'object' ? clone(cfg.CUSTOM_ELEMENT_HANDLING) : create$7(null);
|
|
19159
19413
|
CUSTOM_ELEMENT_HANDLING = create$7(null);
|
|
19160
19414
|
if (objectHasOwnProperty(customElementHandling, 'tagNameCheck') && isRegexOrFunction(customElementHandling.tagNameCheck)) {
|
|
@@ -19166,6 +19420,7 @@
|
|
|
19166
19420
|
if (objectHasOwnProperty(customElementHandling, 'allowCustomizedBuiltInElements') && typeof customElementHandling.allowCustomizedBuiltInElements === 'boolean') {
|
|
19167
19421
|
CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements = customElementHandling.allowCustomizedBuiltInElements; // Default undefined
|
|
19168
19422
|
}
|
|
19423
|
+
seal(CUSTOM_ELEMENT_HANDLING);
|
|
19169
19424
|
if (SAFE_FOR_TEMPLATES) {
|
|
19170
19425
|
ALLOW_DATA_ATTR = false;
|
|
19171
19426
|
}
|
|
@@ -19249,6 +19504,13 @@
|
|
|
19249
19504
|
addToSet(ALLOWED_TAGS, ['tbody']);
|
|
19250
19505
|
delete FORBID_TAGS.tbody;
|
|
19251
19506
|
}
|
|
19507
|
+
// Re-derive the active Trusted Types policy from this configuration on
|
|
19508
|
+
// every parse. The active policy must never be sticky closure state that
|
|
19509
|
+
// outlives the config that set it: a caller-supplied policy left in place
|
|
19510
|
+
// after `clearConfig()` — or after a later call that supplied none, or
|
|
19511
|
+
// `TRUSTED_TYPES_POLICY: null` — could sign a subsequent "default"
|
|
19512
|
+
// `RETURN_TRUSTED_TYPE` result with a foreign, possibly unsafe policy.
|
|
19513
|
+
// See GHSA-vxr8-fq34-vvx9.
|
|
19252
19514
|
if (cfg.TRUSTED_TYPES_POLICY) {
|
|
19253
19515
|
if (typeof cfg.TRUSTED_TYPES_POLICY.createHTML !== 'function') {
|
|
19254
19516
|
throw typeErrorCreate('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');
|
|
@@ -19256,18 +19518,45 @@
|
|
|
19256
19518
|
if (typeof cfg.TRUSTED_TYPES_POLICY.createScriptURL !== 'function') {
|
|
19257
19519
|
throw typeErrorCreate('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');
|
|
19258
19520
|
}
|
|
19259
|
-
//
|
|
19521
|
+
// A caller-supplied policy applies to this configuration only.
|
|
19522
|
+
const previousTrustedTypesPolicy = trustedTypesPolicy;
|
|
19260
19523
|
trustedTypesPolicy = cfg.TRUSTED_TYPES_POLICY;
|
|
19261
|
-
// Sign local variables required by `sanitize`.
|
|
19262
|
-
|
|
19524
|
+
// Sign local variables required by `sanitize`. If the supplied policy's
|
|
19525
|
+
// `createHTML` is circular (i.e. it calls `DOMPurify.sanitize`), this
|
|
19526
|
+
// throws via the re-entrancy guard. Restore the previous policy first so
|
|
19527
|
+
// the instance is not left in a poisoned state. See #1422.
|
|
19528
|
+
try {
|
|
19529
|
+
emptyHTML = _createTrustedHTML('');
|
|
19530
|
+
} catch (error) {
|
|
19531
|
+
trustedTypesPolicy = previousTrustedTypesPolicy;
|
|
19532
|
+
throw error;
|
|
19533
|
+
}
|
|
19534
|
+
} else if (cfg.TRUSTED_TYPES_POLICY === null) {
|
|
19535
|
+
// Explicit opt-out for this call: perform no Trusted Types signing and
|
|
19536
|
+
// create nothing (so a strict `trusted-types` CSP that disallows a
|
|
19537
|
+
// `dompurify` policy can still call `sanitize` from inside its own
|
|
19538
|
+
// policy — see #1422). Resetting to `undefined` rather than a sticky
|
|
19539
|
+
// `null` also drops any previously retained caller policy, so it cannot
|
|
19540
|
+
// resurface on a later call, while still allowing the next config-less
|
|
19541
|
+
// call to restore the internal default policy. See GHSA-vxr8-fq34-vvx9.
|
|
19542
|
+
trustedTypesPolicy = undefined;
|
|
19543
|
+
emptyHTML = '';
|
|
19263
19544
|
} else {
|
|
19264
|
-
//
|
|
19545
|
+
// No policy supplied: keep the currently active policy if one is set — a
|
|
19546
|
+
// previously supplied policy is intentionally sticky across config-less
|
|
19547
|
+
// calls — otherwise fall back to the instance's own internal policy,
|
|
19548
|
+
// created at most once. (A policy supplied for a *single* call still
|
|
19549
|
+
// lingers by design; what must not linger is a policy whose configuration
|
|
19550
|
+
// has been torn down via `clearConfig()`, which restores the default.)
|
|
19265
19551
|
if (trustedTypesPolicy === undefined) {
|
|
19266
|
-
trustedTypesPolicy =
|
|
19552
|
+
trustedTypesPolicy = _getDefaultTrustedTypesPolicy();
|
|
19267
19553
|
}
|
|
19268
|
-
//
|
|
19269
|
-
|
|
19270
|
-
|
|
19554
|
+
// Sign internal variables only when a policy is active. A falsy policy
|
|
19555
|
+
// (Trusted Types unsupported, creation failed, or an explicit opt-out)
|
|
19556
|
+
// leaves `emptyHTML` as a plain string, so we never call `.createHTML` on
|
|
19557
|
+
// a non-policy and throw. See #1422.
|
|
19558
|
+
if (trustedTypesPolicy && typeof emptyHTML === 'string') {
|
|
19559
|
+
emptyHTML = _createTrustedHTML('');
|
|
19271
19560
|
}
|
|
19272
19561
|
}
|
|
19273
19562
|
// Prevent further manipulation of configuration.
|
|
@@ -19282,6 +19571,77 @@
|
|
|
19282
19571
|
* correctly. */
|
|
19283
19572
|
const ALL_SVG_TAGS = addToSet({}, [...svg$1, ...svgFilters, ...svgDisallowed]);
|
|
19284
19573
|
const ALL_MATHML_TAGS = addToSet({}, [...mathMl$1, ...mathMlDisallowed]);
|
|
19574
|
+
/**
|
|
19575
|
+
* Namespace rules for an element in the SVG namespace.
|
|
19576
|
+
*
|
|
19577
|
+
* @param tagName the element's lowercase tag name
|
|
19578
|
+
* @param parent the (possibly simulated) parent node
|
|
19579
|
+
* @param parentTagName the parent's lowercase tag name
|
|
19580
|
+
* @returns true if a spec-compliant parser could produce this element
|
|
19581
|
+
*/
|
|
19582
|
+
const _checkSvgNamespace = function _checkSvgNamespace(tagName, parent, parentTagName) {
|
|
19583
|
+
// The only way to switch from HTML namespace to SVG
|
|
19584
|
+
// is via <svg>. If it happens via any other tag, then
|
|
19585
|
+
// it should be killed.
|
|
19586
|
+
if (parent.namespaceURI === HTML_NAMESPACE) {
|
|
19587
|
+
return tagName === 'svg';
|
|
19588
|
+
}
|
|
19589
|
+
// The only way to switch from MathML to SVG is via <svg>
|
|
19590
|
+
// if the parent is either <annotation-xml> or a MathML
|
|
19591
|
+
// text integration point.
|
|
19592
|
+
if (parent.namespaceURI === MATHML_NAMESPACE) {
|
|
19593
|
+
return tagName === 'svg' && (parentTagName === 'annotation-xml' || MATHML_TEXT_INTEGRATION_POINTS[parentTagName]);
|
|
19594
|
+
}
|
|
19595
|
+
// We only allow elements that are defined in SVG
|
|
19596
|
+
// spec. All others are disallowed in SVG namespace.
|
|
19597
|
+
return Boolean(ALL_SVG_TAGS[tagName]);
|
|
19598
|
+
};
|
|
19599
|
+
/**
|
|
19600
|
+
* Namespace rules for an element in the MathML namespace.
|
|
19601
|
+
*
|
|
19602
|
+
* @param tagName the element's lowercase tag name
|
|
19603
|
+
* @param parent the (possibly simulated) parent node
|
|
19604
|
+
* @param parentTagName the parent's lowercase tag name
|
|
19605
|
+
* @returns true if a spec-compliant parser could produce this element
|
|
19606
|
+
*/
|
|
19607
|
+
const _checkMathMlNamespace = function _checkMathMlNamespace(tagName, parent, parentTagName) {
|
|
19608
|
+
// The only way to switch from HTML namespace to MathML
|
|
19609
|
+
// is via <math>. If it happens via any other tag, then
|
|
19610
|
+
// it should be killed.
|
|
19611
|
+
if (parent.namespaceURI === HTML_NAMESPACE) {
|
|
19612
|
+
return tagName === 'math';
|
|
19613
|
+
}
|
|
19614
|
+
// The only way to switch from SVG to MathML is via
|
|
19615
|
+
// <math> and HTML integration points
|
|
19616
|
+
if (parent.namespaceURI === SVG_NAMESPACE) {
|
|
19617
|
+
return tagName === 'math' && HTML_INTEGRATION_POINTS[parentTagName];
|
|
19618
|
+
}
|
|
19619
|
+
// We only allow elements that are defined in MathML
|
|
19620
|
+
// spec. All others are disallowed in MathML namespace.
|
|
19621
|
+
return Boolean(ALL_MATHML_TAGS[tagName]);
|
|
19622
|
+
};
|
|
19623
|
+
/**
|
|
19624
|
+
* Namespace rules for an element in the HTML namespace.
|
|
19625
|
+
*
|
|
19626
|
+
* @param tagName the element's lowercase tag name
|
|
19627
|
+
* @param parent the (possibly simulated) parent node
|
|
19628
|
+
* @param parentTagName the parent's lowercase tag name
|
|
19629
|
+
* @returns true if a spec-compliant parser could produce this element
|
|
19630
|
+
*/
|
|
19631
|
+
const _checkHtmlNamespace = function _checkHtmlNamespace(tagName, parent, parentTagName) {
|
|
19632
|
+
// The only way to switch from SVG to HTML is via
|
|
19633
|
+
// HTML integration points, and from MathML to HTML
|
|
19634
|
+
// is via MathML text integration points
|
|
19635
|
+
if (parent.namespaceURI === SVG_NAMESPACE && !HTML_INTEGRATION_POINTS[parentTagName]) {
|
|
19636
|
+
return false;
|
|
19637
|
+
}
|
|
19638
|
+
if (parent.namespaceURI === MATHML_NAMESPACE && !MATHML_TEXT_INTEGRATION_POINTS[parentTagName]) {
|
|
19639
|
+
return false;
|
|
19640
|
+
}
|
|
19641
|
+
// We disallow tags that are specific for MathML
|
|
19642
|
+
// or SVG and should never appear in HTML namespace
|
|
19643
|
+
return !ALL_MATHML_TAGS[tagName] && (COMMON_SVG_AND_HTML_ELEMENTS[tagName] || !ALL_SVG_TAGS[tagName]);
|
|
19644
|
+
};
|
|
19285
19645
|
/**
|
|
19286
19646
|
* @param element a DOM element whose namespace is being checked
|
|
19287
19647
|
* @returns Return false if the element has a
|
|
@@ -19304,51 +19664,13 @@
|
|
|
19304
19664
|
return false;
|
|
19305
19665
|
}
|
|
19306
19666
|
if (element.namespaceURI === SVG_NAMESPACE) {
|
|
19307
|
-
|
|
19308
|
-
// is via <svg>. If it happens via any other tag, then
|
|
19309
|
-
// it should be killed.
|
|
19310
|
-
if (parent.namespaceURI === HTML_NAMESPACE) {
|
|
19311
|
-
return tagName === 'svg';
|
|
19312
|
-
}
|
|
19313
|
-
// The only way to switch from MathML to SVG is via`
|
|
19314
|
-
// svg if parent is either <annotation-xml> or MathML
|
|
19315
|
-
// text integration points.
|
|
19316
|
-
if (parent.namespaceURI === MATHML_NAMESPACE) {
|
|
19317
|
-
return tagName === 'svg' && (parentTagName === 'annotation-xml' || MATHML_TEXT_INTEGRATION_POINTS[parentTagName]);
|
|
19318
|
-
}
|
|
19319
|
-
// We only allow elements that are defined in SVG
|
|
19320
|
-
// spec. All others are disallowed in SVG namespace.
|
|
19321
|
-
return Boolean(ALL_SVG_TAGS[tagName]);
|
|
19667
|
+
return _checkSvgNamespace(tagName, parent, parentTagName);
|
|
19322
19668
|
}
|
|
19323
19669
|
if (element.namespaceURI === MATHML_NAMESPACE) {
|
|
19324
|
-
|
|
19325
|
-
// is via <math>. If it happens via any other tag, then
|
|
19326
|
-
// it should be killed.
|
|
19327
|
-
if (parent.namespaceURI === HTML_NAMESPACE) {
|
|
19328
|
-
return tagName === 'math';
|
|
19329
|
-
}
|
|
19330
|
-
// The only way to switch from SVG to MathML is via
|
|
19331
|
-
// <math> and HTML integration points
|
|
19332
|
-
if (parent.namespaceURI === SVG_NAMESPACE) {
|
|
19333
|
-
return tagName === 'math' && HTML_INTEGRATION_POINTS[parentTagName];
|
|
19334
|
-
}
|
|
19335
|
-
// We only allow elements that are defined in MathML
|
|
19336
|
-
// spec. All others are disallowed in MathML namespace.
|
|
19337
|
-
return Boolean(ALL_MATHML_TAGS[tagName]);
|
|
19670
|
+
return _checkMathMlNamespace(tagName, parent, parentTagName);
|
|
19338
19671
|
}
|
|
19339
19672
|
if (element.namespaceURI === HTML_NAMESPACE) {
|
|
19340
|
-
|
|
19341
|
-
// HTML integration points, and from MathML to HTML
|
|
19342
|
-
// is via MathML text integration points
|
|
19343
|
-
if (parent.namespaceURI === SVG_NAMESPACE && !HTML_INTEGRATION_POINTS[parentTagName]) {
|
|
19344
|
-
return false;
|
|
19345
|
-
}
|
|
19346
|
-
if (parent.namespaceURI === MATHML_NAMESPACE && !MATHML_TEXT_INTEGRATION_POINTS[parentTagName]) {
|
|
19347
|
-
return false;
|
|
19348
|
-
}
|
|
19349
|
-
// We disallow tags that are specific for MathML
|
|
19350
|
-
// or SVG and should never appear in HTML namespace
|
|
19351
|
-
return !ALL_MATHML_TAGS[tagName] && (COMMON_SVG_AND_HTML_ELEMENTS[tagName] || !ALL_SVG_TAGS[tagName]);
|
|
19673
|
+
return _checkHtmlNamespace(tagName, parent, parentTagName);
|
|
19352
19674
|
}
|
|
19353
19675
|
// For XHTML and XML documents that support custom namespaces
|
|
19354
19676
|
if (PARSER_MEDIA_TYPE === 'application/xhtml+xml' && ALLOWED_NAMESPACES[element.namespaceURI]) {
|
|
@@ -19373,7 +19695,74 @@
|
|
|
19373
19695
|
// eslint-disable-next-line unicorn/prefer-dom-node-remove
|
|
19374
19696
|
getParentNode(node).removeChild(node);
|
|
19375
19697
|
} catch (_) {
|
|
19698
|
+
/* The normal detach failed — this is reached for a parentless node
|
|
19699
|
+
(getParentNode() is null, so .removeChild throws). Element.prototype
|
|
19700
|
+
.remove() is itself a spec no-op on a parentless node, so a recorded
|
|
19701
|
+
"removal" would otherwise hand the caller back an intact,
|
|
19702
|
+
payload-bearing node (e.g. a detached IN_PLACE root the mXSS canary or
|
|
19703
|
+
the style-with-element-child rule decided to kill). Fail closed by
|
|
19704
|
+
throwing — exactly as a clobbered root does at the IN_PLACE entry —
|
|
19705
|
+
rather than trying to "neutralize" the node via its own methods.
|
|
19706
|
+
Neutralizing would mean calling getAttributeNames()/removeAttribute()
|
|
19707
|
+
on the node, both of which a <form> root can clobber via a named child
|
|
19708
|
+
(and _isClobbered does not even probe getAttributeNames), so the
|
|
19709
|
+
neutralize step could itself be silently defeated, leaving the payload
|
|
19710
|
+
intact. A throw touches only the cached, clobber-safe remove() and
|
|
19711
|
+
getParentNode(). Generalizes GHSA-r47g-fvhr-h676 (clobbered-form root)
|
|
19712
|
+
to every root-kill reason. REPORT-3.
|
|
19713
|
+
This lives inside the catch, so it never fires for a normally-removed
|
|
19714
|
+
in-tree node: those have a parent, removeChild() succeeds, and the
|
|
19715
|
+
catch is not entered. Only a kept (parentless) root reaches here. */
|
|
19376
19716
|
remove(node);
|
|
19717
|
+
if (!getParentNode(node)) {
|
|
19718
|
+
throw typeErrorCreate('a node selected for removal could not be detached from its tree ' + 'and cannot be safely returned; refusing to sanitize in place');
|
|
19719
|
+
}
|
|
19720
|
+
}
|
|
19721
|
+
};
|
|
19722
|
+
/**
|
|
19723
|
+
* _neutralizeRoot
|
|
19724
|
+
*
|
|
19725
|
+
* Fail-closed teardown of an in-place root after the sanitize walk aborts
|
|
19726
|
+
* (campaign-3 F2). An internal throw mid-walk — e.g. a page-registered
|
|
19727
|
+
* custom element's reaction detaches a node so `_forceRemove`'s deliberate
|
|
19728
|
+
* parentless guard throws, or any other re-entrant engine mutation — would
|
|
19729
|
+
* otherwise leave the caller's *live* tree half-sanitized, with everything
|
|
19730
|
+
* after the abort point still carrying its handlers. There is no safe way
|
|
19731
|
+
* to resume the walk (the tree mutated under us), so we strip the root bare:
|
|
19732
|
+
* remove every child and every attribute, then let the caller's catch see
|
|
19733
|
+
* the original error. Clobber-safe (cached `remove`/`childNodes`/`attributes`
|
|
19734
|
+
* getters; the root was already clobber-pre-flighted at the IN_PLACE entry).
|
|
19735
|
+
*
|
|
19736
|
+
* @param root the in-place root to empty
|
|
19737
|
+
*/
|
|
19738
|
+
const _neutralizeRoot = function _neutralizeRoot(root) {
|
|
19739
|
+
const childNodes = getChildNodes(root);
|
|
19740
|
+
if (childNodes) {
|
|
19741
|
+
const snapshot = [];
|
|
19742
|
+
arrayForEach(childNodes, child => {
|
|
19743
|
+
arrayPush(snapshot, child);
|
|
19744
|
+
});
|
|
19745
|
+
arrayForEach(snapshot, child => {
|
|
19746
|
+
try {
|
|
19747
|
+
remove(child);
|
|
19748
|
+
} catch (_) {
|
|
19749
|
+
/* Best-effort teardown; a still-attached child is handled below */
|
|
19750
|
+
}
|
|
19751
|
+
});
|
|
19752
|
+
}
|
|
19753
|
+
const attributes = getAttributes(root);
|
|
19754
|
+
if (attributes) {
|
|
19755
|
+
for (let i = attributes.length - 1; i >= 0; --i) {
|
|
19756
|
+
const attribute = attributes[i];
|
|
19757
|
+
const name = attribute && attribute.name;
|
|
19758
|
+
if (typeof name === 'string') {
|
|
19759
|
+
try {
|
|
19760
|
+
root.removeAttribute(name);
|
|
19761
|
+
} catch (_) {
|
|
19762
|
+
/* Clobbered removeAttribute — ignore (fail-closed best effort) */
|
|
19763
|
+
}
|
|
19764
|
+
}
|
|
19765
|
+
}
|
|
19377
19766
|
}
|
|
19378
19767
|
};
|
|
19379
19768
|
/**
|
|
@@ -19408,6 +19797,72 @@
|
|
|
19408
19797
|
}
|
|
19409
19798
|
}
|
|
19410
19799
|
};
|
|
19800
|
+
/**
|
|
19801
|
+
* _stripDisallowedAttributes
|
|
19802
|
+
*
|
|
19803
|
+
* Removes every attribute the active configuration does not allow from a
|
|
19804
|
+
* single element, using the same allowlist as the main attribute pass (so
|
|
19805
|
+
* `on*` handlers go, but no `/^on/` blocklist is introduced). Used only to
|
|
19806
|
+
* neutralise nodes that are being discarded from an in-place tree.
|
|
19807
|
+
*
|
|
19808
|
+
* @param element the element to strip
|
|
19809
|
+
*/
|
|
19810
|
+
const _stripDisallowedAttributes = function _stripDisallowedAttributes(element) {
|
|
19811
|
+
const attributes = getAttributes(element);
|
|
19812
|
+
if (!attributes) {
|
|
19813
|
+
return;
|
|
19814
|
+
}
|
|
19815
|
+
for (let i = attributes.length - 1; i >= 0; --i) {
|
|
19816
|
+
const attribute = attributes[i];
|
|
19817
|
+
const name = attribute && attribute.name;
|
|
19818
|
+
if (typeof name !== 'string' || ALLOWED_ATTR[transformCaseFunc(name)]) {
|
|
19819
|
+
continue;
|
|
19820
|
+
}
|
|
19821
|
+
try {
|
|
19822
|
+
element.removeAttribute(name);
|
|
19823
|
+
} catch (_) {
|
|
19824
|
+
/* Clobbered removeAttribute on a doomed node — ignore */
|
|
19825
|
+
}
|
|
19826
|
+
}
|
|
19827
|
+
};
|
|
19828
|
+
/**
|
|
19829
|
+
* _neutralizeSubtree
|
|
19830
|
+
*
|
|
19831
|
+
* Completes the audit-5 F1 fix across every removal path. The KEEP_CONTENT
|
|
19832
|
+
* move-hoist neutralises only disallowed-tag removals; clobber, mXSS-canary,
|
|
19833
|
+
* namespace, comment, processing-instruction and KEEP_CONTENT:false removals
|
|
19834
|
+
* all drop their subtree wholesale via `_forceRemove`. On the IN_PLACE path
|
|
19835
|
+
* those dropped nodes are detached from the caller's LIVE tree but a
|
|
19836
|
+
* handler-bearing original among them (an `<img onerror>`/`<video>` that was
|
|
19837
|
+
* loading) keeps its queued resource event, which fires in page scope after
|
|
19838
|
+
* sanitize returns. This walks a removed subtree and strips every attribute
|
|
19839
|
+
* the active configuration does not allow — so `on*` handlers are cancelled
|
|
19840
|
+
* through the SAME allowlist that governs kept nodes, not a separate `/^on/`
|
|
19841
|
+
* blocklist. Run synchronously before sanitize returns, i.e. before any
|
|
19842
|
+
* queued event can fire. Hook-free by design: these nodes leave the output,
|
|
19843
|
+
* so firing attribute hooks for them would be surprising. Clobber-safe reads;
|
|
19844
|
+
* a doomed clobbered node may shadow `removeAttribute` (its own attributes are
|
|
19845
|
+
* irrelevant — it is discarded — while its non-clobbered descendants, e.g.
|
|
19846
|
+
* the `<img>`, are reached and scrubbed).
|
|
19847
|
+
*
|
|
19848
|
+
* @param root the root of a removed subtree to neutralise
|
|
19849
|
+
*/
|
|
19850
|
+
const _neutralizeSubtree = function _neutralizeSubtree(root) {
|
|
19851
|
+
const stack = [root];
|
|
19852
|
+
while (stack.length > 0) {
|
|
19853
|
+
const node = stack.pop();
|
|
19854
|
+
const nodeType = getNodeType ? getNodeType(node) : node.nodeType;
|
|
19855
|
+
if (nodeType === NODE_TYPE.element) {
|
|
19856
|
+
_stripDisallowedAttributes(node);
|
|
19857
|
+
}
|
|
19858
|
+
const childNodes = getChildNodes(node);
|
|
19859
|
+
if (childNodes) {
|
|
19860
|
+
for (let i = childNodes.length - 1; i >= 0; --i) {
|
|
19861
|
+
stack.push(childNodes[i]);
|
|
19862
|
+
}
|
|
19863
|
+
}
|
|
19864
|
+
}
|
|
19865
|
+
};
|
|
19411
19866
|
/**
|
|
19412
19867
|
* _initDocument
|
|
19413
19868
|
*
|
|
@@ -19429,7 +19884,7 @@
|
|
|
19429
19884
|
// Root of XHTML doc must contain xmlns declaration (see https://www.w3.org/TR/xhtml1/normative.html#strict)
|
|
19430
19885
|
dirty = '<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>' + dirty + '</body></html>';
|
|
19431
19886
|
}
|
|
19432
|
-
const dirtyPayload = trustedTypesPolicy ?
|
|
19887
|
+
const dirtyPayload = trustedTypesPolicy ? _createTrustedHTML(dirty) : dirty;
|
|
19433
19888
|
/*
|
|
19434
19889
|
* Use the DOMParser API by default, fallback later if needs be
|
|
19435
19890
|
* DOMParser not work for svg when has multiple root element.
|
|
@@ -19469,6 +19924,20 @@
|
|
|
19469
19924
|
// eslint-disable-next-line no-bitwise
|
|
19470
19925
|
NodeFilter.SHOW_ELEMENT | NodeFilter.SHOW_COMMENT | NodeFilter.SHOW_TEXT | NodeFilter.SHOW_PROCESSING_INSTRUCTION | NodeFilter.SHOW_CDATA_SECTION, null);
|
|
19471
19926
|
};
|
|
19927
|
+
/**
|
|
19928
|
+
* Replace template expression syntax (mustache, ERB, template
|
|
19929
|
+
* literal) with a space; shared by all SAFE_FOR_TEMPLATES scrub
|
|
19930
|
+
* sites. Order matters: mustache, then ERB, then template literal.
|
|
19931
|
+
*
|
|
19932
|
+
* @param value the string to scrub
|
|
19933
|
+
* @returns the scrubbed string
|
|
19934
|
+
*/
|
|
19935
|
+
const _stripTemplateExpressions = function _stripTemplateExpressions(value) {
|
|
19936
|
+
value = stringReplace(value, MUSTACHE_EXPR$1, ' ');
|
|
19937
|
+
value = stringReplace(value, ERB_EXPR$1, ' ');
|
|
19938
|
+
value = stringReplace(value, TMPLIT_EXPR$1, ' ');
|
|
19939
|
+
return value;
|
|
19940
|
+
};
|
|
19472
19941
|
/**
|
|
19473
19942
|
* Strip template-engine expressions ({{...}}, ${...}, <%...%>) from the
|
|
19474
19943
|
* character data of an element subtree. Used as the final safety net for
|
|
@@ -19488,29 +19957,100 @@
|
|
|
19488
19957
|
*
|
|
19489
19958
|
* @param node The root element whose character data should be scrubbed.
|
|
19490
19959
|
*/
|
|
19491
|
-
const
|
|
19960
|
+
const _scrubTemplateExpressions2 = function _scrubTemplateExpressions(node) {
|
|
19961
|
+
var _node$querySelectorAl;
|
|
19492
19962
|
node.normalize();
|
|
19493
19963
|
const walker = createNodeIterator.call(node.ownerDocument || node, node,
|
|
19494
19964
|
// eslint-disable-next-line no-bitwise
|
|
19495
19965
|
NodeFilter.SHOW_TEXT | NodeFilter.SHOW_COMMENT | NodeFilter.SHOW_CDATA_SECTION | NodeFilter.SHOW_PROCESSING_INSTRUCTION, null);
|
|
19496
19966
|
let currentNode = walker.nextNode();
|
|
19497
19967
|
while (currentNode) {
|
|
19498
|
-
|
|
19499
|
-
arrayForEach([MUSTACHE_EXPR$1, ERB_EXPR$1, TMPLIT_EXPR$1], expr => {
|
|
19500
|
-
data = stringReplace(data, expr, ' ');
|
|
19501
|
-
});
|
|
19502
|
-
currentNode.data = data;
|
|
19968
|
+
currentNode.data = _stripTemplateExpressions(currentNode.data);
|
|
19503
19969
|
currentNode = walker.nextNode();
|
|
19504
19970
|
}
|
|
19971
|
+
// NodeIterator does not descend into <template>.content per the DOM spec,
|
|
19972
|
+
// so we must explicitly recurse into each template's content fragment,
|
|
19973
|
+
// mirroring the approach used by _sanitizeShadowDOM.
|
|
19974
|
+
const templates = (_node$querySelectorAl = node.querySelectorAll) === null || _node$querySelectorAl === void 0 ? void 0 : _node$querySelectorAl.call(node, 'template');
|
|
19975
|
+
if (templates) {
|
|
19976
|
+
arrayForEach(templates, tmpl => {
|
|
19977
|
+
if (_isDocumentFragment(tmpl.content)) {
|
|
19978
|
+
_scrubTemplateExpressions2(tmpl.content);
|
|
19979
|
+
}
|
|
19980
|
+
});
|
|
19981
|
+
}
|
|
19505
19982
|
};
|
|
19506
19983
|
/**
|
|
19507
19984
|
* _isClobbered
|
|
19508
19985
|
*
|
|
19986
|
+
* Detect DOM-clobbering on HTMLFormElement nodes. Form is the only HTML
|
|
19987
|
+
* interface with [LegacyOverrideBuiltIns]; a descendant element with a
|
|
19988
|
+
* `name` attribute matching a prototype property shadows that property
|
|
19989
|
+
* on direct reads. We use this check at the IN_PLACE entry-point and
|
|
19990
|
+
* during attribute sanitization to refuse clobbered forms.
|
|
19991
|
+
*
|
|
19509
19992
|
* @param element element to check for clobbering attacks
|
|
19510
19993
|
* @return true if clobbered, false if safe
|
|
19511
19994
|
*/
|
|
19512
19995
|
const _isClobbered = function _isClobbered(element) {
|
|
19513
|
-
|
|
19996
|
+
// Realm-independent tag-name probe. If we can't determine the tag
|
|
19997
|
+
// name at all, we can't reason about clobbering — return false
|
|
19998
|
+
// (the caller's other defences still apply).
|
|
19999
|
+
const realTagName = getNodeName ? getNodeName(element) : null;
|
|
20000
|
+
if (typeof realTagName !== 'string') {
|
|
20001
|
+
return false;
|
|
20002
|
+
}
|
|
20003
|
+
if (transformCaseFunc(realTagName) !== 'form') {
|
|
20004
|
+
return false;
|
|
20005
|
+
}
|
|
20006
|
+
return typeof element.nodeName !== 'string' || typeof element.textContent !== 'string' || typeof element.removeChild !== 'function' ||
|
|
20007
|
+
// Realm-safe NamedNodeMap detection: equality against the cached
|
|
20008
|
+
// prototype getter. Clobbered .attributes (e.g. <input name="attributes">)
|
|
20009
|
+
// makes the direct read diverge from the cached read; a clean form
|
|
20010
|
+
// (same-realm OR foreign-realm) has both reads pointing at the same
|
|
20011
|
+
// canonical NamedNodeMap.
|
|
20012
|
+
element.attributes !== getAttributes(element) || typeof element.removeAttribute !== 'function' || typeof element.setAttribute !== 'function' || typeof element.namespaceURI !== 'string' || typeof element.insertBefore !== 'function' || typeof element.hasChildNodes !== 'function' ||
|
|
20013
|
+
// NodeType clobbering probe. Cached Node.prototype.nodeType getter
|
|
20014
|
+
// returns the integer 1 for any Element regardless of realm; direct
|
|
20015
|
+
// read on a clobbered form (e.g. <input name="nodeType">) returns
|
|
20016
|
+
// the named child element. Cheap addition — nodeType is read from
|
|
20017
|
+
// an internal slot, no serialization cost — and removes a residual
|
|
20018
|
+
// clobbering surface used by several mXSS / PI / comment branches
|
|
20019
|
+
// in _sanitizeElements that compare currentNode.nodeType directly.
|
|
20020
|
+
element.nodeType !== getNodeType(element) ||
|
|
20021
|
+
// HTMLFormElement has [LegacyOverrideBuiltIns]: a descendant named
|
|
20022
|
+
// "childNodes" shadows the prototype getter. Direct reads of
|
|
20023
|
+
// form.childNodes from a clobbered form return the named child
|
|
20024
|
+
// instead of the real NodeList, so any walk that reads it directly
|
|
20025
|
+
// skips the form's real children. Compare the direct read to the
|
|
20026
|
+
// cached Node.prototype getter — when the form's named-property
|
|
20027
|
+
// getter intercepts the read, the two values differ and we flag
|
|
20028
|
+
// the form. This catches every clobbering child type (input,
|
|
20029
|
+
// select, etc.) regardless of whether the named child happens to
|
|
20030
|
+
// carry a numeric .length, which a typeof-based probe would miss
|
|
20031
|
+
// (e.g. HTMLSelectElement.length is a defined unsigned-long).
|
|
20032
|
+
element.childNodes !== getChildNodes(element);
|
|
20033
|
+
};
|
|
20034
|
+
/**
|
|
20035
|
+
* Checks whether the given value is a DocumentFragment from any realm.
|
|
20036
|
+
*
|
|
20037
|
+
* The realm-independent replacement reads `nodeType` through the cached
|
|
20038
|
+
* Node.prototype getter and compares to the DOCUMENT_FRAGMENT_NODE
|
|
20039
|
+
* constant (11). nodeType is a numeric value resolved from the node's
|
|
20040
|
+
* internal slot, identical across realms for the same kind of node.
|
|
20041
|
+
*
|
|
20042
|
+
* @param value object to check
|
|
20043
|
+
* @return true if value is a DocumentFragment-shaped node from any realm
|
|
20044
|
+
*/
|
|
20045
|
+
const _isDocumentFragment = function _isDocumentFragment(value) {
|
|
20046
|
+
if (!getNodeType || typeof value !== 'object' || value === null) {
|
|
20047
|
+
return false;
|
|
20048
|
+
}
|
|
20049
|
+
try {
|
|
20050
|
+
return getNodeType(value) === NODE_TYPE.documentFragment;
|
|
20051
|
+
} catch (_) {
|
|
20052
|
+
return false;
|
|
20053
|
+
}
|
|
19514
20054
|
};
|
|
19515
20055
|
/**
|
|
19516
20056
|
* Checks whether the given object is a DOM node, including nodes that
|
|
@@ -19520,12 +20060,6 @@
|
|
|
19520
20060
|
* sanitize() to silently stringify them and reset IN_PLACE to false,
|
|
19521
20061
|
* returning the original node unsanitized. See GHSA-4w3q-35jp-p934.
|
|
19522
20062
|
*
|
|
19523
|
-
* Implementation: call the cached `nodeType` getter from Node.prototype
|
|
19524
|
-
* directly on the value. This bypasses any clobbered instance property
|
|
19525
|
-
* (e.g. a child element named "nodeType") and works across realms
|
|
19526
|
-
* because the WebIDL `nodeType` getter reads an internal slot that
|
|
19527
|
-
* every real Node has, regardless of which window minted it.
|
|
19528
|
-
*
|
|
19529
20063
|
* @param value object to check whether it's a DOM node
|
|
19530
20064
|
* @return true if value is a DOM node from any realm
|
|
19531
20065
|
*/
|
|
@@ -19540,10 +20074,104 @@
|
|
|
19540
20074
|
}
|
|
19541
20075
|
};
|
|
19542
20076
|
function _executeHooks(hooks, currentNode, data) {
|
|
20077
|
+
if (hooks.length === 0) {
|
|
20078
|
+
return;
|
|
20079
|
+
}
|
|
19543
20080
|
arrayForEach(hooks, hook => {
|
|
19544
20081
|
hook.call(DOMPurify, currentNode, data, CONFIG);
|
|
19545
20082
|
});
|
|
19546
20083
|
}
|
|
20084
|
+
/**
|
|
20085
|
+
* Structural-threat checks that condemn a node regardless of the
|
|
20086
|
+
* allowlists: mXSS via namespace confusion, risky CSS construction,
|
|
20087
|
+
* processing instructions, markup-bearing comments. Pure predicate;
|
|
20088
|
+
* the caller removes. Check order is load-bearing.
|
|
20089
|
+
*
|
|
20090
|
+
* @param currentNode the node to inspect
|
|
20091
|
+
* @param tagName the node's transformCaseFunc'd tag name
|
|
20092
|
+
* @return true if the node must be removed
|
|
20093
|
+
*/
|
|
20094
|
+
const _isUnsafeNode = function _isUnsafeNode(currentNode, tagName) {
|
|
20095
|
+
/* Detect mXSS attempts abusing namespace confusion */
|
|
20096
|
+
if (SAFE_FOR_XML && currentNode.hasChildNodes() && !_isNode(currentNode.firstElementChild) && regExpTest(ELEMENT_MARKUP_PROBE, currentNode.textContent) && regExpTest(ELEMENT_MARKUP_PROBE, currentNode.innerHTML)) {
|
|
20097
|
+
return true;
|
|
20098
|
+
}
|
|
20099
|
+
/* Remove risky CSS construction leading to mXSS */
|
|
20100
|
+
if (SAFE_FOR_XML && currentNode.namespaceURI === HTML_NAMESPACE && tagName === 'style' && _isNode(currentNode.firstElementChild)) {
|
|
20101
|
+
return true;
|
|
20102
|
+
}
|
|
20103
|
+
/* Remove any occurrence of processing instructions */
|
|
20104
|
+
if (currentNode.nodeType === NODE_TYPE.processingInstruction) {
|
|
20105
|
+
return true;
|
|
20106
|
+
}
|
|
20107
|
+
/* Remove any kind of possibly harmful comments */
|
|
20108
|
+
if (SAFE_FOR_XML && currentNode.nodeType === NODE_TYPE.comment && regExpTest(COMMENT_MARKUP_PROBE, currentNode.data)) {
|
|
20109
|
+
return true;
|
|
20110
|
+
}
|
|
20111
|
+
return false;
|
|
20112
|
+
};
|
|
20113
|
+
/**
|
|
20114
|
+
* Handle a node whose tag is forbidden or not allowlisted: keep
|
|
20115
|
+
* allowed custom elements (false return exits _sanitizeElements
|
|
20116
|
+
* early - namespace/fallback checks and the afterSanitizeElements
|
|
20117
|
+
* hook are intentionally skipped for kept custom elements), else
|
|
20118
|
+
* hoist content per KEEP_CONTENT and remove.
|
|
20119
|
+
*
|
|
20120
|
+
* @param currentNode the disallowed node
|
|
20121
|
+
* @param tagName the node's transformCaseFunc'd tag name
|
|
20122
|
+
* @return true if the node was removed, false if kept
|
|
20123
|
+
*/
|
|
20124
|
+
const _sanitizeDisallowedNode = function _sanitizeDisallowedNode(currentNode, tagName) {
|
|
20125
|
+
/* Check if we have a custom element to handle */
|
|
20126
|
+
if (!FORBID_TAGS[tagName] && _isBasicCustomElement(tagName)) {
|
|
20127
|
+
if (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof RegExp && regExpTest(CUSTOM_ELEMENT_HANDLING.tagNameCheck, tagName)) {
|
|
20128
|
+
return false;
|
|
20129
|
+
}
|
|
20130
|
+
if (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof Function && CUSTOM_ELEMENT_HANDLING.tagNameCheck(tagName)) {
|
|
20131
|
+
return false;
|
|
20132
|
+
}
|
|
20133
|
+
}
|
|
20134
|
+
/* Keep content except for bad-listed elements.
|
|
20135
|
+
Use the cached prototype getters exclusively — the previous code
|
|
20136
|
+
had `|| currentNode.parentNode` / `|| currentNode.childNodes`
|
|
20137
|
+
fallbacks, but the cached getters always return the canonical
|
|
20138
|
+
value (or null for a real parent-less node), so the fallback
|
|
20139
|
+
path was dead in safe cases and a clobbering surface in unsafe
|
|
20140
|
+
ones. Falsy cached results stay falsy; the `if (childNodes &&
|
|
20141
|
+
parentNode)` check already gates correctly. */
|
|
20142
|
+
if (KEEP_CONTENT && !FORBID_CONTENTS[tagName]) {
|
|
20143
|
+
const parentNode = getParentNode(currentNode);
|
|
20144
|
+
const childNodes = getChildNodes(currentNode);
|
|
20145
|
+
if (childNodes && parentNode) {
|
|
20146
|
+
const childCount = childNodes.length;
|
|
20147
|
+
/* In-place: hoist the *original* children so the iterator visits
|
|
20148
|
+
and sanitises them through the same allowlist pass as every other
|
|
20149
|
+
node. The caller built the tree in the live document, so the
|
|
20150
|
+
originals carry already-queued resource events (`<img onerror>`,
|
|
20151
|
+
`<video>`/`<audio>` error, lazy/`onload`, …); cloning would leave
|
|
20152
|
+
those originals detached but still armed, firing in page scope
|
|
20153
|
+
while the returned tree looked clean. Moving is safe in-place: the
|
|
20154
|
+
root is pre-validated as an allowed tag and so is never the node
|
|
20155
|
+
being removed, which keeps `parentNode` inside the iterator root
|
|
20156
|
+
and the relocated child inside the serialised tree.
|
|
20157
|
+
Otherwise (string / DOM-copy paths): clone. The iterator is rooted
|
|
20158
|
+
at — and the result serialised from — `body`, so a restrictive
|
|
20159
|
+
ALLOWED_TAGS that removes `body` itself must leave its content in
|
|
20160
|
+
place, which only cloning does; and those paths parse into an
|
|
20161
|
+
inert document, so their discarded originals never had a queued
|
|
20162
|
+
event to neutralise.
|
|
20163
|
+
`childNodes` is live; a tail-to-head walk keeps `childNodes[i]`
|
|
20164
|
+
valid whether we move (drops the trailing entry) or clone (leaves
|
|
20165
|
+
the list intact). */
|
|
20166
|
+
for (let i = childCount - 1; i >= 0; --i) {
|
|
20167
|
+
const hoisted = IN_PLACE ? childNodes[i] : cloneNode(childNodes[i], true);
|
|
20168
|
+
parentNode.insertBefore(hoisted, getNextSibling(currentNode));
|
|
20169
|
+
}
|
|
20170
|
+
}
|
|
20171
|
+
}
|
|
20172
|
+
_forceRemove(currentNode);
|
|
20173
|
+
return true;
|
|
20174
|
+
};
|
|
19547
20175
|
/**
|
|
19548
20176
|
* _sanitizeElements
|
|
19549
20177
|
*
|
|
@@ -19554,7 +20182,6 @@
|
|
|
19554
20182
|
* @return true if node was killed, false if left alive
|
|
19555
20183
|
*/
|
|
19556
20184
|
const _sanitizeElements = function _sanitizeElements(currentNode) {
|
|
19557
|
-
let content = null;
|
|
19558
20185
|
/* Execute a hook if present */
|
|
19559
20186
|
_executeHooks(hooks.beforeSanitizeElements, currentNode, null);
|
|
19560
20187
|
/* Check if element is clobbered or can clobber */
|
|
@@ -19563,75 +20190,41 @@
|
|
|
19563
20190
|
return true;
|
|
19564
20191
|
}
|
|
19565
20192
|
/* Now let's check the element's type and name */
|
|
19566
|
-
const tagName = transformCaseFunc(currentNode.nodeName);
|
|
20193
|
+
const tagName = transformCaseFunc(getNodeName ? getNodeName(currentNode) : currentNode.nodeName);
|
|
19567
20194
|
/* Execute a hook if present */
|
|
19568
20195
|
_executeHooks(hooks.uponSanitizeElement, currentNode, {
|
|
19569
20196
|
tagName,
|
|
19570
20197
|
allowedTags: ALLOWED_TAGS
|
|
19571
20198
|
});
|
|
19572
|
-
/*
|
|
19573
|
-
if (
|
|
19574
|
-
_forceRemove(currentNode);
|
|
19575
|
-
return true;
|
|
19576
|
-
}
|
|
19577
|
-
/* Remove risky CSS construction leading to mXSS */
|
|
19578
|
-
if (SAFE_FOR_XML && currentNode.namespaceURI === HTML_NAMESPACE && tagName === 'style' && _isNode(currentNode.firstElementChild)) {
|
|
19579
|
-
_forceRemove(currentNode);
|
|
19580
|
-
return true;
|
|
19581
|
-
}
|
|
19582
|
-
/* Remove any occurrence of processing instructions */
|
|
19583
|
-
if (currentNode.nodeType === NODE_TYPE.progressingInstruction) {
|
|
19584
|
-
_forceRemove(currentNode);
|
|
19585
|
-
return true;
|
|
19586
|
-
}
|
|
19587
|
-
/* Remove any kind of possibly harmful comments */
|
|
19588
|
-
if (SAFE_FOR_XML && currentNode.nodeType === NODE_TYPE.comment && regExpTest(/<[/\w]/g, currentNode.data)) {
|
|
20199
|
+
/* Remove mXSS vectors, processing instructions and risky comments */
|
|
20200
|
+
if (_isUnsafeNode(currentNode, tagName)) {
|
|
19589
20201
|
_forceRemove(currentNode);
|
|
19590
20202
|
return true;
|
|
19591
20203
|
}
|
|
19592
20204
|
/* Remove element if anything forbids its presence */
|
|
19593
20205
|
if (FORBID_TAGS[tagName] || !(EXTRA_ELEMENT_HANDLING.tagCheck instanceof Function && EXTRA_ELEMENT_HANDLING.tagCheck(tagName)) && !ALLOWED_TAGS[tagName]) {
|
|
19594
|
-
|
|
19595
|
-
|
|
19596
|
-
|
|
19597
|
-
|
|
19598
|
-
|
|
19599
|
-
|
|
19600
|
-
|
|
19601
|
-
|
|
19602
|
-
|
|
19603
|
-
|
|
19604
|
-
if (KEEP_CONTENT && !FORBID_CONTENTS[tagName]) {
|
|
19605
|
-
const parentNode = getParentNode(currentNode) || currentNode.parentNode;
|
|
19606
|
-
const childNodes = getChildNodes(currentNode) || currentNode.childNodes;
|
|
19607
|
-
if (childNodes && parentNode) {
|
|
19608
|
-
const childCount = childNodes.length;
|
|
19609
|
-
for (let i = childCount - 1; i >= 0; --i) {
|
|
19610
|
-
const childClone = cloneNode(childNodes[i], true);
|
|
19611
|
-
parentNode.insertBefore(childClone, getNextSibling(currentNode));
|
|
19612
|
-
}
|
|
19613
|
-
}
|
|
19614
|
-
}
|
|
19615
|
-
_forceRemove(currentNode);
|
|
19616
|
-
return true;
|
|
19617
|
-
}
|
|
19618
|
-
/* Check whether element has a valid namespace */
|
|
19619
|
-
if (currentNode instanceof Element && !_checkValidNamespace(currentNode)) {
|
|
20206
|
+
return _sanitizeDisallowedNode(currentNode, tagName);
|
|
20207
|
+
}
|
|
20208
|
+
/* Check whether element has a valid namespace.
|
|
20209
|
+
Realm-safe check (GHSA-hpcv-96wg-7vj8): use the cached Node.prototype
|
|
20210
|
+
nodeType getter rather than `instanceof Element`, which is realm-
|
|
20211
|
+
bound and short-circuits to false for any node minted in a different
|
|
20212
|
+
realm — letting a foreign-realm element with a forbidden namespace
|
|
20213
|
+
slip past the namespace check entirely. */
|
|
20214
|
+
const nt = getNodeType ? getNodeType(currentNode) : currentNode.nodeType;
|
|
20215
|
+
if (nt === NODE_TYPE.element && !_checkValidNamespace(currentNode)) {
|
|
19620
20216
|
_forceRemove(currentNode);
|
|
19621
20217
|
return true;
|
|
19622
20218
|
}
|
|
19623
20219
|
/* Make sure that older browsers don't get fallback-tag mXSS */
|
|
19624
|
-
if ((tagName === 'noscript' || tagName === 'noembed' || tagName === 'noframes') && regExpTest(
|
|
20220
|
+
if ((tagName === 'noscript' || tagName === 'noembed' || tagName === 'noframes') && regExpTest(FALLBACK_TAG_CLOSE, currentNode.innerHTML)) {
|
|
19625
20221
|
_forceRemove(currentNode);
|
|
19626
20222
|
return true;
|
|
19627
20223
|
}
|
|
19628
20224
|
/* Sanitize element content to be template-safe */
|
|
19629
20225
|
if (SAFE_FOR_TEMPLATES && currentNode.nodeType === NODE_TYPE.text) {
|
|
19630
20226
|
/* Get the element's text content */
|
|
19631
|
-
content = currentNode.textContent;
|
|
19632
|
-
arrayForEach([MUSTACHE_EXPR$1, ERB_EXPR$1, TMPLIT_EXPR$1], expr => {
|
|
19633
|
-
content = stringReplace(content, expr, ' ');
|
|
19634
|
-
});
|
|
20227
|
+
const content = _stripTemplateExpressions(currentNode.textContent);
|
|
19635
20228
|
if (currentNode.textContent !== content) {
|
|
19636
20229
|
arrayPush(DOMPurify.removed, {
|
|
19637
20230
|
element: currentNode.cloneNode()
|
|
@@ -19666,7 +20259,7 @@
|
|
|
19666
20259
|
(https://html.spec.whatwg.org/multipage/dom.html#embedding-custom-non-visible-data-with-the-data-*-attributes)
|
|
19667
20260
|
XML-compatible (https://html.spec.whatwg.org/multipage/infrastructure.html#xml-compatible and http://www.w3.org/TR/xml/#d0e804)
|
|
19668
20261
|
We don't need to check the value; it's always URI safe. */
|
|
19669
|
-
if (ALLOW_DATA_ATTR &&
|
|
20262
|
+
if (ALLOW_DATA_ATTR && regExpTest(DATA_ATTR$1, lcName)) ; else if (ALLOW_ARIA_ATTR && regExpTest(ARIA_ATTR$1, lcName)) ; else if (!nameIsPermitted) {
|
|
19670
20263
|
if (
|
|
19671
20264
|
// First condition does a very basic check if a) it's basically a valid custom element tagname AND
|
|
19672
20265
|
// b) if the tagName passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.tagNameCheck
|
|
@@ -19698,6 +20291,63 @@
|
|
|
19698
20291
|
const _isBasicCustomElement = function _isBasicCustomElement(tagName) {
|
|
19699
20292
|
return !RESERVED_CUSTOM_ELEMENT_NAMES[stringToLowerCase(tagName)] && regExpTest(CUSTOM_ELEMENT$1, tagName);
|
|
19700
20293
|
};
|
|
20294
|
+
/**
|
|
20295
|
+
* Wrap an attribute value in the matching Trusted Types object when
|
|
20296
|
+
* the active policy requires it. Namespaced attributes pass through
|
|
20297
|
+
* unchanged (no TT support yet, see
|
|
20298
|
+
* https://bugs.chromium.org/p/chromium/issues/detail?id=1305293).
|
|
20299
|
+
*
|
|
20300
|
+
* @param lcTag lowercase tag name of the containing element
|
|
20301
|
+
* @param lcName lowercase attribute name
|
|
20302
|
+
* @param namespaceURI the attribute's namespace, if any
|
|
20303
|
+
* @param value the attribute value to wrap
|
|
20304
|
+
* @return the value, wrapped when Trusted Types demand it
|
|
20305
|
+
*/
|
|
20306
|
+
const _applyTrustedTypesToAttribute = function _applyTrustedTypesToAttribute(lcTag, lcName, namespaceURI, value) {
|
|
20307
|
+
if (trustedTypesPolicy && typeof trustedTypes === 'object' && typeof trustedTypes.getAttributeType === 'function' && !namespaceURI) {
|
|
20308
|
+
switch (trustedTypes.getAttributeType(lcTag, lcName)) {
|
|
20309
|
+
case 'TrustedHTML':
|
|
20310
|
+
{
|
|
20311
|
+
return _createTrustedHTML(value);
|
|
20312
|
+
}
|
|
20313
|
+
case 'TrustedScriptURL':
|
|
20314
|
+
{
|
|
20315
|
+
return _createTrustedScriptURL(value);
|
|
20316
|
+
}
|
|
20317
|
+
}
|
|
20318
|
+
}
|
|
20319
|
+
return value;
|
|
20320
|
+
};
|
|
20321
|
+
/**
|
|
20322
|
+
* Write a modified attribute value back onto the element. On
|
|
20323
|
+
* success, re-probe for clobbering introduced by the new value and
|
|
20324
|
+
* remove the element when found; otherwise pop the removal entry
|
|
20325
|
+
* recorded by the earlier _removeAttribute (long-standing pairing
|
|
20326
|
+
* with the SANITIZE_NAMED_PROPS path - do not "fix" casually). On
|
|
20327
|
+
* failure, remove the attribute instead.
|
|
20328
|
+
*
|
|
20329
|
+
* @param currentNode the element carrying the attribute
|
|
20330
|
+
* @param name the attribute name as present on the element
|
|
20331
|
+
* @param namespaceURI the attribute's namespace, if any
|
|
20332
|
+
* @param value the new attribute value
|
|
20333
|
+
*/
|
|
20334
|
+
const _setAttributeValue = function _setAttributeValue(currentNode, name, namespaceURI, value) {
|
|
20335
|
+
try {
|
|
20336
|
+
if (namespaceURI) {
|
|
20337
|
+
currentNode.setAttributeNS(namespaceURI, name, value);
|
|
20338
|
+
} else {
|
|
20339
|
+
/* Fallback to setAttribute() for browser-unrecognized namespaces e.g. "x-schema". */
|
|
20340
|
+
currentNode.setAttribute(name, value);
|
|
20341
|
+
}
|
|
20342
|
+
if (_isClobbered(currentNode)) {
|
|
20343
|
+
_forceRemove(currentNode);
|
|
20344
|
+
} else {
|
|
20345
|
+
arrayPop(DOMPurify.removed);
|
|
20346
|
+
}
|
|
20347
|
+
} catch (_) {
|
|
20348
|
+
_removeAttribute(name, currentNode);
|
|
20349
|
+
}
|
|
20350
|
+
};
|
|
19701
20351
|
/**
|
|
19702
20352
|
* _sanitizeAttributes
|
|
19703
20353
|
*
|
|
@@ -19724,6 +20374,7 @@
|
|
|
19724
20374
|
forceKeepAttr: undefined
|
|
19725
20375
|
};
|
|
19726
20376
|
let l = attributes.length;
|
|
20377
|
+
const lcTag = transformCaseFunc(currentNode.nodeName);
|
|
19727
20378
|
/* Go backwards over all attributes; safely remove bad ones */
|
|
19728
20379
|
while (l--) {
|
|
19729
20380
|
const attr = attributes[l];
|
|
@@ -19761,7 +20412,7 @@
|
|
|
19761
20412
|
_removeAttribute(name, currentNode);
|
|
19762
20413
|
continue;
|
|
19763
20414
|
}
|
|
19764
|
-
/* Did the hooks
|
|
20415
|
+
/* Did the hooks force-keep the attribute? */
|
|
19765
20416
|
if (hookEvent.forceKeepAttr) {
|
|
19766
20417
|
continue;
|
|
19767
20418
|
}
|
|
@@ -19771,56 +20422,24 @@
|
|
|
19771
20422
|
continue;
|
|
19772
20423
|
}
|
|
19773
20424
|
/* Work around a security issue in jQuery 3.0 */
|
|
19774
|
-
if (!ALLOW_SELF_CLOSE_IN_ATTR && regExpTest(
|
|
20425
|
+
if (!ALLOW_SELF_CLOSE_IN_ATTR && regExpTest(SELF_CLOSING_TAG, value)) {
|
|
19775
20426
|
_removeAttribute(name, currentNode);
|
|
19776
20427
|
continue;
|
|
19777
20428
|
}
|
|
19778
20429
|
/* Sanitize attribute content to be template-safe */
|
|
19779
20430
|
if (SAFE_FOR_TEMPLATES) {
|
|
19780
|
-
|
|
19781
|
-
value = stringReplace(value, expr, ' ');
|
|
19782
|
-
});
|
|
20431
|
+
value = _stripTemplateExpressions(value);
|
|
19783
20432
|
}
|
|
19784
20433
|
/* Is `value` valid for this attribute? */
|
|
19785
|
-
const lcTag = transformCaseFunc(currentNode.nodeName);
|
|
19786
20434
|
if (!_isValidAttribute(lcTag, lcName, value)) {
|
|
19787
20435
|
_removeAttribute(name, currentNode);
|
|
19788
20436
|
continue;
|
|
19789
20437
|
}
|
|
19790
20438
|
/* Handle attributes that require Trusted Types */
|
|
19791
|
-
|
|
19792
|
-
if (namespaceURI) ; else {
|
|
19793
|
-
switch (trustedTypes.getAttributeType(lcTag, lcName)) {
|
|
19794
|
-
case 'TrustedHTML':
|
|
19795
|
-
{
|
|
19796
|
-
value = trustedTypesPolicy.createHTML(value);
|
|
19797
|
-
break;
|
|
19798
|
-
}
|
|
19799
|
-
case 'TrustedScriptURL':
|
|
19800
|
-
{
|
|
19801
|
-
value = trustedTypesPolicy.createScriptURL(value);
|
|
19802
|
-
break;
|
|
19803
|
-
}
|
|
19804
|
-
}
|
|
19805
|
-
}
|
|
19806
|
-
}
|
|
20439
|
+
value = _applyTrustedTypesToAttribute(lcTag, lcName, namespaceURI, value);
|
|
19807
20440
|
/* Handle invalid data-* attribute set by try-catching it */
|
|
19808
20441
|
if (value !== initValue) {
|
|
19809
|
-
|
|
19810
|
-
if (namespaceURI) {
|
|
19811
|
-
currentNode.setAttributeNS(namespaceURI, name, value);
|
|
19812
|
-
} else {
|
|
19813
|
-
/* Fallback to setAttribute() for browser-unrecognized namespaces e.g. "x-schema". */
|
|
19814
|
-
currentNode.setAttribute(name, value);
|
|
19815
|
-
}
|
|
19816
|
-
if (_isClobbered(currentNode)) {
|
|
19817
|
-
_forceRemove(currentNode);
|
|
19818
|
-
} else {
|
|
19819
|
-
arrayPop(DOMPurify.removed);
|
|
19820
|
-
}
|
|
19821
|
-
} catch (_) {
|
|
19822
|
-
_removeAttribute(name, currentNode);
|
|
19823
|
-
}
|
|
20442
|
+
_setAttributeValue(currentNode, name, namespaceURI, value);
|
|
19824
20443
|
}
|
|
19825
20444
|
}
|
|
19826
20445
|
/* Execute a hook if present */
|
|
@@ -19843,10 +20462,31 @@
|
|
|
19843
20462
|
_sanitizeElements(shadowNode);
|
|
19844
20463
|
/* Check attributes next */
|
|
19845
20464
|
_sanitizeAttributes(shadowNode);
|
|
19846
|
-
/* Deep shadow DOM detected
|
|
19847
|
-
|
|
20465
|
+
/* Deep shadow DOM detected.
|
|
20466
|
+
Realm-safe check (GHSA-hpcv-96wg-7vj8): use nodeType against the
|
|
20467
|
+
DOCUMENT_FRAGMENT_NODE constant rather than instanceof, so we
|
|
20468
|
+
recurse into <template>.content from foreign realms too. */
|
|
20469
|
+
if (_isDocumentFragment(shadowNode.content)) {
|
|
19848
20470
|
_sanitizeShadowDOM2(shadowNode.content);
|
|
19849
20471
|
}
|
|
20472
|
+
/* An element iterated here may itself host an attached
|
|
20473
|
+
shadow root. The default NodeIterator does not enter shadow
|
|
20474
|
+
trees, so a shadow root nested inside template.content was
|
|
20475
|
+
previously reached by no walk at all (the pre-pass at
|
|
20476
|
+
_sanitizeAttachedShadowRoots descends via childNodes, which
|
|
20477
|
+
doesn't enter template.content; the template-content recursion
|
|
20478
|
+
above iterates the content but never inspected shadowRoot).
|
|
20479
|
+
Walk it explicitly. The nodeType guard avoids reading
|
|
20480
|
+
shadowRoot off text / comment / CDATA / PI nodes that the
|
|
20481
|
+
iterator also surfaces. */
|
|
20482
|
+
const shadowNodeType = getNodeType ? getNodeType(shadowNode) : shadowNode.nodeType;
|
|
20483
|
+
if (shadowNodeType === NODE_TYPE.element) {
|
|
20484
|
+
const innerSr = getShadowRoot(shadowNode);
|
|
20485
|
+
if (_isDocumentFragment(innerSr)) {
|
|
20486
|
+
_sanitizeAttachedShadowRoots(innerSr);
|
|
20487
|
+
_sanitizeShadowDOM2(innerSr);
|
|
20488
|
+
}
|
|
20489
|
+
}
|
|
19850
20490
|
}
|
|
19851
20491
|
/* Execute a hook if present */
|
|
19852
20492
|
_executeHooks(hooks.afterSanitizeShadowDOM, fragment, null);
|
|
@@ -19870,28 +20510,83 @@
|
|
|
19870
20510
|
*
|
|
19871
20511
|
* @param root the subtree root to walk for attached shadow roots
|
|
19872
20512
|
*/
|
|
19873
|
-
const
|
|
19874
|
-
|
|
19875
|
-
|
|
19876
|
-
|
|
19877
|
-
|
|
19878
|
-
|
|
19879
|
-
|
|
19880
|
-
|
|
19881
|
-
|
|
19882
|
-
|
|
19883
|
-
|
|
19884
|
-
|
|
19885
|
-
|
|
19886
|
-
|
|
19887
|
-
|
|
19888
|
-
|
|
19889
|
-
const
|
|
19890
|
-
|
|
19891
|
-
|
|
19892
|
-
}
|
|
19893
|
-
|
|
19894
|
-
|
|
20513
|
+
const _sanitizeAttachedShadowRoots = function _sanitizeAttachedShadowRoots(root) {
|
|
20514
|
+
/* Iterative (explicit stack) rather than per-child recursion. DOM APIs
|
|
20515
|
+
impose no depth cap, so an attacker-shaped tree (JSON/CRDT/editor data
|
|
20516
|
+
built straight into the DOM — the IN_PLACE surface) deeper than the JS
|
|
20517
|
+
call-stack budget would otherwise overflow native recursion here and
|
|
20518
|
+
throw at the IN_PLACE entry pre-pass, before a single node is
|
|
20519
|
+
sanitized, leaving the caller's live tree untouched (fail-open). See
|
|
20520
|
+
campaign-3 F4. A heap stack keeps depth off the call stack.
|
|
20521
|
+
Each work item is either a node to descend into, or a deferred
|
|
20522
|
+
`_sanitizeShadowDOM` for an already-walked shadow root. The deferred
|
|
20523
|
+
form preserves the original post-order discipline: a shadow root's
|
|
20524
|
+
nested shadow roots are discovered before the outer shadow is
|
|
20525
|
+
sanitized (which may remove hosts). Pushes are in reverse of the
|
|
20526
|
+
desired processing order (LIFO): template content, then children, then
|
|
20527
|
+
the shadow-sanitize, then the shadow walk — so the order matches the
|
|
20528
|
+
previous recursion exactly. */
|
|
20529
|
+
const stack = [{
|
|
20530
|
+
node: root,
|
|
20531
|
+
shadow: null
|
|
20532
|
+
}];
|
|
20533
|
+
while (stack.length > 0) {
|
|
20534
|
+
const item = stack.pop();
|
|
20535
|
+
/* Deferred shadow-DOM sanitisation: runs after its subtree was walked. */
|
|
20536
|
+
if (item.shadow) {
|
|
20537
|
+
_sanitizeShadowDOM2(item.shadow);
|
|
20538
|
+
continue;
|
|
20539
|
+
}
|
|
20540
|
+
const node = item.node;
|
|
20541
|
+
const nodeType = getNodeType ? getNodeType(node) : node.nodeType;
|
|
20542
|
+
const isElement = nodeType === NODE_TYPE.element;
|
|
20543
|
+
/* (pushed last → processed first) Children, snapshotted in reverse so
|
|
20544
|
+
the first child is processed first. Snapshotting matters because a
|
|
20545
|
+
hook may detach siblings mid-walk. */
|
|
20546
|
+
const childNodes = getChildNodes(node);
|
|
20547
|
+
if (childNodes) {
|
|
20548
|
+
for (let i = childNodes.length - 1; i >= 0; --i) {
|
|
20549
|
+
stack.push({
|
|
20550
|
+
node: childNodes[i],
|
|
20551
|
+
shadow: null
|
|
20552
|
+
});
|
|
20553
|
+
}
|
|
20554
|
+
}
|
|
20555
|
+
/* (pushed before children → processed after them, matching the old
|
|
20556
|
+
"template content last" order) When the node is a <template>,
|
|
20557
|
+
descend into its content. */
|
|
20558
|
+
if (isElement) {
|
|
20559
|
+
const rootName = getNodeName ? getNodeName(node) : null;
|
|
20560
|
+
if (typeof rootName === 'string' && transformCaseFunc(rootName) === 'template') {
|
|
20561
|
+
const content = node.content;
|
|
20562
|
+
if (_isDocumentFragment(content)) {
|
|
20563
|
+
stack.push({
|
|
20564
|
+
node: content,
|
|
20565
|
+
shadow: null
|
|
20566
|
+
});
|
|
20567
|
+
}
|
|
20568
|
+
}
|
|
20569
|
+
}
|
|
20570
|
+
/* Shadow root (processed first): walk its subtree, then sanitise it.
|
|
20571
|
+
Realm-safe check (GHSA-hpcv-96wg-7vj8): nodeType-based detection
|
|
20572
|
+
rather than `instanceof DocumentFragment`, which is realm-bound and
|
|
20573
|
+
silently skipped foreign-realm shadow roots (e.g.
|
|
20574
|
+
iframe.contentDocument attachShadow). */
|
|
20575
|
+
if (isElement) {
|
|
20576
|
+
const sr = getShadowRoot(node);
|
|
20577
|
+
if (_isDocumentFragment(sr)) {
|
|
20578
|
+
/* Push the deferred sanitise first so it pops after the shadow
|
|
20579
|
+
walk we push next, i.e. nested shadow roots are discovered
|
|
20580
|
+
before this one is sanitised. */
|
|
20581
|
+
stack.push({
|
|
20582
|
+
node: null,
|
|
20583
|
+
shadow: sr
|
|
20584
|
+
}, {
|
|
20585
|
+
node: sr,
|
|
20586
|
+
shadow: null
|
|
20587
|
+
});
|
|
20588
|
+
}
|
|
20589
|
+
}
|
|
19895
20590
|
}
|
|
19896
20591
|
};
|
|
19897
20592
|
// eslint-disable-next-line complexity
|
|
@@ -19920,27 +20615,77 @@
|
|
|
19920
20615
|
return dirty;
|
|
19921
20616
|
}
|
|
19922
20617
|
/* Assign config vars */
|
|
19923
|
-
if (
|
|
20618
|
+
if (SET_CONFIG) {
|
|
20619
|
+
/* Persistent setConfig() path: _parseConfig is skipped, so the sets are
|
|
20620
|
+
* not re-derived per call. Restore them from the pristine bindings
|
|
20621
|
+
* captured at setConfig() time so a previous call's hook clone (mutated
|
|
20622
|
+
* below) does not carry over. */
|
|
20623
|
+
ALLOWED_TAGS = SET_CONFIG_ALLOWED_TAGS;
|
|
20624
|
+
ALLOWED_ATTR = SET_CONFIG_ALLOWED_ATTR;
|
|
20625
|
+
} else {
|
|
19924
20626
|
_parseConfig(cfg);
|
|
19925
20627
|
}
|
|
20628
|
+
/* Clone the hook-mutable allowlists before the walk whenever an
|
|
20629
|
+
* uponSanitize* hook is registered. The hook event exposes ALLOWED_TAGS
|
|
20630
|
+
* and ALLOWED_ATTR by reference (as allowedTags / allowedAttributes), so
|
|
20631
|
+
* a hook that widens them would otherwise mutate the shared set
|
|
20632
|
+
* permanently: across later calls and across every element. Cloning per
|
|
20633
|
+
* walk keeps documented in-call widening working while scoping it to the
|
|
20634
|
+
* call. A single guard for both config paths - the per-call path rebinds
|
|
20635
|
+
* the sets in _parseConfig each call, the persistent path restores them
|
|
20636
|
+
* from the captured bindings just above - so the two cannot diverge. */
|
|
20637
|
+
if (hooks.uponSanitizeElement.length > 0 || hooks.uponSanitizeAttribute.length > 0) {
|
|
20638
|
+
ALLOWED_TAGS = clone(ALLOWED_TAGS);
|
|
20639
|
+
}
|
|
20640
|
+
if (hooks.uponSanitizeAttribute.length > 0) {
|
|
20641
|
+
ALLOWED_ATTR = clone(ALLOWED_ATTR);
|
|
20642
|
+
}
|
|
19926
20643
|
/* Clean up removed elements */
|
|
19927
20644
|
DOMPurify.removed = [];
|
|
19928
|
-
/*
|
|
19929
|
-
|
|
19930
|
-
|
|
19931
|
-
|
|
19932
|
-
|
|
19933
|
-
|
|
19934
|
-
|
|
20645
|
+
/* Resolve IN_PLACE for this call without mutating persistent config.
|
|
20646
|
+
Writing the IN_PLACE closure variable here leaks under setConfig(),
|
|
20647
|
+
where _parseConfig is skipped on later calls: a single string call would
|
|
20648
|
+
disable in-place mode for every subsequent node call, returning a
|
|
20649
|
+
sanitized copy while leaving the caller's node — which in-place callers
|
|
20650
|
+
keep using and whose return value they ignore — unsanitized. REPORT-2. */
|
|
20651
|
+
const inPlace = IN_PLACE && typeof dirty !== 'string' && _isNode(dirty);
|
|
20652
|
+
if (inPlace) {
|
|
20653
|
+
/* Do some early pre-sanitization to avoid unsafe root nodes.
|
|
20654
|
+
Read nodeName through the cached prototype getter — a clobbering
|
|
20655
|
+
child named "nodeName" on the form root would otherwise shadow
|
|
20656
|
+
the property and let this check skip the root-allowlist
|
|
20657
|
+
validation entirely. */
|
|
20658
|
+
const nn = getNodeName ? getNodeName(dirty) : dirty.nodeName;
|
|
19935
20659
|
if (typeof nn === 'string') {
|
|
19936
20660
|
const tagName = transformCaseFunc(nn);
|
|
19937
20661
|
if (!ALLOWED_TAGS[tagName] || FORBID_TAGS[tagName]) {
|
|
19938
20662
|
throw typeErrorCreate('root node is forbidden and cannot be sanitized in-place');
|
|
19939
20663
|
}
|
|
19940
20664
|
}
|
|
20665
|
+
/* Pre-flight the root through _isClobbered. The iterator-driven
|
|
20666
|
+
removal path can not detach a parent-less root: _forceRemove
|
|
20667
|
+
falls through to Element.prototype.remove(), which per spec
|
|
20668
|
+
is a no-op on a node with no parent. A clobbered root would
|
|
20669
|
+
then survive the main loop with its attributes uninspected,
|
|
20670
|
+
because _sanitizeAttributes early-returns on _isClobbered. The
|
|
20671
|
+
result would be an attacker-controlled form, complete with any
|
|
20672
|
+
event-handler attributes the caller passed in, handed back to
|
|
20673
|
+
the application unsanitized. Refuse to sanitize such a root
|
|
20674
|
+
the same way we refuse a forbidden tag. GHSA-r47g-fvhr-h676. */
|
|
20675
|
+
if (_isClobbered(dirty)) {
|
|
20676
|
+
throw typeErrorCreate('root node is clobbered and cannot be sanitized in-place');
|
|
20677
|
+
}
|
|
19941
20678
|
/* Sanitize attached shadow roots before the main iterator runs.
|
|
19942
|
-
The iterator does not descend into shadow trees.
|
|
19943
|
-
|
|
20679
|
+
The iterator does not descend into shadow trees. Same fail-closed
|
|
20680
|
+
barrier as the main walk (campaign-3 F2): a custom-element reaction
|
|
20681
|
+
inside a shadow root could abort this pre-pass before the walk runs,
|
|
20682
|
+
which would otherwise leave the entire live tree unsanitized. */
|
|
20683
|
+
try {
|
|
20684
|
+
_sanitizeAttachedShadowRoots(dirty);
|
|
20685
|
+
} catch (error) {
|
|
20686
|
+
_neutralizeRoot(dirty);
|
|
20687
|
+
throw error;
|
|
20688
|
+
}
|
|
19944
20689
|
} else if (_isNode(dirty)) {
|
|
19945
20690
|
/* If dirty is a DOM element, append to an empty document to avoid
|
|
19946
20691
|
elements being stripped by the parser */
|
|
@@ -19957,14 +20702,16 @@
|
|
|
19957
20702
|
}
|
|
19958
20703
|
/* Clonable shadow roots are deep-cloned by importNode(); sanitize
|
|
19959
20704
|
them before the main iterator runs, since the iterator does not
|
|
19960
|
-
descend into shadow trees.
|
|
19961
|
-
|
|
20705
|
+
descend into shadow trees. The walk routes every read through a
|
|
20706
|
+
cached prototype getter so clobbering descendants on a form root
|
|
20707
|
+
cannot hide a shadow host from this pass. */
|
|
20708
|
+
_sanitizeAttachedShadowRoots(importedNode);
|
|
19962
20709
|
} else {
|
|
19963
20710
|
/* Exit directly if we have nothing to do */
|
|
19964
20711
|
if (!RETURN_DOM && !SAFE_FOR_TEMPLATES && !WHOLE_DOCUMENT &&
|
|
19965
20712
|
// eslint-disable-next-line unicorn/prefer-includes
|
|
19966
20713
|
dirty.indexOf('<') === -1) {
|
|
19967
|
-
return trustedTypesPolicy && RETURN_TRUSTED_TYPE ?
|
|
20714
|
+
return trustedTypesPolicy && RETURN_TRUSTED_TYPE ? _createTrustedHTML(dirty) : dirty;
|
|
19968
20715
|
}
|
|
19969
20716
|
/* Initialize the document to work on */
|
|
19970
20717
|
body = _initDocument(dirty);
|
|
@@ -19978,29 +20725,59 @@
|
|
|
19978
20725
|
_forceRemove(body.firstChild);
|
|
19979
20726
|
}
|
|
19980
20727
|
/* Get node iterator */
|
|
19981
|
-
const nodeIterator = _createNodeIterator(
|
|
19982
|
-
/* Now start iterating over the created document
|
|
19983
|
-
|
|
19984
|
-
|
|
19985
|
-
|
|
19986
|
-
|
|
19987
|
-
|
|
19988
|
-
|
|
19989
|
-
|
|
19990
|
-
|
|
20728
|
+
const nodeIterator = _createNodeIterator(inPlace ? dirty : body);
|
|
20729
|
+
/* Now start iterating over the created document.
|
|
20730
|
+
The walk runs inside an exception barrier (campaign-3 F2): a re-entrant
|
|
20731
|
+
engine/custom-element mutation can detach a node mid-walk so
|
|
20732
|
+
`_forceRemove`'s parentless guard throws, aborting the loop. Without the
|
|
20733
|
+
barrier the caller's in-place tree would be left half-sanitized with the
|
|
20734
|
+
unvisited tail still armed. On any throw we fail closed — strip the
|
|
20735
|
+
in-place root bare — then rethrow so the existing throw contract is
|
|
20736
|
+
preserved. (String/DOM-copy paths never return the partial body, so the
|
|
20737
|
+
propagating throw is already fail-closed there.) */
|
|
20738
|
+
try {
|
|
20739
|
+
while (currentNode = nodeIterator.nextNode()) {
|
|
20740
|
+
/* Sanitize tags and elements */
|
|
20741
|
+
_sanitizeElements(currentNode);
|
|
20742
|
+
/* Check attributes next */
|
|
20743
|
+
_sanitizeAttributes(currentNode);
|
|
20744
|
+
/* Shadow DOM detected, sanitize it.
|
|
20745
|
+
Realm-safe check (GHSA-hpcv-96wg-7vj8): nodeType-based detection
|
|
20746
|
+
instead of instanceof, so foreign-realm <template>.content is
|
|
20747
|
+
walked correctly. */
|
|
20748
|
+
if (_isDocumentFragment(currentNode.content)) {
|
|
20749
|
+
_sanitizeShadowDOM2(currentNode.content);
|
|
20750
|
+
}
|
|
20751
|
+
}
|
|
20752
|
+
} catch (error) {
|
|
20753
|
+
if (inPlace) {
|
|
20754
|
+
_neutralizeRoot(dirty);
|
|
19991
20755
|
}
|
|
20756
|
+
throw error;
|
|
19992
20757
|
}
|
|
19993
20758
|
/* If we sanitized `dirty` in-place, return it. */
|
|
19994
|
-
if (
|
|
20759
|
+
if (inPlace) {
|
|
20760
|
+
/* Fail-closed completion of the audit-5 F1 fix: every node removed from
|
|
20761
|
+
the caller's live tree is detached but may still hold a queued
|
|
20762
|
+
resource-event handler that fires in page scope after we return. The
|
|
20763
|
+
move-hoist covers only disallowed-tag KEEP_CONTENT removals; strip the
|
|
20764
|
+
non-allow-listed attributes off every other removed subtree (clobber,
|
|
20765
|
+
mXSS, namespace, comments, KEEP_CONTENT:false, …) so those handlers are
|
|
20766
|
+
cancelled before any event can fire. Runs synchronously, pre-return. */
|
|
20767
|
+
arrayForEach(DOMPurify.removed, entry => {
|
|
20768
|
+
if (entry.element) {
|
|
20769
|
+
_neutralizeSubtree(entry.element);
|
|
20770
|
+
}
|
|
20771
|
+
});
|
|
19995
20772
|
if (SAFE_FOR_TEMPLATES) {
|
|
19996
|
-
|
|
20773
|
+
_scrubTemplateExpressions2(dirty);
|
|
19997
20774
|
}
|
|
19998
20775
|
return dirty;
|
|
19999
20776
|
}
|
|
20000
20777
|
/* Return sanitized string or DOM */
|
|
20001
20778
|
if (RETURN_DOM) {
|
|
20002
20779
|
if (SAFE_FOR_TEMPLATES) {
|
|
20003
|
-
|
|
20780
|
+
_scrubTemplateExpressions2(body);
|
|
20004
20781
|
}
|
|
20005
20782
|
if (RETURN_DOM_FRAGMENT) {
|
|
20006
20783
|
returnNode = createDocumentFragment.call(body.ownerDocument);
|
|
@@ -20030,20 +20807,28 @@
|
|
|
20030
20807
|
}
|
|
20031
20808
|
/* Sanitize final string template-safe */
|
|
20032
20809
|
if (SAFE_FOR_TEMPLATES) {
|
|
20033
|
-
|
|
20034
|
-
serializedHTML = stringReplace(serializedHTML, expr, ' ');
|
|
20035
|
-
});
|
|
20810
|
+
serializedHTML = _stripTemplateExpressions(serializedHTML);
|
|
20036
20811
|
}
|
|
20037
|
-
return trustedTypesPolicy && RETURN_TRUSTED_TYPE ?
|
|
20812
|
+
return trustedTypesPolicy && RETURN_TRUSTED_TYPE ? _createTrustedHTML(serializedHTML) : serializedHTML;
|
|
20038
20813
|
};
|
|
20039
20814
|
DOMPurify.setConfig = function () {
|
|
20040
20815
|
let cfg = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
20041
20816
|
_parseConfig(cfg);
|
|
20042
20817
|
SET_CONFIG = true;
|
|
20818
|
+
SET_CONFIG_ALLOWED_TAGS = ALLOWED_TAGS;
|
|
20819
|
+
SET_CONFIG_ALLOWED_ATTR = ALLOWED_ATTR;
|
|
20043
20820
|
};
|
|
20044
20821
|
DOMPurify.clearConfig = function () {
|
|
20045
20822
|
CONFIG = null;
|
|
20046
20823
|
SET_CONFIG = false;
|
|
20824
|
+
SET_CONFIG_ALLOWED_TAGS = null;
|
|
20825
|
+
SET_CONFIG_ALLOWED_ATTR = null;
|
|
20826
|
+
// Drop any caller-supplied Trusted Types policy so it cannot poison later
|
|
20827
|
+
// `RETURN_TRUSTED_TYPE` output. The internal default policy (cached, and
|
|
20828
|
+
// never recreated — Trusted Types throws on duplicate names) is restored by
|
|
20829
|
+
// the next `_parseConfig`. See GHSA-vxr8-fq34-vvx9.
|
|
20830
|
+
trustedTypesPolicy = defaultTrustedTypesPolicy;
|
|
20831
|
+
emptyHTML = '';
|
|
20047
20832
|
};
|
|
20048
20833
|
DOMPurify.isValidAttribute = function (tag, attr, value) {
|
|
20049
20834
|
/* Initialize shared config vars if necessary. */
|
|
@@ -20058,9 +20843,19 @@
|
|
|
20058
20843
|
if (typeof hookFunction !== 'function') {
|
|
20059
20844
|
return;
|
|
20060
20845
|
}
|
|
20846
|
+
/* Reject unknown entry points. Without this, a non-hook key (e.g.
|
|
20847
|
+
* '__proto__') indexes off the prototype chain rather than a real
|
|
20848
|
+
* hook array, and arrayPush then writes to Object.prototype. Guard
|
|
20849
|
+
* with an own-property check against the known hook names. */
|
|
20850
|
+
if (!objectHasOwnProperty(hooks, entryPoint)) {
|
|
20851
|
+
return;
|
|
20852
|
+
}
|
|
20061
20853
|
arrayPush(hooks[entryPoint], hookFunction);
|
|
20062
20854
|
};
|
|
20063
20855
|
DOMPurify.removeHook = function (entryPoint, hookFunction) {
|
|
20856
|
+
if (!objectHasOwnProperty(hooks, entryPoint)) {
|
|
20857
|
+
return undefined;
|
|
20858
|
+
}
|
|
20064
20859
|
if (hookFunction !== undefined) {
|
|
20065
20860
|
const index = arrayLastIndexOf(hooks[entryPoint], hookFunction);
|
|
20066
20861
|
return index === -1 ? undefined : arraySplice(hooks[entryPoint], index, 1)[0];
|
|
@@ -20068,6 +20863,9 @@
|
|
|
20068
20863
|
return arrayPop(hooks[entryPoint]);
|
|
20069
20864
|
};
|
|
20070
20865
|
DOMPurify.removeHooks = function (entryPoint) {
|
|
20866
|
+
if (!objectHasOwnProperty(hooks, entryPoint)) {
|
|
20867
|
+
return;
|
|
20868
|
+
}
|
|
20071
20869
|
hooks[entryPoint] = [];
|
|
20072
20870
|
};
|
|
20073
20871
|
DOMPurify.removeAllHooks = function () {
|
|
@@ -20551,22 +21349,44 @@
|
|
|
20551
21349
|
const bogus = get$a(element, 'data-mce-bogus');
|
|
20552
21350
|
if (!isInternalElement && isString(bogus)) {
|
|
20553
21351
|
if (bogus === 'all') {
|
|
21352
|
+
// Empty before removing so a detached raw-text element (e.g. script/style) can't carry
|
|
21353
|
+
// markup-like content into DOMPurify's unsafe-node check, which would then throw trying
|
|
21354
|
+
// to _forceRemove the now-parentless node.
|
|
21355
|
+
empty(element);
|
|
20554
21356
|
remove$8(element);
|
|
20555
21357
|
}
|
|
20556
21358
|
else {
|
|
20557
21359
|
unwrap(element);
|
|
20558
21360
|
}
|
|
21361
|
+
// We detach the element above; DOMPurify throws if it then tries to _forceRemove the
|
|
21362
|
+
// now-parentless node, so mark the tag allowed to stop that second removal.
|
|
21363
|
+
if (isNonNullable(evt)) {
|
|
21364
|
+
evt.allowedTags[lcTagName] = true;
|
|
21365
|
+
}
|
|
20559
21366
|
return;
|
|
20560
21367
|
}
|
|
20561
21368
|
// Determine if the schema allows the element and either add it or remove it
|
|
20562
21369
|
const rule = schema.getElementRule(lcTagName);
|
|
20563
21370
|
if (validate && !rule) {
|
|
20564
|
-
//
|
|
20565
|
-
|
|
20566
|
-
|
|
21371
|
+
// Don't detach invalid special / non-HTML-namespace elements: DOMPurify throws if it later
|
|
21372
|
+
// _forceRemoves a parentless node (its unsafe-content and namespace checks do this regardless
|
|
21373
|
+
// of allowedTags). Empty and leave attached instead, so DOMPurify removes it without hoisting content.
|
|
21374
|
+
if (settings.sanitize && (has$2(specialElements, lcTagName) || scope !== 'html')) {
|
|
21375
|
+
empty(element);
|
|
20567
21376
|
}
|
|
20568
21377
|
else {
|
|
20569
|
-
|
|
21378
|
+
// No DOMPurify to remove it (sanitize disabled), or a plain invalid HTML element: detach it ourselves.
|
|
21379
|
+
if (has$2(specialElements, lcTagName)) {
|
|
21380
|
+
remove$8(element);
|
|
21381
|
+
}
|
|
21382
|
+
else {
|
|
21383
|
+
unwrap(element);
|
|
21384
|
+
}
|
|
21385
|
+
// The element is now detached; mark the tag allowed so DOMPurify won't _forceRemove the
|
|
21386
|
+
// parentless node and throw. Safe here: it's empty and HTML-namespaced, so no earlier check fires.
|
|
21387
|
+
if (isNonNullable(evt)) {
|
|
21388
|
+
evt.allowedTags[lcTagName] = true;
|
|
21389
|
+
}
|
|
20570
21390
|
}
|
|
20571
21391
|
return;
|
|
20572
21392
|
}
|
|
@@ -20749,7 +21569,9 @@
|
|
|
20749
21569
|
evt.allowedTags[lcTagName] = keepElement;
|
|
20750
21570
|
if (!keepElement && settings.sanitize) {
|
|
20751
21571
|
if (isElement$7(node)) {
|
|
20752
|
-
node
|
|
21572
|
+
// Empty the node and leave it attached so DOMPurify removes it (allowedTags is false).
|
|
21573
|
+
// Detaching it would make DOMPurify throw when it _forceRemoves the parentless node.
|
|
21574
|
+
empty(SugarElement.fromDom(node));
|
|
20753
21575
|
}
|
|
20754
21576
|
}
|
|
20755
21577
|
});
|
|
@@ -22068,7 +22890,7 @@
|
|
|
22068
22890
|
append(SugarElement.fromDom(pre1), [
|
|
22069
22891
|
SugarElement.fromTag('br', doc),
|
|
22070
22892
|
SugarElement.fromTag('br', doc),
|
|
22071
|
-
...children$
|
|
22893
|
+
...children$2(sPre2)
|
|
22072
22894
|
]);
|
|
22073
22895
|
};
|
|
22074
22896
|
if (!rng.collapsed) {
|
|
@@ -22215,10 +23037,12 @@
|
|
|
22215
23037
|
const wrapName = format.inline || format.block;
|
|
22216
23038
|
const wrapElm = createWrapElement(wrapName);
|
|
22217
23039
|
const isMatchingWrappingBlock = (node) => isWrappingBlockFormat(format) && matchNode$1(ed, node, name, vars);
|
|
23040
|
+
const canRenameChildBlocks = (node) => forall(node.childNodes, (child) => !isTextBlock$2(ed.schema, child) || isValid(ed, wrapName, child.nodeName.toLowerCase()));
|
|
22218
23041
|
const canRenameBlock = (node, parentName, isEditableDescendant) => {
|
|
22219
23042
|
const isValidBlockFormatForNode = isNonWrappingBlockFormat(format) &&
|
|
22220
23043
|
isTextBlock$2(ed.schema, node) &&
|
|
22221
|
-
isValid(ed, parentName, wrapName)
|
|
23044
|
+
isValid(ed, parentName, wrapName) &&
|
|
23045
|
+
canRenameChildBlocks(node);
|
|
22222
23046
|
return isEditableDescendant && isValidBlockFormatForNode;
|
|
22223
23047
|
};
|
|
22224
23048
|
const canWrapNode = (node, parentName, isEditableDescendant, isWrappableNoneditableElm) => {
|
|
@@ -22375,6 +23199,19 @@
|
|
|
22375
23199
|
// node variable is used by other functions above in the same scope so need to set it here
|
|
22376
23200
|
node = targetNode;
|
|
22377
23201
|
applyNodeStyle(formatList, node);
|
|
23202
|
+
if (isBlockFormat(format) && !dom.isBlock(targetNode)) {
|
|
23203
|
+
const parentBlock = dom.getParent(targetNode, dom.isBlock);
|
|
23204
|
+
if (dom.isEditable(parentBlock)) {
|
|
23205
|
+
const wrapperElementName = format.block;
|
|
23206
|
+
if (parentBlock.nodeName.toLowerCase() === wrapperElementName.toLowerCase()) {
|
|
23207
|
+
setElementFormat(ed, parentBlock, format, vars, node);
|
|
23208
|
+
}
|
|
23209
|
+
else if (!isWrappingBlockFormat(format)) {
|
|
23210
|
+
const elm = dom.rename(parentBlock, wrapperElementName);
|
|
23211
|
+
setElementFormat(ed, elm, format, vars, node);
|
|
23212
|
+
}
|
|
23213
|
+
}
|
|
23214
|
+
}
|
|
22378
23215
|
fireFormatApply(ed, name, node, vars);
|
|
22379
23216
|
return;
|
|
22380
23217
|
}
|
|
@@ -25454,7 +26291,8 @@
|
|
|
25454
26291
|
}, (href) => {
|
|
25455
26292
|
e.preventDefault();
|
|
25456
26293
|
if (/^#/.test(href)) {
|
|
25457
|
-
const
|
|
26294
|
+
const id = removeLeading(href, '#');
|
|
26295
|
+
const targetEl = editor.dom.select(`[id="${id}"],[name="${id}"]`);
|
|
25458
26296
|
if (targetEl.length) {
|
|
25459
26297
|
editor.selection.scrollIntoView(targetEl[0], true);
|
|
25460
26298
|
}
|
|
@@ -26164,7 +27002,7 @@
|
|
|
26164
27002
|
preview: 'font-family font-size'
|
|
26165
27003
|
},
|
|
26166
27004
|
{
|
|
26167
|
-
selector: '.mce-preview-object,[data-ephox-embed-iri]',
|
|
27005
|
+
selector: '.mce-preview-object,[data-ephox-embed-iri],.tiny-pageembed',
|
|
26168
27006
|
ceFalseOverride: true,
|
|
26169
27007
|
styles: {
|
|
26170
27008
|
float: 'left'
|
|
@@ -26216,7 +27054,7 @@
|
|
|
26216
27054
|
preview: 'font-family font-size'
|
|
26217
27055
|
},
|
|
26218
27056
|
{
|
|
26219
|
-
selector: '.mce-preview-object',
|
|
27057
|
+
selector: '.mce-preview-object,.tiny-pageembed',
|
|
26220
27058
|
ceFalseOverride: true,
|
|
26221
27059
|
styles: {
|
|
26222
27060
|
display: 'table', // Needs to be `table` to properly render while editing
|
|
@@ -26280,7 +27118,7 @@
|
|
|
26280
27118
|
preview: 'font-family font-size'
|
|
26281
27119
|
},
|
|
26282
27120
|
{
|
|
26283
|
-
selector: '.mce-preview-object,[data-ephox-embed-iri]',
|
|
27121
|
+
selector: '.mce-preview-object,[data-ephox-embed-iri],.tiny-pageembed',
|
|
26284
27122
|
ceFalseOverride: true,
|
|
26285
27123
|
styles: {
|
|
26286
27124
|
float: 'right'
|
|
@@ -26967,8 +27805,8 @@
|
|
|
26967
27805
|
isFirstTypedCharacter.set(true);
|
|
26968
27806
|
return;
|
|
26969
27807
|
}
|
|
26970
|
-
const
|
|
26971
|
-
if (
|
|
27808
|
+
const hasMetaOrCtrlModifier = Env.os.isMacOS() ? e.metaKey : e.ctrlKey && !e.altKey;
|
|
27809
|
+
if (hasMetaOrCtrlModifier && (e.key === 'Backspace' || e.key === 'Delete')) {
|
|
26972
27810
|
undoManager.beforeChange();
|
|
26973
27811
|
}
|
|
26974
27812
|
});
|
|
@@ -27533,7 +28371,7 @@
|
|
|
27533
28371
|
const isIndented = (entry) => entry.depth > 0;
|
|
27534
28372
|
const isSelected = (entry) => entry.isSelected;
|
|
27535
28373
|
const cloneItemContent = (li) => {
|
|
27536
|
-
const children = children$
|
|
28374
|
+
const children = children$2(li);
|
|
27537
28375
|
const content = hasLastChildList(li) ? children.slice(0, -1) : children;
|
|
27538
28376
|
return map$3(content, deep);
|
|
27539
28377
|
};
|
|
@@ -27731,7 +28569,7 @@
|
|
|
27731
28569
|
return currentItemEntry.toArray().concat(childListEntries);
|
|
27732
28570
|
};
|
|
27733
28571
|
const parseItem = (depth, itemSelection, selectionState, item) => firstChild(item).filter(isList).fold(() => parseSingleItem(depth, itemSelection, selectionState, item), (list) => {
|
|
27734
|
-
const parsedSiblings = foldl(children$
|
|
28572
|
+
const parsedSiblings = foldl(children$2(item), (acc, liChild, i) => {
|
|
27735
28573
|
if (i === 0) {
|
|
27736
28574
|
return acc;
|
|
27737
28575
|
}
|
|
@@ -27754,7 +28592,7 @@
|
|
|
27754
28592
|
}, []);
|
|
27755
28593
|
return parseList(depth, itemSelection, selectionState, list).concat(parsedSiblings);
|
|
27756
28594
|
});
|
|
27757
|
-
const parseList = (depth, itemSelection, selectionState, list) => bind$3(children$
|
|
28595
|
+
const parseList = (depth, itemSelection, selectionState, list) => bind$3(children$2(list), (element) => {
|
|
27758
28596
|
const parser = isList(element) ? parseList : parseItem;
|
|
27759
28597
|
const newDepth = depth + 1;
|
|
27760
28598
|
return parser(newDepth, itemSelection, selectionState, element);
|
|
@@ -28417,7 +29255,7 @@
|
|
|
28417
29255
|
const rng = normalizeRange(editor.selection.getRng());
|
|
28418
29256
|
const nextCaretContainer = findNextCaretContainer(editor, rng, isForward, root);
|
|
28419
29257
|
const otherLi = dom.getParent(nextCaretContainer, 'LI', root);
|
|
28420
|
-
if (nextCaretContainer && otherLi) {
|
|
29258
|
+
if (nextCaretContainer && otherLi && (isForward || !dom.isChildOf(nextCaretContainer, block))) {
|
|
28421
29259
|
const findValidElement = (element) => contains$2(['td', 'th', 'caption'], name(element));
|
|
28422
29260
|
const findRoot = (node) => node.dom === root;
|
|
28423
29261
|
const otherLiCell = closest$5(SugarElement.fromDom(otherLi), findValidElement, findRoot);
|
|
@@ -28515,7 +29353,7 @@
|
|
|
28515
29353
|
const read$1 = (schema, rootNode, forward, rng) => rng.collapsed ? readFromRange(schema, rootNode, forward, rng) : Optional.none();
|
|
28516
29354
|
|
|
28517
29355
|
const getChildrenUntilBlockBoundary = (block, schema) => {
|
|
28518
|
-
const children = children$
|
|
29356
|
+
const children = children$2(block);
|
|
28519
29357
|
return findIndex$2(children, (el) => schema.isBlock(name(el))).fold(constant(children), (index) => children.slice(0, index));
|
|
28520
29358
|
};
|
|
28521
29359
|
const extractChildren = (block, schema) => {
|
|
@@ -29910,7 +30748,11 @@
|
|
|
29910
30748
|
const canIndent = (editor) => !editor.mode.isReadOnly() && canIndent$1(editor);
|
|
29911
30749
|
const isListComponent = (el) => isList$1(el) || isListItem$2(el);
|
|
29912
30750
|
const parentIsListComponent = (el) => parent(el).exists(isListComponent);
|
|
29913
|
-
const getBlocksToIndent = (editor) =>
|
|
30751
|
+
const getBlocksToIndent = (editor) => {
|
|
30752
|
+
const selectedCells = getCellsFromEditor(editor);
|
|
30753
|
+
return selectedCells.length === 0 ?
|
|
30754
|
+
filter$5(fromDom$1(editor.selection.getSelectedBlocks()), (el) => !isListComponent(el) && !parentIsListComponent(el) && isEditable(el)) : selectedCells;
|
|
30755
|
+
};
|
|
29914
30756
|
const handle = (editor, command) => {
|
|
29915
30757
|
if (editor.mode.isReadOnly()) {
|
|
29916
30758
|
return;
|
|
@@ -30585,7 +31427,7 @@
|
|
|
30585
31427
|
return filterFirstLayer(scope, selector, always);
|
|
30586
31428
|
};
|
|
30587
31429
|
const filterFirstLayer = (scope, selector, predicate) => {
|
|
30588
|
-
return bind$3(children$
|
|
31430
|
+
return bind$3(children$2(scope), (x) => {
|
|
30589
31431
|
if (is$2(x, selector)) {
|
|
30590
31432
|
return predicate(x) ? [x] : [];
|
|
30591
31433
|
}
|
|
@@ -30795,7 +31637,7 @@
|
|
|
30795
31637
|
nextSibling: nextSibling
|
|
30796
31638
|
}),
|
|
30797
31639
|
property: constant({
|
|
30798
|
-
children: children$
|
|
31640
|
+
children: children$2,
|
|
30799
31641
|
name: name,
|
|
30800
31642
|
parent: parent,
|
|
30801
31643
|
document,
|
|
@@ -30885,10 +31727,14 @@
|
|
|
30885
31727
|
};
|
|
30886
31728
|
const isInDragStartEvent = checkEvent(0 /* Event.Dragstart */);
|
|
30887
31729
|
|
|
30888
|
-
const createEmptyFileList = () =>
|
|
30889
|
-
|
|
30890
|
-
|
|
30891
|
-
|
|
31730
|
+
const createEmptyFileList = () => {
|
|
31731
|
+
const empty = [];
|
|
31732
|
+
return Object.freeze({
|
|
31733
|
+
length: 0,
|
|
31734
|
+
item: (_) => null,
|
|
31735
|
+
[Symbol.iterator]: () => empty[Symbol.iterator]()
|
|
31736
|
+
});
|
|
31737
|
+
};
|
|
30892
31738
|
|
|
30893
31739
|
const modeId = generate('mode');
|
|
30894
31740
|
const getMode = (transfer) => {
|
|
@@ -33902,15 +34748,20 @@
|
|
|
33902
34748
|
blobCache.add(blobInfo);
|
|
33903
34749
|
return blobInfo;
|
|
33904
34750
|
};
|
|
33905
|
-
const pasteImage = (editor, imageItem) => {
|
|
33906
|
-
parseDataUri(imageItem.uri).
|
|
34751
|
+
const pasteImage = async (editor, imageItem) => {
|
|
34752
|
+
return parseDataUri(imageItem.uri).fold(() => Promise.resolve(), ({ data, type, base64Encoded }) => {
|
|
33907
34753
|
const base64 = base64Encoded ? data : btoa(data);
|
|
33908
34754
|
const file = imageItem.file;
|
|
33909
34755
|
// TODO: Move the bulk of the cache logic to EditorUpload
|
|
33910
34756
|
const blobCache = editor.editorUpload.blobCache;
|
|
33911
34757
|
const existingBlobInfo = blobCache.getByData(base64, type);
|
|
33912
34758
|
const blobInfo = existingBlobInfo ?? createBlobInfo(editor, blobCache, file, base64);
|
|
33913
|
-
|
|
34759
|
+
const imgUrl = blobInfo.blobUri();
|
|
34760
|
+
return getImageSize(imgUrl).then(({ width, height }) => {
|
|
34761
|
+
pasteHtml(editor, `<img width="${width}" height="${height}" src="${imgUrl}">`, false, true);
|
|
34762
|
+
}).catch(() => {
|
|
34763
|
+
pasteHtml(editor, `<img src="${imgUrl}">`, false, true);
|
|
34764
|
+
});
|
|
33914
34765
|
});
|
|
33915
34766
|
};
|
|
33916
34767
|
const isClipboardEvent = (event) => event.type === 'paste';
|
|
@@ -33941,13 +34792,13 @@
|
|
|
33941
34792
|
if (images.length > 0) {
|
|
33942
34793
|
e.preventDefault();
|
|
33943
34794
|
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
33944
|
-
readFilesAsDataUris(images).then((fileResults) => {
|
|
34795
|
+
readFilesAsDataUris(images).then(async (fileResults) => {
|
|
33945
34796
|
if (rng) {
|
|
33946
34797
|
editor.selection.setRng(rng);
|
|
33947
34798
|
}
|
|
33948
|
-
|
|
33949
|
-
pasteImage(editor, result);
|
|
33950
|
-
}
|
|
34799
|
+
for (const result of fileResults) {
|
|
34800
|
+
await pasteImage(editor, result);
|
|
34801
|
+
}
|
|
33951
34802
|
});
|
|
33952
34803
|
return true;
|
|
33953
34804
|
}
|
|
@@ -36095,6 +36946,7 @@
|
|
|
36095
36946
|
const browser = Env.browser;
|
|
36096
36947
|
const isGecko = browser.isFirefox();
|
|
36097
36948
|
const isWebKit = browser.isChromium() || browser.isSafari();
|
|
36949
|
+
const isSafari = browser.isSafari();
|
|
36098
36950
|
const isiOS = Env.deviceType.isiPhone() || Env.deviceType.isiPad();
|
|
36099
36951
|
const isMac = Env.os.isMacOS() || Env.os.isiOS();
|
|
36100
36952
|
/**
|
|
@@ -36701,6 +37553,51 @@
|
|
|
36701
37553
|
}
|
|
36702
37554
|
});
|
|
36703
37555
|
};
|
|
37556
|
+
/**
|
|
37557
|
+
* this is needed to manage the difference between
|
|
37558
|
+
* ```
|
|
37559
|
+
* <li><span class="fake">a</span><div>b</div></li>
|
|
37560
|
+
* ```
|
|
37561
|
+
* and
|
|
37562
|
+
* ```
|
|
37563
|
+
* <li><span class="fake">a</span> <div>b</div></li>
|
|
37564
|
+
* ```
|
|
37565
|
+
* since if the indentation of the HTML has a new line it creates a fake child in the `li` that is an empty text
|
|
37566
|
+
* it's check it trying to get the rects and if it can't it means that it's the false unwanted new line
|
|
37567
|
+
**/
|
|
37568
|
+
const isValidSibling = (el) => getClientRects([el.dom]).length > 0;
|
|
37569
|
+
const firstBlockChildOrNewLine = (target) => child(target, (child) => isBr$6(child) || isElement$8(child) && get$8(child, 'display') === 'block');
|
|
37570
|
+
const clickAfterEl = (clientX, clientY, el) => get$c(getClientRects([el.dom]), 0).exists((rect) => clientX >= rect.right && clientY >= rect.top && clientY <= rect.bottom);
|
|
37571
|
+
const selectPos = (editor, e, pos) => {
|
|
37572
|
+
e.preventDefault();
|
|
37573
|
+
editor.focus();
|
|
37574
|
+
editor.selection.setRng(pos.toRange());
|
|
37575
|
+
};
|
|
37576
|
+
/**
|
|
37577
|
+
* In Chrome in a `LI` that contains a block element and where the first child is an inline element
|
|
37578
|
+
* clicking on the right side of the first child the carret goes at the start of the element instead that in the end of it
|
|
37579
|
+
* issue: https://issues.chromium.org/issues/40767343
|
|
37580
|
+
**/
|
|
37581
|
+
const fixInLISelection = () => {
|
|
37582
|
+
editor.on('mousedown', (e) => {
|
|
37583
|
+
const target = SugarElement.fromDom(e.target);
|
|
37584
|
+
if (isListItem$2(target)) {
|
|
37585
|
+
firstBlockChildOrNewLine(target).fold(() => {
|
|
37586
|
+
lastChild(target).each((lastChild) => {
|
|
37587
|
+
if (clickAfterEl(e.clientX, e.clientY, lastChild)) {
|
|
37588
|
+
lastPositionIn(target.dom).each((pos) => selectPos(editor, e, pos));
|
|
37589
|
+
}
|
|
37590
|
+
});
|
|
37591
|
+
}, (firstBlock) => {
|
|
37592
|
+
findLast(prevSiblings(firstBlock), isValidSibling).each((lastInlineBeforeBlock) => {
|
|
37593
|
+
if (clickAfterEl(e.clientX, e.clientY, lastInlineBeforeBlock)) {
|
|
37594
|
+
prevPosition(target.dom, CaretPosition(firstBlock.dom, 0)).each((pos) => selectPos(editor, e, pos));
|
|
37595
|
+
}
|
|
37596
|
+
});
|
|
37597
|
+
});
|
|
37598
|
+
}
|
|
37599
|
+
});
|
|
37600
|
+
};
|
|
36704
37601
|
// No-op since Mozilla seems to have fixed the caret repaint issues
|
|
36705
37602
|
const refreshContentEditable = noop;
|
|
36706
37603
|
const isHidden = () => {
|
|
@@ -36747,6 +37644,9 @@
|
|
|
36747
37644
|
blockFormSubmitInsideEditor();
|
|
36748
37645
|
disableBackspaceIntoATable();
|
|
36749
37646
|
removeAppleInterchangeBrs();
|
|
37647
|
+
if (!isSafari) {
|
|
37648
|
+
fixInLISelection();
|
|
37649
|
+
}
|
|
36750
37650
|
// touchClickEvent();
|
|
36751
37651
|
// iOS
|
|
36752
37652
|
if (isiOS) {
|
|
@@ -40843,6 +41743,21 @@
|
|
|
40843
41743
|
hasEditableRoot() {
|
|
40844
41744
|
return hasEditableRoot(this);
|
|
40845
41745
|
}
|
|
41746
|
+
/**
|
|
41747
|
+
* Announces a message to screen readers via the page-wide aria-live region, without shifting focus.
|
|
41748
|
+
* Delegates to {@link tinymce.dom.AriaAnnouncer#announce}.
|
|
41749
|
+
*
|
|
41750
|
+
* @method announce
|
|
41751
|
+
* @param {String} message The message to announce to screen readers.
|
|
41752
|
+
* @param {Object} options Optional settings.
|
|
41753
|
+
* @param {Boolean} options.assertive If true, uses aria-live="assertive" (role="alert") instead of polite.
|
|
41754
|
+
* @example
|
|
41755
|
+
* tinymce.activeEditor.announce('Bold on');
|
|
41756
|
+
* tinymce.activeEditor.announce('Error occurred', { assertive: true });
|
|
41757
|
+
*/
|
|
41758
|
+
announce(message, options) {
|
|
41759
|
+
AriaAnnouncer.announce(message, options);
|
|
41760
|
+
}
|
|
40846
41761
|
/**
|
|
40847
41762
|
* Removes the editor from the dom and tinymce collection.
|
|
40848
41763
|
*
|
|
@@ -40967,14 +41882,14 @@
|
|
|
40967
41882
|
* @property minorVersion
|
|
40968
41883
|
* @type String
|
|
40969
41884
|
*/
|
|
40970
|
-
minorVersion: '
|
|
41885
|
+
minorVersion: '8.0',
|
|
40971
41886
|
/**
|
|
40972
41887
|
* Release date of TinyMCE build.
|
|
40973
41888
|
*
|
|
40974
41889
|
* @property releaseDate
|
|
40975
41890
|
* @type String
|
|
40976
41891
|
*/
|
|
40977
|
-
releaseDate: '2026-
|
|
41892
|
+
releaseDate: '2026-07-15',
|
|
40978
41893
|
/**
|
|
40979
41894
|
* Collection of language pack data.
|
|
40980
41895
|
*
|
|
@@ -41832,6 +42747,7 @@
|
|
|
41832
42747
|
ControlSelection,
|
|
41833
42748
|
BookmarkManager,
|
|
41834
42749
|
Selection: EditorSelection,
|
|
42750
|
+
AriaAnnouncer,
|
|
41835
42751
|
Event: EventUtils.Event
|
|
41836
42752
|
},
|
|
41837
42753
|
html: {
|
|
@@ -41890,7 +42806,7 @@
|
|
|
41890
42806
|
}
|
|
41891
42807
|
catch {
|
|
41892
42808
|
// It will thrown an error when running this module
|
|
41893
|
-
// within
|
|
42809
|
+
// within rspack where the module.exports object is sealed
|
|
41894
42810
|
}
|
|
41895
42811
|
}
|
|
41896
42812
|
};
|