@lwrjs/client-modules 0.20.5 → 0.20.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/bundle/prod/lwr/lockerDefine/lockerDefine.js +1 -1
- package/build/es/modules/lwr/init/init.js +1 -6
- package/build/modules/lwr/init/init.js +1 -7
- package/build/modules/lwr/lockerDefine/lockerDefine.js +361 -427
- package/build/modules/lwr/lockerSandbox/lockerSandbox.js +361 -427
- package/package.json +6 -8
|
@@ -206,16 +206,12 @@ const LOCKER_IDENTIFIER_MARKER$LWS = '$LWS';
|
|
|
206
206
|
// phase two, the user opted-in to custom devtools formatters. Phase one
|
|
207
207
|
// is used for light weight initialization time debug while phase two is
|
|
208
208
|
// reserved for post initialization runtime
|
|
209
|
-
const LOCKER_UNMINIFIED_FLAG$LWS$1 =
|
|
210
|
-
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
211
|
-
/* istanbul ignore next */
|
|
212
|
-
`${function LOCKER_UNMINIFIED_FLAG$LWS() {
|
|
209
|
+
const LOCKER_UNMINIFIED_FLAG$LWS$1 = /* istanbul ignore next */`${function LOCKER_UNMINIFIED_FLAG$LWS() {
|
|
213
210
|
return LOCKER_UNMINIFIED_FLAG$LWS.name;
|
|
214
211
|
}()}`.includes('LOCKER_UNMINIFIED_FLAG');
|
|
215
212
|
// Locker key constants.
|
|
216
213
|
const LOCKER_SERVICE_KEY$LWS = 'LSKey';
|
|
217
214
|
const LOCKER_SERVICE_KEY_LOWERED$LWS = 'lskey';
|
|
218
|
-
// Character constants.
|
|
219
215
|
const CHAR_QUOTE_DOUBLE$LWS = '"';
|
|
220
216
|
const CHAR_QUOTE_SINGLE$LWS = "'";
|
|
221
217
|
// Compiler constants.
|
|
@@ -713,13 +709,13 @@ const {
|
|
|
713
709
|
delete: SetProtoDelete$LWS,
|
|
714
710
|
entries: SetProtoEntries$LWS,
|
|
715
711
|
forEach: SetProtoForEach$LWS,
|
|
716
|
-
has: SetProtoHas$LWS$1,
|
|
717
712
|
keys: SetProtoKeys$LWS,
|
|
718
713
|
[SymbolIterator$LWS$1]: SetProtoSymbolIterator$LWS,
|
|
719
714
|
[SymbolToStringTag$LWS$1]: SetProtoSymbolToStringTag$LWS
|
|
720
715
|
} = SetProto$LWS$1;
|
|
721
716
|
const {
|
|
722
717
|
add: SetProtoAdd$LWS$1,
|
|
718
|
+
has: SetProtoHas$LWS$1,
|
|
723
719
|
values: SetProtoValues$LWS$1
|
|
724
720
|
} = SetProto$LWS$1;
|
|
725
721
|
const SetProtoSizeGetter$LWS = ObjectLookupOwnGetter$LWS$1(SetProto$LWS$1, 'size');
|
|
@@ -894,7 +890,7 @@ function getBrandByTrialAndError$LWS(value$LWS) {
|
|
|
894
890
|
return TO_STRING_BRAND_SYMBOL$LWS$1;
|
|
895
891
|
}
|
|
896
892
|
// eslint-disable-next-line no-empty
|
|
897
|
-
} catch (
|
|
893
|
+
} catch (_unused0$LWS) {}
|
|
898
894
|
// Perform heavier checks last.
|
|
899
895
|
// Section 22.2.6.13 get RegExp.prototype.source
|
|
900
896
|
// https://tc39.es/ecma262/#sec-get-regexp.prototype.source
|
|
@@ -907,7 +903,7 @@ function getBrandByTrialAndError$LWS(value$LWS) {
|
|
|
907
903
|
return TO_STRING_BRAND_REG_EXP$LWS;
|
|
908
904
|
}
|
|
909
905
|
// eslint-disable-next-line no-empty
|
|
910
|
-
} catch (
|
|
906
|
+
} catch (_unused1$LWS) {}
|
|
911
907
|
// Section 22.1.3 Properties of the String Prototype Object
|
|
912
908
|
// https://tc39.es/ecma262/#thisstringvalue
|
|
913
909
|
// Step 2: If Type(value) is Object and value has a [[StringData]] internal slot, then
|
|
@@ -919,7 +915,7 @@ function getBrandByTrialAndError$LWS(value$LWS) {
|
|
|
919
915
|
return TO_STRING_BRAND_STRING$LWS$1;
|
|
920
916
|
}
|
|
921
917
|
// eslint-disable-next-line no-empty
|
|
922
|
-
} catch (
|
|
918
|
+
} catch (_unused10$LWS) {}
|
|
923
919
|
// Section 20.3.3 Properties of the Boolean Prototype Object
|
|
924
920
|
// https://tc39.es/ecma262/#thisbooleanvalue
|
|
925
921
|
// Step 2: If Type(value) is Object and value has a [[BooleanData]] internal slot, then
|
|
@@ -929,7 +925,7 @@ function getBrandByTrialAndError$LWS(value$LWS) {
|
|
|
929
925
|
ReflectApply$LWS$1(BooleanProtoValueOf$LWS, value$LWS, []);
|
|
930
926
|
return TO_STRING_BRAND_BOOLEAN$LWS$1;
|
|
931
927
|
// eslint-disable-next-line no-empty
|
|
932
|
-
} catch (
|
|
928
|
+
} catch (_unused11$LWS) {}
|
|
933
929
|
// istanbul ignore else: All platforms that LWS runs tests in support BigInt
|
|
934
930
|
if (SUPPORTS_BIG_INT$LWS) {
|
|
935
931
|
try {
|
|
@@ -940,7 +936,7 @@ function getBrandByTrialAndError$LWS(value$LWS) {
|
|
|
940
936
|
ReflectApply$LWS$1(BigIntProtoValueOf$LWS, value$LWS, []);
|
|
941
937
|
return TO_STRING_BRAND_BIG_INT$LWS$1;
|
|
942
938
|
// eslint-disable-next-line no-empty
|
|
943
|
-
} catch (
|
|
939
|
+
} catch (_unused12$LWS) {}
|
|
944
940
|
}
|
|
945
941
|
// Cannot detect brands for Arguments and Error objects.
|
|
946
942
|
return TO_STRING_BRAND_OBJECT$LWS;
|
|
@@ -980,7 +976,6 @@ typeof performance === 'undefined' ? /* istanbul ignore next: unreachable in tes
|
|
|
980
976
|
// https://github.com/acornjs/acorn/blob/master/acorn/src/parseutil.js
|
|
981
977
|
function indexOfPragma$LWS(source$LWS, pragma$LWS) {
|
|
982
978
|
let pos$LWS = 0;
|
|
983
|
-
// eslint-disable-next-line no-constant-condition
|
|
984
979
|
while (true) {
|
|
985
980
|
skipWhiteSpacesRegExp$LWS.lastIndex = pos$LWS;
|
|
986
981
|
pos$LWS += ReflectApply$LWS$1(RegExpProtoExec$LWS, skipWhiteSpacesRegExp$LWS, [source$LWS])[0].length;
|
|
@@ -1050,7 +1045,6 @@ function cloneMap$LWS(map$LWS, queue$LWS) {
|
|
|
1050
1045
|
let {
|
|
1051
1046
|
length: queueOffset$LWS
|
|
1052
1047
|
} = queue$LWS;
|
|
1053
|
-
// eslint-disable-next-line no-constant-condition
|
|
1054
1048
|
while (true) {
|
|
1055
1049
|
const {
|
|
1056
1050
|
done: done$LWS,
|
|
@@ -1094,7 +1088,6 @@ function cloneSet$LWS(set$LWS, queue$LWS) {
|
|
|
1094
1088
|
let {
|
|
1095
1089
|
length: queueOffset$LWS
|
|
1096
1090
|
} = queue$LWS;
|
|
1097
|
-
// eslint-disable-next-line no-constant-condition
|
|
1098
1091
|
while (true) {
|
|
1099
1092
|
const {
|
|
1100
1093
|
done: done$LWS,
|
|
@@ -1206,7 +1199,7 @@ function partialStructuredCloneInternal$LWS(value$LWS) {
|
|
|
1206
1199
|
// Step 4: If Type(value) is Undefined, Null, Boolean, Number, BigInt, or String
|
|
1207
1200
|
if (originalValue$LWS === null || originalValue$LWS === undefined || typeof originalValue$LWS === 'boolean' || typeof originalValue$LWS === 'number' || typeof originalValue$LWS === 'string' || typeof originalValue$LWS === 'bigint') {
|
|
1208
1201
|
setter$LWS(originalValue$LWS);
|
|
1209
|
-
// eslint-disable-next-line no-
|
|
1202
|
+
// eslint-disable-next-line no-extra-label, no-labels
|
|
1210
1203
|
continue queueLoop;
|
|
1211
1204
|
}
|
|
1212
1205
|
// Step 5: If Type(value) is Symbol, then throw a 'DataCloneError' DOMException.
|
|
@@ -1223,7 +1216,7 @@ function partialStructuredCloneInternal$LWS(value$LWS) {
|
|
|
1223
1216
|
let cloneValue$LWS = SEEN_OBJECTS$LWS.get(originalValue$LWS);
|
|
1224
1217
|
if (cloneValue$LWS) {
|
|
1225
1218
|
setter$LWS(cloneValue$LWS);
|
|
1226
|
-
// eslint-disable-next-line no-
|
|
1219
|
+
// eslint-disable-next-line no-extra-label, no-labels
|
|
1227
1220
|
continue queueLoop;
|
|
1228
1221
|
}
|
|
1229
1222
|
// Perform a brand check on originalValue.
|
|
@@ -1321,7 +1314,7 @@ function partialStructuredClone$LWS(value$LWS) {
|
|
|
1321
1314
|
try {
|
|
1322
1315
|
result$LWS = partialStructuredCloneInternal$LWS(value$LWS);
|
|
1323
1316
|
// eslint-disable-next-line no-empty
|
|
1324
|
-
} catch (
|
|
1317
|
+
} catch (_unused13$LWS) {}
|
|
1325
1318
|
SEEN_OBJECTS$LWS.clear();
|
|
1326
1319
|
}
|
|
1327
1320
|
return result$LWS;
|
|
@@ -1394,7 +1387,7 @@ function isTargetLive$LWS(target$LWS, targetTraits$LWS = 0 /* TargetTraits.None
|
|
|
1394
1387
|
try {
|
|
1395
1388
|
return trackedLiveTargets$LWS.has(target$LWS) || ObjectHasOwn$LWS$1(target$LWS, SYMBOL_LIVE_OBJECT$LWS);
|
|
1396
1389
|
// eslint-disable-next-line no-empty
|
|
1397
|
-
} catch (
|
|
1390
|
+
} catch (_unused14$LWS) {}
|
|
1398
1391
|
return false;
|
|
1399
1392
|
}
|
|
1400
1393
|
if (typeof target$LWS === 'object') {
|
|
@@ -1403,7 +1396,7 @@ function isTargetLive$LWS(target$LWS, targetTraits$LWS = 0 /* TargetTraits.None
|
|
|
1403
1396
|
return true;
|
|
1404
1397
|
}
|
|
1405
1398
|
// eslint-disable-next-line no-empty
|
|
1406
|
-
} catch (
|
|
1399
|
+
} catch (_unused15$LWS) {}
|
|
1407
1400
|
let constructor$LWS;
|
|
1408
1401
|
try {
|
|
1409
1402
|
({
|
|
@@ -1415,7 +1408,7 @@ function isTargetLive$LWS(target$LWS, targetTraits$LWS = 0 /* TargetTraits.None
|
|
|
1415
1408
|
return true;
|
|
1416
1409
|
}
|
|
1417
1410
|
// eslint-disable-next-line no-empty
|
|
1418
|
-
} catch (
|
|
1411
|
+
} catch (_unused16$LWS) {}
|
|
1419
1412
|
try {
|
|
1420
1413
|
if (ReflectGetPrototypeOf$LWS$1(target$LWS) === null && (
|
|
1421
1414
|
// Ensure `target` is not an `Object.prototype` from an iframe.
|
|
@@ -1423,14 +1416,14 @@ function isTargetLive$LWS(target$LWS, targetTraits$LWS = 0 /* TargetTraits.None
|
|
|
1423
1416
|
return true;
|
|
1424
1417
|
}
|
|
1425
1418
|
// eslint-disable-next-line no-empty
|
|
1426
|
-
} catch (
|
|
1419
|
+
} catch (_unused17$LWS) {}
|
|
1427
1420
|
// istanbul ignore else: it is unnecessary to cover the else path here
|
|
1428
1421
|
if (targetTraits$LWS === 0 /* TargetTraits.None */) {
|
|
1429
1422
|
try {
|
|
1430
1423
|
if (ArrayIsArray$LWS$1(target$LWS)) {
|
|
1431
1424
|
return true;
|
|
1432
1425
|
}
|
|
1433
|
-
} catch (
|
|
1426
|
+
} catch (_unused18$LWS) {
|
|
1434
1427
|
// The target is a revoked proxy.
|
|
1435
1428
|
return false;
|
|
1436
1429
|
}
|
|
@@ -1449,7 +1442,7 @@ function isTargetLive$LWS(target$LWS, targetTraits$LWS = 0 /* TargetTraits.None
|
|
|
1449
1442
|
return true;
|
|
1450
1443
|
}
|
|
1451
1444
|
// eslint-disable-next-line no-empty
|
|
1452
|
-
} catch (
|
|
1445
|
+
} catch (_unused19$LWS) {}
|
|
1453
1446
|
// Section 25.1.5.1 get ArrayBuffer.prototype.byteLength
|
|
1454
1447
|
// https://tc39.es/ecma262/#sec-get-arraybuffer.prototype.bytelength
|
|
1455
1448
|
// Step 2: Perform RequireInternalSlot(O, [[ArrayBufferData]]).
|
|
@@ -1459,7 +1452,7 @@ function isTargetLive$LWS(target$LWS, targetTraits$LWS = 0 /* TargetTraits.None
|
|
|
1459
1452
|
return true;
|
|
1460
1453
|
}
|
|
1461
1454
|
// eslint-disable-next-line no-empty
|
|
1462
|
-
} catch (
|
|
1455
|
+
} catch (_unused20$LWS) {}
|
|
1463
1456
|
}
|
|
1464
1457
|
return false;
|
|
1465
1458
|
}
|
|
@@ -1515,7 +1508,7 @@ const {
|
|
|
1515
1508
|
const PromiseResolve$LWS = PromiseCtor$LWS.resolve.bind(PromiseCtor$LWS);
|
|
1516
1509
|
const PromiseReject$LWS = PromiseCtor$LWS.reject.bind(PromiseCtor$LWS);
|
|
1517
1510
|
const trustedResources$LWS = toSafeSet$LWS(new SetCtor$LWS$1());
|
|
1518
|
-
/*! version: 0.
|
|
1511
|
+
/*! version: 0.26.2 */
|
|
1519
1512
|
|
|
1520
1513
|
/*!
|
|
1521
1514
|
* Copyright (C) 2019 salesforce.com, inc.
|
|
@@ -1691,7 +1684,6 @@ const WindowQueueMicrotask$LWS = (() => {
|
|
|
1691
1684
|
// https://caniuse.com/mdn-api_queuemicrotask
|
|
1692
1685
|
// https://developer.mozilla.org/en-US/docs/Web/API/queueMicrotask#when_queuemicrotask_isnt_available
|
|
1693
1686
|
// istanbul ignore next: coverage is not measured in Edge 15, which means this whole fallback is considered "uncovered" when the tests are run in Chrome.
|
|
1694
|
-
// eslint-disable-next-line @typescript-eslint/no-shadow, no-shadow
|
|
1695
1687
|
return function queueMicrotask$LWS(callback$LWS) {
|
|
1696
1688
|
let promise$LWS = PromiseResolve$LWS();
|
|
1697
1689
|
promise$LWS = ReflectApply$LWS$1(PromiseProtoThen$LWS, promise$LWS, [callback$LWS]);
|
|
@@ -1903,7 +1895,7 @@ class Validator$LWS {
|
|
|
1903
1895
|
// There is no reason to ever allow any HTML or XML that contains all three of these substrings.
|
|
1904
1896
|
// eslint-disable-next-line class-methods-use-this
|
|
1905
1897
|
this.isInherentlyUnsecure = input$LWS => {
|
|
1906
|
-
const normalizedInput$LWS = toSafeStringValue$LWS(input$LWS);
|
|
1898
|
+
const normalizedInput$LWS = ReflectApply$LWS$1(StringProtoToLowerCase$LWS, toSafeStringValue$LWS(input$LWS), []);
|
|
1907
1899
|
const hasIframe$LWS = hasTag$LWS(normalizedInput$LWS, 'iframe') && ReflectApply$LWS$1(StringProtoIncludes$LWS, normalizedInput$LWS, ['srcdoc']);
|
|
1908
1900
|
const hasScript$LWS = hasTag$LWS(normalizedInput$LWS, 'script');
|
|
1909
1901
|
// If neither an iframe or a script was detected, then this input is safe.
|
|
@@ -2297,7 +2289,7 @@ const {
|
|
|
2297
2289
|
const XhrProtoResponseTextGetter$LWS = ObjectLookupOwnGetter$LWS$1(XhrProto$LWS, 'responseText');
|
|
2298
2290
|
const XhrProtoStatusGetter$LWS = ObjectLookupOwnGetter$LWS$1(XhrProto$LWS, 'status');
|
|
2299
2291
|
ObjectLookupOwnSetter$LWS(XhrProto$LWS, 'withCredentials');
|
|
2300
|
-
/*! version: 0.
|
|
2292
|
+
/*! version: 0.26.2 */
|
|
2301
2293
|
|
|
2302
2294
|
/*!
|
|
2303
2295
|
* Copyright (C) 2019 salesforce.com, inc.
|
|
@@ -2372,9 +2364,9 @@ function sanitizeURLForElement$LWS(url$LWS) {
|
|
|
2372
2364
|
function sanitizeURLString$LWS(urlString$LWS) {
|
|
2373
2365
|
return urlString$LWS === '' ? urlString$LWS : ReflectApply$LWS$1(StringProtoReplace$LWS, urlString$LWS, [newlinesAndTabsRegExp$LWS, '']);
|
|
2374
2366
|
}
|
|
2375
|
-
/*! version: 0.
|
|
2367
|
+
/*! version: 0.26.2 */
|
|
2376
2368
|
|
|
2377
|
-
/*! @license DOMPurify 3.
|
|
2369
|
+
/*! @license DOMPurify 3.2.4 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.2.4/LICENSE */
|
|
2378
2370
|
|
|
2379
2371
|
const {
|
|
2380
2372
|
entries,
|
|
@@ -2413,8 +2405,10 @@ if (!construct) {
|
|
|
2413
2405
|
};
|
|
2414
2406
|
}
|
|
2415
2407
|
const arrayForEach = unapply(Array.prototype.forEach);
|
|
2408
|
+
const arrayLastIndexOf = unapply(Array.prototype.lastIndexOf);
|
|
2416
2409
|
const arrayPop = unapply(Array.prototype.pop);
|
|
2417
2410
|
const arrayPush = unapply(Array.prototype.push);
|
|
2411
|
+
const arraySplice = unapply(Array.prototype.splice);
|
|
2418
2412
|
const stringToLowerCase = unapply(String.prototype.toLowerCase);
|
|
2419
2413
|
const stringToString = unapply(String.prototype.toString);
|
|
2420
2414
|
const stringMatch = unapply(String.prototype.match);
|
|
@@ -2424,12 +2418,11 @@ const stringTrim = unapply(String.prototype.trim);
|
|
|
2424
2418
|
const objectHasOwnProperty = unapply(Object.prototype.hasOwnProperty);
|
|
2425
2419
|
const regExpTest = unapply(RegExp.prototype.test);
|
|
2426
2420
|
const typeErrorCreate = unconstruct(TypeError);
|
|
2427
|
-
|
|
2428
2421
|
/**
|
|
2429
2422
|
* Creates a new function that calls the given function with a specified thisArg and arguments.
|
|
2430
2423
|
*
|
|
2431
|
-
* @param
|
|
2432
|
-
* @returns
|
|
2424
|
+
* @param func - The function to be wrapped and called.
|
|
2425
|
+
* @returns A new function that calls the given function with a specified thisArg and arguments.
|
|
2433
2426
|
*/
|
|
2434
2427
|
function unapply(func) {
|
|
2435
2428
|
return function (thisArg) {
|
|
@@ -2439,12 +2432,11 @@ function unapply(func) {
|
|
|
2439
2432
|
return apply(func, thisArg, args);
|
|
2440
2433
|
};
|
|
2441
2434
|
}
|
|
2442
|
-
|
|
2443
2435
|
/**
|
|
2444
2436
|
* Creates a new function that constructs an instance of the given constructor function with the provided arguments.
|
|
2445
2437
|
*
|
|
2446
|
-
* @param
|
|
2447
|
-
* @returns
|
|
2438
|
+
* @param func - The constructor function to be wrapped and called.
|
|
2439
|
+
* @returns A new function that constructs an instance of the given constructor function with the provided arguments.
|
|
2448
2440
|
*/
|
|
2449
2441
|
function unconstruct(func) {
|
|
2450
2442
|
return function () {
|
|
@@ -2454,14 +2446,13 @@ function unconstruct(func) {
|
|
|
2454
2446
|
return construct(func, args);
|
|
2455
2447
|
};
|
|
2456
2448
|
}
|
|
2457
|
-
|
|
2458
2449
|
/**
|
|
2459
2450
|
* Add properties to a lookup table
|
|
2460
2451
|
*
|
|
2461
|
-
* @param
|
|
2462
|
-
* @param
|
|
2463
|
-
* @param
|
|
2464
|
-
* @returns
|
|
2452
|
+
* @param set - The set to which elements will be added.
|
|
2453
|
+
* @param array - The array containing elements to be added to the set.
|
|
2454
|
+
* @param transformCaseFunc - An optional function to transform the case of each element before adding to the set.
|
|
2455
|
+
* @returns The modified set with added elements.
|
|
2465
2456
|
*/
|
|
2466
2457
|
function addToSet(set, array) {
|
|
2467
2458
|
let transformCaseFunc = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : stringToLowerCase;
|
|
@@ -2488,12 +2479,11 @@ function addToSet(set, array) {
|
|
|
2488
2479
|
}
|
|
2489
2480
|
return set;
|
|
2490
2481
|
}
|
|
2491
|
-
|
|
2492
2482
|
/**
|
|
2493
2483
|
* Clean up an array to harden against CSPP
|
|
2494
2484
|
*
|
|
2495
|
-
* @param
|
|
2496
|
-
* @returns
|
|
2485
|
+
* @param array - The array to be cleaned.
|
|
2486
|
+
* @returns The cleaned version of the array
|
|
2497
2487
|
*/
|
|
2498
2488
|
function cleanArray(array) {
|
|
2499
2489
|
for (let index = 0; index < array.length; index++) {
|
|
@@ -2504,12 +2494,11 @@ function cleanArray(array) {
|
|
|
2504
2494
|
}
|
|
2505
2495
|
return array;
|
|
2506
2496
|
}
|
|
2507
|
-
|
|
2508
2497
|
/**
|
|
2509
2498
|
* Shallow clone an object
|
|
2510
2499
|
*
|
|
2511
|
-
* @param
|
|
2512
|
-
* @returns
|
|
2500
|
+
* @param object - The object to be cloned.
|
|
2501
|
+
* @returns A new object that copies the original.
|
|
2513
2502
|
*/
|
|
2514
2503
|
function clone(object) {
|
|
2515
2504
|
const newObject = create(null);
|
|
@@ -2527,13 +2516,12 @@ function clone(object) {
|
|
|
2527
2516
|
}
|
|
2528
2517
|
return newObject;
|
|
2529
2518
|
}
|
|
2530
|
-
|
|
2531
2519
|
/**
|
|
2532
2520
|
* This method automatically checks if the prop is function or getter and behaves accordingly.
|
|
2533
2521
|
*
|
|
2534
|
-
* @param
|
|
2535
|
-
* @param
|
|
2536
|
-
* @returns
|
|
2522
|
+
* @param object - The object to look up the getter function in its prototype chain.
|
|
2523
|
+
* @param prop - The property name for which to find the getter function.
|
|
2524
|
+
* @returns The getter function found in the prototype chain or a fallback function.
|
|
2537
2525
|
*/
|
|
2538
2526
|
function lookupGetter(object, prop) {
|
|
2539
2527
|
while (object !== null) {
|
|
@@ -2555,33 +2543,29 @@ function lookupGetter(object, prop) {
|
|
|
2555
2543
|
}
|
|
2556
2544
|
|
|
2557
2545
|
const html$1 = freeze(['a', 'abbr', 'acronym', 'address', 'area', 'article', 'aside', 'audio', 'b', 'bdi', 'bdo', 'big', 'blink', 'blockquote', 'body', 'br', 'button', 'canvas', 'caption', 'center', 'cite', 'code', 'col', 'colgroup', 'content', 'data', 'datalist', 'dd', 'decorator', 'del', 'details', 'dfn', 'dialog', 'dir', 'div', 'dl', 'dt', 'element', 'em', 'fieldset', 'figcaption', 'figure', 'font', 'footer', 'form', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'head', 'header', 'hgroup', 'hr', 'html', 'i', 'img', 'input', 'ins', 'kbd', 'label', 'legend', 'li', 'main', 'map', 'mark', 'marquee', 'menu', 'menuitem', 'meter', 'nav', 'nobr', 'ol', 'optgroup', 'option', 'output', 'p', 'picture', 'pre', 'progress', 'q', 'rp', 'rt', 'ruby', 's', 'samp', 'section', 'select', 'shadow', 'small', 'source', 'spacer', 'span', 'strike', 'strong', 'style', 'sub', 'summary', 'sup', 'table', 'tbody', 'td', 'template', 'textarea', 'tfoot', 'th', 'thead', 'time', 'tr', 'track', 'tt', 'u', 'ul', 'var', 'video', 'wbr']);
|
|
2558
|
-
|
|
2559
|
-
// SVG
|
|
2560
2546
|
const svg$1 = freeze(['svg', 'a', 'altglyph', 'altglyphdef', 'altglyphitem', 'animatecolor', 'animatemotion', 'animatetransform', 'circle', 'clippath', 'defs', 'desc', 'ellipse', 'filter', 'font', 'g', 'glyph', 'glyphref', 'hkern', 'image', 'line', 'lineargradient', 'marker', 'mask', 'metadata', 'mpath', 'path', 'pattern', 'polygon', 'polyline', 'radialgradient', 'rect', 'stop', 'style', 'switch', 'symbol', 'text', 'textpath', 'title', 'tref', 'tspan', 'view', 'vkern']);
|
|
2561
2547
|
const svgFilters = freeze(['feBlend', 'feColorMatrix', 'feComponentTransfer', 'feComposite', 'feConvolveMatrix', 'feDiffuseLighting', 'feDisplacementMap', 'feDistantLight', 'feDropShadow', 'feFlood', 'feFuncA', 'feFuncB', 'feFuncG', 'feFuncR', 'feGaussianBlur', 'feImage', 'feMerge', 'feMergeNode', 'feMorphology', 'feOffset', 'fePointLight', 'feSpecularLighting', 'feSpotLight', 'feTile', 'feTurbulence']);
|
|
2562
|
-
|
|
2563
2548
|
// List of SVG elements that are disallowed by default.
|
|
2564
2549
|
// We still need to know them so that we can do namespace
|
|
2565
2550
|
// checks properly in case one wants to add them to
|
|
2566
2551
|
// allow-list.
|
|
2567
2552
|
const svgDisallowed = freeze(['animate', 'color-profile', 'cursor', 'discard', 'font-face', 'font-face-format', 'font-face-name', 'font-face-src', 'font-face-uri', 'foreignobject', 'hatch', 'hatchpath', 'mesh', 'meshgradient', 'meshpatch', 'meshrow', 'missing-glyph', 'script', 'set', 'solidcolor', 'unknown', 'use']);
|
|
2568
2553
|
const mathMl$1 = freeze(['math', 'menclose', 'merror', 'mfenced', 'mfrac', 'mglyph', 'mi', 'mlabeledtr', 'mmultiscripts', 'mn', 'mo', 'mover', 'mpadded', 'mphantom', 'mroot', 'mrow', 'ms', 'mspace', 'msqrt', 'mstyle', 'msub', 'msup', 'msubsup', 'mtable', 'mtd', 'mtext', 'mtr', 'munder', 'munderover', 'mprescripts']);
|
|
2569
|
-
|
|
2570
2554
|
// Similarly to SVG, we want to know all MathML elements,
|
|
2571
2555
|
// even those that we disallow by default.
|
|
2572
2556
|
const mathMlDisallowed = freeze(['maction', 'maligngroup', 'malignmark', 'mlongdiv', 'mscarries', 'mscarry', 'msgroup', 'mstack', 'msline', 'msrow', 'semantics', 'annotation', 'annotation-xml', 'mprescripts', 'none']);
|
|
2573
2557
|
const text = freeze(['#text']);
|
|
2574
2558
|
|
|
2575
2559
|
const html = freeze(['accept', 'action', 'align', 'alt', 'autocapitalize', 'autocomplete', 'autopictureinpicture', 'autoplay', 'background', 'bgcolor', 'border', 'capture', 'cellpadding', 'cellspacing', 'checked', 'cite', 'class', 'clear', 'color', 'cols', 'colspan', 'controls', 'controlslist', 'coords', 'crossorigin', 'datetime', 'decoding', 'default', 'dir', 'disabled', 'disablepictureinpicture', 'disableremoteplayback', 'download', 'draggable', 'enctype', 'enterkeyhint', 'face', 'for', 'headers', 'height', 'hidden', 'high', 'href', 'hreflang', 'id', 'inputmode', 'integrity', 'ismap', 'kind', 'label', 'lang', 'list', 'loading', 'loop', 'low', 'max', 'maxlength', 'media', 'method', 'min', 'minlength', 'multiple', 'muted', 'name', 'nonce', 'noshade', 'novalidate', 'nowrap', 'open', 'optimum', 'pattern', 'placeholder', 'playsinline', 'popover', 'popovertarget', 'popovertargetaction', 'poster', 'preload', 'pubdate', 'radiogroup', 'readonly', 'rel', 'required', 'rev', 'reversed', 'role', 'rows', 'rowspan', 'spellcheck', 'scope', 'selected', 'shape', 'size', 'sizes', 'span', 'srclang', 'start', 'src', 'srcset', 'step', 'style', 'summary', 'tabindex', 'title', 'translate', 'type', 'usemap', 'valign', 'value', 'width', 'wrap', 'xmlns', 'slot']);
|
|
2576
|
-
const svg = freeze(['accent-height', 'accumulate', 'additive', 'alignment-baseline', 'ascent', 'attributename', 'attributetype', 'azimuth', 'basefrequency', 'baseline-shift', 'begin', 'bias', 'by', 'class', 'clip', 'clippathunits', 'clip-path', 'clip-rule', 'color', 'color-interpolation', 'color-interpolation-filters', 'color-profile', 'color-rendering', 'cx', 'cy', 'd', 'dx', 'dy', 'diffuseconstant', 'direction', 'display', 'divisor', 'dur', 'edgemode', 'elevation', 'end', 'fill', 'fill-opacity', 'fill-rule', 'filter', 'filterunits', 'flood-color', 'flood-opacity', 'font-family', 'font-size', 'font-size-adjust', 'font-stretch', 'font-style', 'font-variant', 'font-weight', 'fx', 'fy', 'g1', 'g2', 'glyph-name', 'glyphref', 'gradientunits', 'gradienttransform', 'height', 'href', 'id', 'image-rendering', 'in', 'in2', 'k', 'k1', 'k2', 'k3', 'k4', 'kerning', 'keypoints', 'keysplines', 'keytimes', 'lang', 'lengthadjust', 'letter-spacing', 'kernelmatrix', 'kernelunitlength', 'lighting-color', 'local', 'marker-end', 'marker-mid', 'marker-start', 'markerheight', 'markerunits', 'markerwidth', 'maskcontentunits', 'maskunits', 'max', 'mask', 'media', 'method', 'mode', 'min', 'name', 'numoctaves', 'offset', 'operator', 'opacity', 'order', 'orient', 'orientation', 'origin', 'overflow', 'paint-order', 'path', 'pathlength', 'patterncontentunits', 'patterntransform', 'patternunits', 'points', 'preservealpha', 'preserveaspectratio', 'primitiveunits', 'r', 'rx', 'ry', 'radius', 'refx', 'refy', 'repeatcount', 'repeatdur', 'restart', 'result', 'rotate', 'scale', 'seed', 'shape-rendering', 'specularconstant', 'specularexponent', 'spreadmethod', 'startoffset', 'stddeviation', 'stitchtiles', 'stop-color', 'stop-opacity', 'stroke-dasharray', 'stroke-dashoffset', 'stroke-linecap', 'stroke-linejoin', 'stroke-miterlimit', 'stroke-opacity', 'stroke', 'stroke-width', 'style', 'surfacescale', 'systemlanguage', 'tabindex', 'targetx', 'targety', 'transform', 'transform-origin', 'text-anchor', 'text-decoration', 'text-rendering', 'textlength', 'type', 'u1', 'u2', 'unicode', 'values', 'viewbox', 'visibility', 'version', 'vert-adv-y', 'vert-origin-x', 'vert-origin-y', 'width', 'word-spacing', 'wrap', 'writing-mode', 'xchannelselector', 'ychannelselector', 'x', 'x1', 'x2', 'xmlns', 'y', 'y1', 'y2', 'z', 'zoomandpan']);
|
|
2560
|
+
const svg = freeze(['accent-height', 'accumulate', 'additive', 'alignment-baseline', 'amplitude', 'ascent', 'attributename', 'attributetype', 'azimuth', 'basefrequency', 'baseline-shift', 'begin', 'bias', 'by', 'class', 'clip', 'clippathunits', 'clip-path', 'clip-rule', 'color', 'color-interpolation', 'color-interpolation-filters', 'color-profile', 'color-rendering', 'cx', 'cy', 'd', 'dx', 'dy', 'diffuseconstant', 'direction', 'display', 'divisor', 'dur', 'edgemode', 'elevation', 'end', 'exponent', 'fill', 'fill-opacity', 'fill-rule', 'filter', 'filterunits', 'flood-color', 'flood-opacity', 'font-family', 'font-size', 'font-size-adjust', 'font-stretch', 'font-style', 'font-variant', 'font-weight', 'fx', 'fy', 'g1', 'g2', 'glyph-name', 'glyphref', 'gradientunits', 'gradienttransform', 'height', 'href', 'id', 'image-rendering', 'in', 'in2', 'intercept', 'k', 'k1', 'k2', 'k3', 'k4', 'kerning', 'keypoints', 'keysplines', 'keytimes', 'lang', 'lengthadjust', 'letter-spacing', 'kernelmatrix', 'kernelunitlength', 'lighting-color', 'local', 'marker-end', 'marker-mid', 'marker-start', 'markerheight', 'markerunits', 'markerwidth', 'maskcontentunits', 'maskunits', 'max', 'mask', 'media', 'method', 'mode', 'min', 'name', 'numoctaves', 'offset', 'operator', 'opacity', 'order', 'orient', 'orientation', 'origin', 'overflow', 'paint-order', 'path', 'pathlength', 'patterncontentunits', 'patterntransform', 'patternunits', 'points', 'preservealpha', 'preserveaspectratio', 'primitiveunits', 'r', 'rx', 'ry', 'radius', 'refx', 'refy', 'repeatcount', 'repeatdur', 'restart', 'result', 'rotate', 'scale', 'seed', 'shape-rendering', 'slope', 'specularconstant', 'specularexponent', 'spreadmethod', 'startoffset', 'stddeviation', 'stitchtiles', 'stop-color', 'stop-opacity', 'stroke-dasharray', 'stroke-dashoffset', 'stroke-linecap', 'stroke-linejoin', 'stroke-miterlimit', 'stroke-opacity', 'stroke', 'stroke-width', 'style', 'surfacescale', 'systemlanguage', 'tabindex', 'tablevalues', 'targetx', 'targety', 'transform', 'transform-origin', 'text-anchor', 'text-decoration', 'text-rendering', 'textlength', 'type', 'u1', 'u2', 'unicode', 'values', 'viewbox', 'visibility', 'version', 'vert-adv-y', 'vert-origin-x', 'vert-origin-y', 'width', 'word-spacing', 'wrap', 'writing-mode', 'xchannelselector', 'ychannelselector', 'x', 'x1', 'x2', 'xmlns', 'y', 'y1', 'y2', 'z', 'zoomandpan']);
|
|
2577
2561
|
const mathMl = freeze(['accent', 'accentunder', 'align', 'bevelled', 'close', 'columnsalign', 'columnlines', 'columnspan', 'denomalign', 'depth', 'dir', 'display', 'displaystyle', 'encoding', 'fence', 'frame', 'height', 'href', 'id', 'largeop', 'length', 'linethickness', 'lspace', 'lquote', 'mathbackground', 'mathcolor', 'mathsize', 'mathvariant', 'maxsize', 'minsize', 'movablelimits', 'notation', 'numalign', 'open', 'rowalign', 'rowlines', 'rowspacing', 'rowspan', 'rspace', 'rquote', 'scriptlevel', 'scriptminsize', 'scriptsizemultiplier', 'selection', 'separator', 'separators', 'stretchy', 'subscriptshift', 'supscriptshift', 'symmetric', 'voffset', 'width', 'xmlns']);
|
|
2578
2562
|
const xml = freeze(['xlink:href', 'xml:id', 'xlink:title', 'xml:space', 'xmlns:xlink']);
|
|
2579
2563
|
|
|
2580
2564
|
// eslint-disable-next-line unicorn/better-regex
|
|
2581
2565
|
const MUSTACHE_EXPR = seal(/\{\{[\w\W]*|[\w\W]*\}\}/gm); // Specify template detection regex for SAFE_FOR_TEMPLATES mode
|
|
2582
2566
|
const ERB_EXPR = seal(/<%[\w\W]*|[\w\W]*%>/gm);
|
|
2583
|
-
const TMPLIT_EXPR = seal(
|
|
2584
|
-
const DATA_ATTR = seal(/^data-[\-\w.\u00B7-\uFFFF]
|
|
2567
|
+
const TMPLIT_EXPR = seal(/\$\{[\w\W]*/gm); // eslint-disable-line unicorn/better-regex
|
|
2568
|
+
const DATA_ATTR = seal(/^data-[\-\w.\u00B7-\uFFFF]+$/); // eslint-disable-line no-useless-escape
|
|
2585
2569
|
const ARIA_ATTR = seal(/^aria-[\-\w]+$/); // eslint-disable-line no-useless-escape
|
|
2586
2570
|
const IS_ALLOWED_URI = seal(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i // eslint-disable-line no-useless-escape
|
|
2587
2571
|
);
|
|
@@ -2593,18 +2577,19 @@ const CUSTOM_ELEMENT = seal(/^[a-z][.\w]*(-[.\w]+)+$/i);
|
|
|
2593
2577
|
|
|
2594
2578
|
var EXPRESSIONS = /*#__PURE__*/Object.freeze({
|
|
2595
2579
|
__proto__: null,
|
|
2596
|
-
MUSTACHE_EXPR: MUSTACHE_EXPR,
|
|
2597
|
-
ERB_EXPR: ERB_EXPR,
|
|
2598
|
-
TMPLIT_EXPR: TMPLIT_EXPR,
|
|
2599
|
-
DATA_ATTR: DATA_ATTR,
|
|
2600
2580
|
ARIA_ATTR: ARIA_ATTR,
|
|
2601
|
-
IS_ALLOWED_URI: IS_ALLOWED_URI,
|
|
2602
|
-
IS_SCRIPT_OR_DATA: IS_SCRIPT_OR_DATA,
|
|
2603
2581
|
ATTR_WHITESPACE: ATTR_WHITESPACE,
|
|
2582
|
+
CUSTOM_ELEMENT: CUSTOM_ELEMENT,
|
|
2583
|
+
DATA_ATTR: DATA_ATTR,
|
|
2604
2584
|
DOCTYPE_NAME: DOCTYPE_NAME,
|
|
2605
|
-
|
|
2585
|
+
ERB_EXPR: ERB_EXPR,
|
|
2586
|
+
IS_ALLOWED_URI: IS_ALLOWED_URI,
|
|
2587
|
+
IS_SCRIPT_OR_DATA: IS_SCRIPT_OR_DATA,
|
|
2588
|
+
MUSTACHE_EXPR: MUSTACHE_EXPR,
|
|
2589
|
+
TMPLIT_EXPR: TMPLIT_EXPR
|
|
2606
2590
|
});
|
|
2607
2591
|
|
|
2592
|
+
/* eslint-disable @typescript-eslint/indent */
|
|
2608
2593
|
// https://developer.mozilla.org/en-US/docs/Web/API/Node/nodeType
|
|
2609
2594
|
const NODE_TYPE = {
|
|
2610
2595
|
element: 1,
|
|
@@ -2625,20 +2610,18 @@ const NODE_TYPE = {
|
|
|
2625
2610
|
const getGlobal = function getGlobal() {
|
|
2626
2611
|
return typeof window === 'undefined' ? null : window;
|
|
2627
2612
|
};
|
|
2628
|
-
|
|
2629
2613
|
/**
|
|
2630
2614
|
* Creates a no-op policy for internal use only.
|
|
2631
2615
|
* Don't export this function outside this module!
|
|
2632
|
-
* @param
|
|
2633
|
-
* @param
|
|
2634
|
-
* @return
|
|
2616
|
+
* @param trustedTypes The policy factory.
|
|
2617
|
+
* @param purifyHostElement The Script element used to load DOMPurify (to determine policy name suffix).
|
|
2618
|
+
* @return The policy created (or null, if Trusted Types
|
|
2635
2619
|
* are not supported or creating the policy failed).
|
|
2636
2620
|
*/
|
|
2637
2621
|
const _createTrustedTypesPolicy = function _createTrustedTypesPolicy(trustedTypes, purifyHostElement) {
|
|
2638
2622
|
if (typeof trustedTypes !== 'object' || typeof trustedTypes.createPolicy !== 'function') {
|
|
2639
2623
|
return null;
|
|
2640
2624
|
}
|
|
2641
|
-
|
|
2642
2625
|
// Allow the callers to control the unique policy name
|
|
2643
2626
|
// by adding a data-tt-policy-suffix to the script element with the DOMPurify.
|
|
2644
2627
|
// Policy creation with duplicate names throws in Trusted Types.
|
|
@@ -2665,22 +2648,25 @@ const _createTrustedTypesPolicy = function _createTrustedTypesPolicy(trustedType
|
|
|
2665
2648
|
return null;
|
|
2666
2649
|
}
|
|
2667
2650
|
};
|
|
2651
|
+
const _createHooksMap = function _createHooksMap() {
|
|
2652
|
+
return {
|
|
2653
|
+
afterSanitizeAttributes: [],
|
|
2654
|
+
afterSanitizeElements: [],
|
|
2655
|
+
afterSanitizeShadowDOM: [],
|
|
2656
|
+
beforeSanitizeAttributes: [],
|
|
2657
|
+
beforeSanitizeElements: [],
|
|
2658
|
+
beforeSanitizeShadowDOM: [],
|
|
2659
|
+
uponSanitizeAttribute: [],
|
|
2660
|
+
uponSanitizeElement: [],
|
|
2661
|
+
uponSanitizeShadowNode: []
|
|
2662
|
+
};
|
|
2663
|
+
};
|
|
2668
2664
|
function createDOMPurify() {
|
|
2669
2665
|
let window = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : getGlobal();
|
|
2670
2666
|
const DOMPurify = root => createDOMPurify(root);
|
|
2671
|
-
|
|
2672
|
-
/**
|
|
2673
|
-
* Version label, exposed for easier checks
|
|
2674
|
-
* if DOMPurify is up to date or not
|
|
2675
|
-
*/
|
|
2676
|
-
DOMPurify.version = '3.1.6';
|
|
2677
|
-
|
|
2678
|
-
/**
|
|
2679
|
-
* Array of elements that DOMPurify removed during sanitation.
|
|
2680
|
-
* Empty if nothing was removed.
|
|
2681
|
-
*/
|
|
2667
|
+
DOMPurify.version = '3.2.4';
|
|
2682
2668
|
DOMPurify.removed = [];
|
|
2683
|
-
if (!window || !window.document || window.document.nodeType !== NODE_TYPE.document) {
|
|
2669
|
+
if (!window || !window.document || window.document.nodeType !== NODE_TYPE.document || !window.Element) {
|
|
2684
2670
|
// Not running in a browser, provide a factory function
|
|
2685
2671
|
// so that you can pass your own Window
|
|
2686
2672
|
DOMPurify.isSupported = false;
|
|
@@ -2708,7 +2694,6 @@ function createDOMPurify() {
|
|
|
2708
2694
|
const getNextSibling = lookupGetter(ElementPrototype, 'nextSibling');
|
|
2709
2695
|
const getChildNodes = lookupGetter(ElementPrototype, 'childNodes');
|
|
2710
2696
|
const getParentNode = lookupGetter(ElementPrototype, 'parentNode');
|
|
2711
|
-
|
|
2712
2697
|
// As per issue #47, the web-components registry is inherited by a
|
|
2713
2698
|
// new document created via createHTMLDocument. As per the spec
|
|
2714
2699
|
// (http://w3c.github.io/webcomponents/spec/custom/#creating-and-passing-registries)
|
|
@@ -2732,8 +2717,7 @@ function createDOMPurify() {
|
|
|
2732
2717
|
const {
|
|
2733
2718
|
importNode
|
|
2734
2719
|
} = originalDocument;
|
|
2735
|
-
let hooks =
|
|
2736
|
-
|
|
2720
|
+
let hooks = _createHooksMap();
|
|
2737
2721
|
/**
|
|
2738
2722
|
* Expose whether this browser supports running the full DOMPurify.
|
|
2739
2723
|
*/
|
|
@@ -2751,22 +2735,18 @@ function createDOMPurify() {
|
|
|
2751
2735
|
let {
|
|
2752
2736
|
IS_ALLOWED_URI: IS_ALLOWED_URI$1
|
|
2753
2737
|
} = EXPRESSIONS;
|
|
2754
|
-
|
|
2755
2738
|
/**
|
|
2756
2739
|
* We consider the elements and attributes below to be safe. Ideally
|
|
2757
2740
|
* don't add any new ones but feel free to remove unwanted ones.
|
|
2758
2741
|
*/
|
|
2759
|
-
|
|
2760
2742
|
/* allowed element names */
|
|
2761
2743
|
let ALLOWED_TAGS = null;
|
|
2762
2744
|
const DEFAULT_ALLOWED_TAGS = addToSet({}, [...html$1, ...svg$1, ...svgFilters, ...mathMl$1, ...text]);
|
|
2763
|
-
|
|
2764
2745
|
/* Allowed attribute names */
|
|
2765
2746
|
let ALLOWED_ATTR = null;
|
|
2766
2747
|
const DEFAULT_ALLOWED_ATTR = addToSet({}, [...html, ...svg, ...mathMl, ...xml]);
|
|
2767
|
-
|
|
2768
2748
|
/*
|
|
2769
|
-
* Configure how
|
|
2749
|
+
* Configure how DOMPurify should handle custom elements and their attributes as well as customized built-in elements.
|
|
2770
2750
|
* @property {RegExp|Function|null} tagNameCheck one of [null, regexPattern, predicate]. Default: `null` (disallow any custom elements)
|
|
2771
2751
|
* @property {RegExp|Function|null} attributeNameCheck one of [null, regexPattern, predicate]. Default: `null` (disallow any attributes not on the allow list)
|
|
2772
2752
|
* @property {boolean} allowCustomizedBuiltInElements allow custom elements derived from built-ins if they pass CUSTOM_ELEMENT_HANDLING.tagNameCheck. Default: `false`.
|
|
@@ -2791,65 +2771,49 @@ function createDOMPurify() {
|
|
|
2791
2771
|
value: false
|
|
2792
2772
|
}
|
|
2793
2773
|
}));
|
|
2794
|
-
|
|
2795
2774
|
/* Explicitly forbidden tags (overrides ALLOWED_TAGS/ADD_TAGS) */
|
|
2796
2775
|
let FORBID_TAGS = null;
|
|
2797
|
-
|
|
2798
2776
|
/* Explicitly forbidden attributes (overrides ALLOWED_ATTR/ADD_ATTR) */
|
|
2799
2777
|
let FORBID_ATTR = null;
|
|
2800
|
-
|
|
2801
2778
|
/* Decide if ARIA attributes are okay */
|
|
2802
2779
|
let ALLOW_ARIA_ATTR = true;
|
|
2803
|
-
|
|
2804
2780
|
/* Decide if custom data attributes are okay */
|
|
2805
2781
|
let ALLOW_DATA_ATTR = true;
|
|
2806
|
-
|
|
2807
2782
|
/* Decide if unknown protocols are okay */
|
|
2808
2783
|
let ALLOW_UNKNOWN_PROTOCOLS = false;
|
|
2809
|
-
|
|
2810
2784
|
/* Decide if self-closing tags in attributes are allowed.
|
|
2811
2785
|
* Usually removed due to a mXSS issue in jQuery 3.0 */
|
|
2812
2786
|
let ALLOW_SELF_CLOSE_IN_ATTR = true;
|
|
2813
|
-
|
|
2814
2787
|
/* Output should be safe for common template engines.
|
|
2815
2788
|
* This means, DOMPurify removes data attributes, mustaches and ERB
|
|
2816
2789
|
*/
|
|
2817
2790
|
let SAFE_FOR_TEMPLATES = false;
|
|
2818
|
-
|
|
2819
2791
|
/* Output should be safe even for XML used within HTML and alike.
|
|
2820
2792
|
* This means, DOMPurify removes comments when containing risky content.
|
|
2821
2793
|
*/
|
|
2822
2794
|
let SAFE_FOR_XML = true;
|
|
2823
|
-
|
|
2824
2795
|
/* Decide if document with <html>... should be returned */
|
|
2825
2796
|
let WHOLE_DOCUMENT = false;
|
|
2826
|
-
|
|
2827
2797
|
/* Track whether config is already set on this instance of DOMPurify. */
|
|
2828
2798
|
let SET_CONFIG = false;
|
|
2829
|
-
|
|
2830
2799
|
/* Decide if all elements (e.g. style, script) must be children of
|
|
2831
2800
|
* document.body. By default, browsers might move them to document.head */
|
|
2832
2801
|
let FORCE_BODY = false;
|
|
2833
|
-
|
|
2834
2802
|
/* Decide if a DOM `HTMLBodyElement` should be returned, instead of a html
|
|
2835
2803
|
* string (or a TrustedHTML object if Trusted Types are supported).
|
|
2836
2804
|
* If `WHOLE_DOCUMENT` is enabled a `HTMLHtmlElement` will be returned instead
|
|
2837
2805
|
*/
|
|
2838
2806
|
let RETURN_DOM = false;
|
|
2839
|
-
|
|
2840
2807
|
/* Decide if a DOM `DocumentFragment` should be returned, instead of a html
|
|
2841
2808
|
* string (or a TrustedHTML object if Trusted Types are supported) */
|
|
2842
2809
|
let RETURN_DOM_FRAGMENT = false;
|
|
2843
|
-
|
|
2844
2810
|
/* Try to return a Trusted Type object instead of a string, return a string in
|
|
2845
2811
|
* case Trusted Types are not supported */
|
|
2846
2812
|
let RETURN_TRUSTED_TYPE = false;
|
|
2847
|
-
|
|
2848
2813
|
/* Output should be free from DOM clobbering attacks?
|
|
2849
2814
|
* This sanitizes markups named with colliding, clobberable built-in DOM APIs.
|
|
2850
2815
|
*/
|
|
2851
2816
|
let SANITIZE_DOM = true;
|
|
2852
|
-
|
|
2853
2817
|
/* Achieve full DOM Clobbering protection by isolating the namespace of named
|
|
2854
2818
|
* properties and JS variables, mitigating attacks that abuse the HTML/DOM spec rules.
|
|
2855
2819
|
*
|
|
@@ -2865,25 +2829,19 @@ function createDOMPurify() {
|
|
|
2865
2829
|
*/
|
|
2866
2830
|
let SANITIZE_NAMED_PROPS = false;
|
|
2867
2831
|
const SANITIZE_NAMED_PROPS_PREFIX = 'user-content-';
|
|
2868
|
-
|
|
2869
2832
|
/* Keep element content when removing element? */
|
|
2870
2833
|
let KEEP_CONTENT = true;
|
|
2871
|
-
|
|
2872
2834
|
/* If a `Node` is passed to sanitize(), then performs sanitization in-place instead
|
|
2873
2835
|
* of importing it into a new Document and returning a sanitized copy */
|
|
2874
2836
|
let IN_PLACE = false;
|
|
2875
|
-
|
|
2876
2837
|
/* Allow usage of profiles like html, svg and mathMl */
|
|
2877
2838
|
let USE_PROFILES = {};
|
|
2878
|
-
|
|
2879
2839
|
/* Tags to ignore content of when KEEP_CONTENT is true */
|
|
2880
2840
|
let FORBID_CONTENTS = null;
|
|
2881
2841
|
const DEFAULT_FORBID_CONTENTS = addToSet({}, ['annotation-xml', 'audio', 'colgroup', 'desc', 'foreignobject', 'head', 'iframe', 'math', 'mi', 'mn', 'mo', 'ms', 'mtext', 'noembed', 'noframes', 'noscript', 'plaintext', 'script', 'style', 'svg', 'template', 'thead', 'title', 'video', 'xmp']);
|
|
2882
|
-
|
|
2883
2842
|
/* Tags that are safe for data: URIs */
|
|
2884
2843
|
let DATA_URI_TAGS = null;
|
|
2885
2844
|
const DEFAULT_DATA_URI_TAGS = addToSet({}, ['audio', 'video', 'img', 'source', 'image', 'track']);
|
|
2886
|
-
|
|
2887
2845
|
/* Attributes safe for values like "javascript:" */
|
|
2888
2846
|
let URI_SAFE_ATTRIBUTES = null;
|
|
2889
2847
|
const DEFAULT_URI_SAFE_ATTRIBUTES = addToSet({}, ['alt', 'class', 'for', 'id', 'label', 'name', 'pattern', 'placeholder', 'role', 'summary', 'title', 'value', 'style', 'xmlns']);
|
|
@@ -2893,32 +2851,33 @@ function createDOMPurify() {
|
|
|
2893
2851
|
/* Document namespace */
|
|
2894
2852
|
let NAMESPACE = HTML_NAMESPACE;
|
|
2895
2853
|
let IS_EMPTY_INPUT = false;
|
|
2896
|
-
|
|
2897
2854
|
/* Allowed XHTML+XML namespaces */
|
|
2898
2855
|
let ALLOWED_NAMESPACES = null;
|
|
2899
2856
|
const DEFAULT_ALLOWED_NAMESPACES = addToSet({}, [MATHML_NAMESPACE, SVG_NAMESPACE, HTML_NAMESPACE], stringToString);
|
|
2900
|
-
|
|
2857
|
+
let MATHML_TEXT_INTEGRATION_POINTS = addToSet({}, ['mi', 'mo', 'mn', 'ms', 'mtext']);
|
|
2858
|
+
let HTML_INTEGRATION_POINTS = addToSet({}, ['annotation-xml']);
|
|
2859
|
+
// Certain elements are allowed in both SVG and HTML
|
|
2860
|
+
// namespace. We need to specify them explicitly
|
|
2861
|
+
// so that they don't get erroneously deleted from
|
|
2862
|
+
// HTML namespace.
|
|
2863
|
+
const COMMON_SVG_AND_HTML_ELEMENTS = addToSet({}, ['title', 'style', 'font', 'a', 'script']);
|
|
2901
2864
|
/* Parsing of strict XHTML documents */
|
|
2902
2865
|
let PARSER_MEDIA_TYPE = null;
|
|
2903
2866
|
const SUPPORTED_PARSER_MEDIA_TYPES = ['application/xhtml+xml', 'text/html'];
|
|
2904
2867
|
const DEFAULT_PARSER_MEDIA_TYPE = 'text/html';
|
|
2905
2868
|
let transformCaseFunc = null;
|
|
2906
|
-
|
|
2907
2869
|
/* Keep a reference to config to pass to hooks */
|
|
2908
2870
|
let CONFIG = null;
|
|
2909
|
-
|
|
2910
2871
|
/* Ideally, do not touch anything below this line */
|
|
2911
2872
|
/* ______________________________________________ */
|
|
2912
|
-
|
|
2913
2873
|
const formElement = document.createElement('form');
|
|
2914
2874
|
const isRegexOrFunction = function isRegexOrFunction(testValue) {
|
|
2915
2875
|
return testValue instanceof RegExp || testValue instanceof Function;
|
|
2916
2876
|
};
|
|
2917
|
-
|
|
2918
2877
|
/**
|
|
2919
2878
|
* _parseConfig
|
|
2920
2879
|
*
|
|
2921
|
-
* @param
|
|
2880
|
+
* @param cfg optional config literal
|
|
2922
2881
|
*/
|
|
2923
2882
|
// eslint-disable-next-line complexity
|
|
2924
2883
|
const _parseConfig = function _parseConfig() {
|
|
@@ -2926,39 +2885,23 @@ function createDOMPurify() {
|
|
|
2926
2885
|
if (CONFIG && CONFIG === cfg) {
|
|
2927
2886
|
return;
|
|
2928
2887
|
}
|
|
2929
|
-
|
|
2930
2888
|
/* Shield configuration object from tampering */
|
|
2931
2889
|
if (!cfg || typeof cfg !== 'object') {
|
|
2932
2890
|
cfg = {};
|
|
2933
2891
|
}
|
|
2934
|
-
|
|
2935
2892
|
/* Shield configuration object from prototype pollution */
|
|
2936
2893
|
cfg = clone(cfg);
|
|
2937
2894
|
PARSER_MEDIA_TYPE =
|
|
2938
2895
|
// eslint-disable-next-line unicorn/prefer-includes
|
|
2939
2896
|
SUPPORTED_PARSER_MEDIA_TYPES.indexOf(cfg.PARSER_MEDIA_TYPE) === -1 ? DEFAULT_PARSER_MEDIA_TYPE : cfg.PARSER_MEDIA_TYPE;
|
|
2940
|
-
|
|
2941
2897
|
// HTML tags and attributes are not case-sensitive, converting to lowercase. Keeping XHTML as is.
|
|
2942
2898
|
transformCaseFunc = PARSER_MEDIA_TYPE === 'application/xhtml+xml' ? stringToString : stringToLowerCase;
|
|
2943
|
-
|
|
2944
2899
|
/* Set configuration parameters */
|
|
2945
2900
|
ALLOWED_TAGS = objectHasOwnProperty(cfg, 'ALLOWED_TAGS') ? addToSet({}, cfg.ALLOWED_TAGS, transformCaseFunc) : DEFAULT_ALLOWED_TAGS;
|
|
2946
2901
|
ALLOWED_ATTR = objectHasOwnProperty(cfg, 'ALLOWED_ATTR') ? addToSet({}, cfg.ALLOWED_ATTR, transformCaseFunc) : DEFAULT_ALLOWED_ATTR;
|
|
2947
2902
|
ALLOWED_NAMESPACES = objectHasOwnProperty(cfg, 'ALLOWED_NAMESPACES') ? addToSet({}, cfg.ALLOWED_NAMESPACES, stringToString) : DEFAULT_ALLOWED_NAMESPACES;
|
|
2948
|
-
URI_SAFE_ATTRIBUTES = objectHasOwnProperty(cfg, 'ADD_URI_SAFE_ATTR') ? addToSet(clone(DEFAULT_URI_SAFE_ATTRIBUTES),
|
|
2949
|
-
|
|
2950
|
-
cfg.ADD_URI_SAFE_ATTR,
|
|
2951
|
-
// eslint-disable-line indent
|
|
2952
|
-
transformCaseFunc // eslint-disable-line indent
|
|
2953
|
-
) // eslint-disable-line indent
|
|
2954
|
-
: DEFAULT_URI_SAFE_ATTRIBUTES;
|
|
2955
|
-
DATA_URI_TAGS = objectHasOwnProperty(cfg, 'ADD_DATA_URI_TAGS') ? addToSet(clone(DEFAULT_DATA_URI_TAGS),
|
|
2956
|
-
// eslint-disable-line indent
|
|
2957
|
-
cfg.ADD_DATA_URI_TAGS,
|
|
2958
|
-
// eslint-disable-line indent
|
|
2959
|
-
transformCaseFunc // eslint-disable-line indent
|
|
2960
|
-
) // eslint-disable-line indent
|
|
2961
|
-
: DEFAULT_DATA_URI_TAGS;
|
|
2903
|
+
URI_SAFE_ATTRIBUTES = objectHasOwnProperty(cfg, 'ADD_URI_SAFE_ATTR') ? addToSet(clone(DEFAULT_URI_SAFE_ATTRIBUTES), cfg.ADD_URI_SAFE_ATTR, transformCaseFunc) : DEFAULT_URI_SAFE_ATTRIBUTES;
|
|
2904
|
+
DATA_URI_TAGS = objectHasOwnProperty(cfg, 'ADD_DATA_URI_TAGS') ? addToSet(clone(DEFAULT_DATA_URI_TAGS), cfg.ADD_DATA_URI_TAGS, transformCaseFunc) : DEFAULT_DATA_URI_TAGS;
|
|
2962
2905
|
FORBID_CONTENTS = objectHasOwnProperty(cfg, 'FORBID_CONTENTS') ? addToSet({}, cfg.FORBID_CONTENTS, transformCaseFunc) : DEFAULT_FORBID_CONTENTS;
|
|
2963
2906
|
FORBID_TAGS = objectHasOwnProperty(cfg, 'FORBID_TAGS') ? addToSet({}, cfg.FORBID_TAGS, transformCaseFunc) : {};
|
|
2964
2907
|
FORBID_ATTR = objectHasOwnProperty(cfg, 'FORBID_ATTR') ? addToSet({}, cfg.FORBID_ATTR, transformCaseFunc) : {};
|
|
@@ -2980,6 +2923,8 @@ function createDOMPurify() {
|
|
|
2980
2923
|
IN_PLACE = cfg.IN_PLACE || false; // Default false
|
|
2981
2924
|
IS_ALLOWED_URI$1 = cfg.ALLOWED_URI_REGEXP || IS_ALLOWED_URI;
|
|
2982
2925
|
NAMESPACE = cfg.NAMESPACE || HTML_NAMESPACE;
|
|
2926
|
+
MATHML_TEXT_INTEGRATION_POINTS = cfg.MATHML_TEXT_INTEGRATION_POINTS || MATHML_TEXT_INTEGRATION_POINTS;
|
|
2927
|
+
HTML_INTEGRATION_POINTS = cfg.HTML_INTEGRATION_POINTS || HTML_INTEGRATION_POINTS;
|
|
2983
2928
|
CUSTOM_ELEMENT_HANDLING = cfg.CUSTOM_ELEMENT_HANDLING || {};
|
|
2984
2929
|
if (cfg.CUSTOM_ELEMENT_HANDLING && isRegexOrFunction(cfg.CUSTOM_ELEMENT_HANDLING.tagNameCheck)) {
|
|
2985
2930
|
CUSTOM_ELEMENT_HANDLING.tagNameCheck = cfg.CUSTOM_ELEMENT_HANDLING.tagNameCheck;
|
|
@@ -2996,7 +2941,6 @@ function createDOMPurify() {
|
|
|
2996
2941
|
if (RETURN_DOM_FRAGMENT) {
|
|
2997
2942
|
RETURN_DOM = true;
|
|
2998
2943
|
}
|
|
2999
|
-
|
|
3000
2944
|
/* Parse profile info */
|
|
3001
2945
|
if (USE_PROFILES) {
|
|
3002
2946
|
ALLOWED_TAGS = addToSet({}, text);
|
|
@@ -3021,7 +2965,6 @@ function createDOMPurify() {
|
|
|
3021
2965
|
addToSet(ALLOWED_ATTR, xml);
|
|
3022
2966
|
}
|
|
3023
2967
|
}
|
|
3024
|
-
|
|
3025
2968
|
/* Merge configuration parameters */
|
|
3026
2969
|
if (cfg.ADD_TAGS) {
|
|
3027
2970
|
if (ALLOWED_TAGS === DEFAULT_ALLOWED_TAGS) {
|
|
@@ -3044,17 +2987,14 @@ function createDOMPurify() {
|
|
|
3044
2987
|
}
|
|
3045
2988
|
addToSet(FORBID_CONTENTS, cfg.FORBID_CONTENTS, transformCaseFunc);
|
|
3046
2989
|
}
|
|
3047
|
-
|
|
3048
2990
|
/* Add #text in case KEEP_CONTENT is set to true */
|
|
3049
2991
|
if (KEEP_CONTENT) {
|
|
3050
2992
|
ALLOWED_TAGS['#text'] = true;
|
|
3051
2993
|
}
|
|
3052
|
-
|
|
3053
2994
|
/* Add html, head and body to ALLOWED_TAGS in case WHOLE_DOCUMENT is true */
|
|
3054
2995
|
if (WHOLE_DOCUMENT) {
|
|
3055
2996
|
addToSet(ALLOWED_TAGS, ['html', 'head', 'body']);
|
|
3056
2997
|
}
|
|
3057
|
-
|
|
3058
2998
|
/* Add tbody to ALLOWED_TAGS in case tables are permitted, see #286, #365 */
|
|
3059
2999
|
if (ALLOWED_TAGS.table) {
|
|
3060
3000
|
addToSet(ALLOWED_TAGS, ['tbody']);
|
|
@@ -3067,10 +3007,8 @@ function createDOMPurify() {
|
|
|
3067
3007
|
if (typeof cfg.TRUSTED_TYPES_POLICY.createScriptURL !== 'function') {
|
|
3068
3008
|
throw typeErrorCreate('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');
|
|
3069
3009
|
}
|
|
3070
|
-
|
|
3071
3010
|
// Overwrite existing TrustedTypes policy.
|
|
3072
3011
|
trustedTypesPolicy = cfg.TRUSTED_TYPES_POLICY;
|
|
3073
|
-
|
|
3074
3012
|
// Sign local variables required by `sanitize`.
|
|
3075
3013
|
emptyHTML = trustedTypesPolicy.createHTML('');
|
|
3076
3014
|
} else {
|
|
@@ -3078,13 +3016,11 @@ function createDOMPurify() {
|
|
|
3078
3016
|
if (trustedTypesPolicy === undefined) {
|
|
3079
3017
|
trustedTypesPolicy = _createTrustedTypesPolicy(trustedTypes, currentScript);
|
|
3080
3018
|
}
|
|
3081
|
-
|
|
3082
3019
|
// If creating the internal policy succeeded sign internal variables.
|
|
3083
3020
|
if (trustedTypesPolicy !== null && typeof emptyHTML === 'string') {
|
|
3084
3021
|
emptyHTML = trustedTypesPolicy.createHTML('');
|
|
3085
3022
|
}
|
|
3086
3023
|
}
|
|
3087
|
-
|
|
3088
3024
|
// Prevent further manipulation of configuration.
|
|
3089
3025
|
// Not available in IE8, Safari 5, etc.
|
|
3090
3026
|
if (freeze) {
|
|
@@ -3092,30 +3028,19 @@ function createDOMPurify() {
|
|
|
3092
3028
|
}
|
|
3093
3029
|
CONFIG = cfg;
|
|
3094
3030
|
};
|
|
3095
|
-
const MATHML_TEXT_INTEGRATION_POINTS = addToSet({}, ['mi', 'mo', 'mn', 'ms', 'mtext']);
|
|
3096
|
-
const HTML_INTEGRATION_POINTS = addToSet({}, ['foreignobject', 'annotation-xml']);
|
|
3097
|
-
|
|
3098
|
-
// Certain elements are allowed in both SVG and HTML
|
|
3099
|
-
// namespace. We need to specify them explicitly
|
|
3100
|
-
// so that they don't get erroneously deleted from
|
|
3101
|
-
// HTML namespace.
|
|
3102
|
-
const COMMON_SVG_AND_HTML_ELEMENTS = addToSet({}, ['title', 'style', 'font', 'a', 'script']);
|
|
3103
|
-
|
|
3104
3031
|
/* Keep track of all possible SVG and MathML tags
|
|
3105
3032
|
* so that we can perform the namespace checks
|
|
3106
3033
|
* correctly. */
|
|
3107
3034
|
const ALL_SVG_TAGS = addToSet({}, [...svg$1, ...svgFilters, ...svgDisallowed]);
|
|
3108
3035
|
const ALL_MATHML_TAGS = addToSet({}, [...mathMl$1, ...mathMlDisallowed]);
|
|
3109
|
-
|
|
3110
3036
|
/**
|
|
3111
|
-
* @param
|
|
3112
|
-
* @returns
|
|
3037
|
+
* @param element a DOM element whose namespace is being checked
|
|
3038
|
+
* @returns Return false if the element has a
|
|
3113
3039
|
* namespace that a spec-compliant parser would never
|
|
3114
3040
|
* return. Return true otherwise.
|
|
3115
3041
|
*/
|
|
3116
3042
|
const _checkValidNamespace = function _checkValidNamespace(element) {
|
|
3117
3043
|
let parent = getParentNode(element);
|
|
3118
|
-
|
|
3119
3044
|
// In JSDOM, if we're inside shadow DOM, then parentNode
|
|
3120
3045
|
// can be null. We just simulate parent in this case.
|
|
3121
3046
|
if (!parent || !parent.tagName) {
|
|
@@ -3136,14 +3061,12 @@ function createDOMPurify() {
|
|
|
3136
3061
|
if (parent.namespaceURI === HTML_NAMESPACE) {
|
|
3137
3062
|
return tagName === 'svg';
|
|
3138
3063
|
}
|
|
3139
|
-
|
|
3140
3064
|
// The only way to switch from MathML to SVG is via`
|
|
3141
3065
|
// svg if parent is either <annotation-xml> or MathML
|
|
3142
3066
|
// text integration points.
|
|
3143
3067
|
if (parent.namespaceURI === MATHML_NAMESPACE) {
|
|
3144
3068
|
return tagName === 'svg' && (parentTagName === 'annotation-xml' || MATHML_TEXT_INTEGRATION_POINTS[parentTagName]);
|
|
3145
3069
|
}
|
|
3146
|
-
|
|
3147
3070
|
// We only allow elements that are defined in SVG
|
|
3148
3071
|
// spec. All others are disallowed in SVG namespace.
|
|
3149
3072
|
return Boolean(ALL_SVG_TAGS[tagName]);
|
|
@@ -3155,13 +3078,11 @@ function createDOMPurify() {
|
|
|
3155
3078
|
if (parent.namespaceURI === HTML_NAMESPACE) {
|
|
3156
3079
|
return tagName === 'math';
|
|
3157
3080
|
}
|
|
3158
|
-
|
|
3159
3081
|
// The only way to switch from SVG to MathML is via
|
|
3160
3082
|
// <math> and HTML integration points
|
|
3161
3083
|
if (parent.namespaceURI === SVG_NAMESPACE) {
|
|
3162
3084
|
return tagName === 'math' && HTML_INTEGRATION_POINTS[parentTagName];
|
|
3163
3085
|
}
|
|
3164
|
-
|
|
3165
3086
|
// We only allow elements that are defined in MathML
|
|
3166
3087
|
// spec. All others are disallowed in MathML namespace.
|
|
3167
3088
|
return Boolean(ALL_MATHML_TAGS[tagName]);
|
|
@@ -3176,28 +3097,24 @@ function createDOMPurify() {
|
|
|
3176
3097
|
if (parent.namespaceURI === MATHML_NAMESPACE && !MATHML_TEXT_INTEGRATION_POINTS[parentTagName]) {
|
|
3177
3098
|
return false;
|
|
3178
3099
|
}
|
|
3179
|
-
|
|
3180
3100
|
// We disallow tags that are specific for MathML
|
|
3181
3101
|
// or SVG and should never appear in HTML namespace
|
|
3182
3102
|
return !ALL_MATHML_TAGS[tagName] && (COMMON_SVG_AND_HTML_ELEMENTS[tagName] || !ALL_SVG_TAGS[tagName]);
|
|
3183
3103
|
}
|
|
3184
|
-
|
|
3185
3104
|
// For XHTML and XML documents that support custom namespaces
|
|
3186
3105
|
if (PARSER_MEDIA_TYPE === 'application/xhtml+xml' && ALLOWED_NAMESPACES[element.namespaceURI]) {
|
|
3187
3106
|
return true;
|
|
3188
3107
|
}
|
|
3189
|
-
|
|
3190
3108
|
// The code should never reach this place (this means
|
|
3191
3109
|
// that the element somehow got namespace that is not
|
|
3192
3110
|
// HTML, SVG, MathML or allowed via ALLOWED_NAMESPACES).
|
|
3193
3111
|
// Return false just in case.
|
|
3194
3112
|
return false;
|
|
3195
3113
|
};
|
|
3196
|
-
|
|
3197
3114
|
/**
|
|
3198
3115
|
* _forceRemove
|
|
3199
3116
|
*
|
|
3200
|
-
* @param
|
|
3117
|
+
* @param node a DOM node
|
|
3201
3118
|
*/
|
|
3202
3119
|
const _forceRemove = function _forceRemove(node) {
|
|
3203
3120
|
arrayPush(DOMPurify.removed, {
|
|
@@ -3210,46 +3127,43 @@ function createDOMPurify() {
|
|
|
3210
3127
|
remove(node);
|
|
3211
3128
|
}
|
|
3212
3129
|
};
|
|
3213
|
-
|
|
3214
3130
|
/**
|
|
3215
3131
|
* _removeAttribute
|
|
3216
3132
|
*
|
|
3217
|
-
* @param
|
|
3218
|
-
* @param
|
|
3133
|
+
* @param name an Attribute name
|
|
3134
|
+
* @param element a DOM node
|
|
3219
3135
|
*/
|
|
3220
|
-
const _removeAttribute = function _removeAttribute(name,
|
|
3136
|
+
const _removeAttribute = function _removeAttribute(name, element) {
|
|
3221
3137
|
try {
|
|
3222
3138
|
arrayPush(DOMPurify.removed, {
|
|
3223
|
-
attribute:
|
|
3224
|
-
from:
|
|
3139
|
+
attribute: element.getAttributeNode(name),
|
|
3140
|
+
from: element
|
|
3225
3141
|
});
|
|
3226
3142
|
} catch (_) {
|
|
3227
3143
|
arrayPush(DOMPurify.removed, {
|
|
3228
3144
|
attribute: null,
|
|
3229
|
-
from:
|
|
3145
|
+
from: element
|
|
3230
3146
|
});
|
|
3231
3147
|
}
|
|
3232
|
-
|
|
3233
|
-
|
|
3234
|
-
|
|
3235
|
-
if (name === 'is' && !ALLOWED_ATTR[name]) {
|
|
3148
|
+
element.removeAttribute(name);
|
|
3149
|
+
// We void attribute values for unremovable "is" attributes
|
|
3150
|
+
if (name === 'is') {
|
|
3236
3151
|
if (RETURN_DOM || RETURN_DOM_FRAGMENT) {
|
|
3237
3152
|
try {
|
|
3238
|
-
_forceRemove(
|
|
3153
|
+
_forceRemove(element);
|
|
3239
3154
|
} catch (_) {}
|
|
3240
3155
|
} else {
|
|
3241
3156
|
try {
|
|
3242
|
-
|
|
3157
|
+
element.setAttribute(name, '');
|
|
3243
3158
|
} catch (_) {}
|
|
3244
3159
|
}
|
|
3245
3160
|
}
|
|
3246
3161
|
};
|
|
3247
|
-
|
|
3248
3162
|
/**
|
|
3249
3163
|
* _initDocument
|
|
3250
3164
|
*
|
|
3251
|
-
* @param
|
|
3252
|
-
* @return
|
|
3165
|
+
* @param dirty - a string of dirty markup
|
|
3166
|
+
* @return a DOM, filled with the dirty markup
|
|
3253
3167
|
*/
|
|
3254
3168
|
const _initDocument = function _initDocument(dirty) {
|
|
3255
3169
|
/* Create a HTML document */
|
|
@@ -3276,7 +3190,6 @@ function createDOMPurify() {
|
|
|
3276
3190
|
doc = new DOMParser().parseFromString(dirtyPayload, PARSER_MEDIA_TYPE);
|
|
3277
3191
|
} catch (_) {}
|
|
3278
3192
|
}
|
|
3279
|
-
|
|
3280
3193
|
/* Use createHTMLDocument in case DOMParser is not available */
|
|
3281
3194
|
if (!doc || !doc.documentElement) {
|
|
3282
3195
|
doc = implementation.createDocument(NAMESPACE, 'template', null);
|
|
@@ -3290,112 +3203,86 @@ function createDOMPurify() {
|
|
|
3290
3203
|
if (dirty && leadingWhitespace) {
|
|
3291
3204
|
body.insertBefore(document.createTextNode(leadingWhitespace), body.childNodes[0] || null);
|
|
3292
3205
|
}
|
|
3293
|
-
|
|
3294
3206
|
/* Work on whole document or just its body */
|
|
3295
3207
|
if (NAMESPACE === HTML_NAMESPACE) {
|
|
3296
3208
|
return getElementsByTagName.call(doc, WHOLE_DOCUMENT ? 'html' : 'body')[0];
|
|
3297
3209
|
}
|
|
3298
3210
|
return WHOLE_DOCUMENT ? doc.documentElement : body;
|
|
3299
3211
|
};
|
|
3300
|
-
|
|
3301
3212
|
/**
|
|
3302
3213
|
* Creates a NodeIterator object that you can use to traverse filtered lists of nodes or elements in a document.
|
|
3303
3214
|
*
|
|
3304
|
-
* @param
|
|
3305
|
-
* @return
|
|
3215
|
+
* @param root The root element or node to start traversing on.
|
|
3216
|
+
* @return The created NodeIterator
|
|
3306
3217
|
*/
|
|
3307
3218
|
const _createNodeIterator = function _createNodeIterator(root) {
|
|
3308
3219
|
return createNodeIterator.call(root.ownerDocument || root, root,
|
|
3309
3220
|
// eslint-disable-next-line no-bitwise
|
|
3310
3221
|
NodeFilter.SHOW_ELEMENT | NodeFilter.SHOW_COMMENT | NodeFilter.SHOW_TEXT | NodeFilter.SHOW_PROCESSING_INSTRUCTION | NodeFilter.SHOW_CDATA_SECTION, null);
|
|
3311
3222
|
};
|
|
3312
|
-
|
|
3313
3223
|
/**
|
|
3314
3224
|
* _isClobbered
|
|
3315
3225
|
*
|
|
3316
|
-
* @param
|
|
3317
|
-
* @return
|
|
3226
|
+
* @param element element to check for clobbering attacks
|
|
3227
|
+
* @return true if clobbered, false if safe
|
|
3318
3228
|
*/
|
|
3319
|
-
const _isClobbered = function _isClobbered(
|
|
3320
|
-
return
|
|
3229
|
+
const _isClobbered = function _isClobbered(element) {
|
|
3230
|
+
return element instanceof HTMLFormElement && (typeof element.nodeName !== 'string' || typeof element.textContent !== 'string' || typeof element.removeChild !== 'function' || !(element.attributes instanceof NamedNodeMap) || typeof element.removeAttribute !== 'function' || typeof element.setAttribute !== 'function' || typeof element.namespaceURI !== 'string' || typeof element.insertBefore !== 'function' || typeof element.hasChildNodes !== 'function');
|
|
3321
3231
|
};
|
|
3322
|
-
|
|
3323
3232
|
/**
|
|
3324
3233
|
* Checks whether the given object is a DOM node.
|
|
3325
3234
|
*
|
|
3326
|
-
* @param
|
|
3327
|
-
* @return
|
|
3235
|
+
* @param value object to check whether it's a DOM node
|
|
3236
|
+
* @return true is object is a DOM node
|
|
3328
3237
|
*/
|
|
3329
|
-
const _isNode = function _isNode(
|
|
3330
|
-
return typeof Node === 'function' &&
|
|
3238
|
+
const _isNode = function _isNode(value) {
|
|
3239
|
+
return typeof Node === 'function' && value instanceof Node;
|
|
3331
3240
|
};
|
|
3332
|
-
|
|
3333
|
-
|
|
3334
|
-
* _executeHook
|
|
3335
|
-
* Execute user configurable hooks
|
|
3336
|
-
*
|
|
3337
|
-
* @param {String} entryPoint Name of the hook's entry point
|
|
3338
|
-
* @param {Node} currentNode node to work on with the hook
|
|
3339
|
-
* @param {Object} data additional hook parameters
|
|
3340
|
-
*/
|
|
3341
|
-
const _executeHook = function _executeHook(entryPoint, currentNode, data) {
|
|
3342
|
-
if (!hooks[entryPoint]) {
|
|
3343
|
-
return;
|
|
3344
|
-
}
|
|
3345
|
-
arrayForEach(hooks[entryPoint], hook => {
|
|
3241
|
+
function _executeHooks(hooks, currentNode, data) {
|
|
3242
|
+
arrayForEach(hooks, hook => {
|
|
3346
3243
|
hook.call(DOMPurify, currentNode, data, CONFIG);
|
|
3347
3244
|
});
|
|
3348
|
-
}
|
|
3349
|
-
|
|
3245
|
+
}
|
|
3350
3246
|
/**
|
|
3351
3247
|
* _sanitizeElements
|
|
3352
3248
|
*
|
|
3353
3249
|
* @protect nodeName
|
|
3354
3250
|
* @protect textContent
|
|
3355
3251
|
* @protect removeChild
|
|
3356
|
-
*
|
|
3357
|
-
* @
|
|
3358
|
-
* @return {Boolean} true if node was killed, false if left alive
|
|
3252
|
+
* @param currentNode to check for permission to exist
|
|
3253
|
+
* @return true if node was killed, false if left alive
|
|
3359
3254
|
*/
|
|
3360
3255
|
const _sanitizeElements = function _sanitizeElements(currentNode) {
|
|
3361
3256
|
let content = null;
|
|
3362
|
-
|
|
3363
3257
|
/* Execute a hook if present */
|
|
3364
|
-
|
|
3365
|
-
|
|
3258
|
+
_executeHooks(hooks.beforeSanitizeElements, currentNode, null);
|
|
3366
3259
|
/* Check if element is clobbered or can clobber */
|
|
3367
3260
|
if (_isClobbered(currentNode)) {
|
|
3368
3261
|
_forceRemove(currentNode);
|
|
3369
3262
|
return true;
|
|
3370
3263
|
}
|
|
3371
|
-
|
|
3372
3264
|
/* Now let's check the element's type and name */
|
|
3373
3265
|
const tagName = transformCaseFunc(currentNode.nodeName);
|
|
3374
|
-
|
|
3375
3266
|
/* Execute a hook if present */
|
|
3376
|
-
|
|
3267
|
+
_executeHooks(hooks.uponSanitizeElement, currentNode, {
|
|
3377
3268
|
tagName,
|
|
3378
3269
|
allowedTags: ALLOWED_TAGS
|
|
3379
3270
|
});
|
|
3380
|
-
|
|
3381
3271
|
/* Detect mXSS attempts abusing namespace confusion */
|
|
3382
3272
|
if (currentNode.hasChildNodes() && !_isNode(currentNode.firstElementChild) && regExpTest(/<[/\w]/g, currentNode.innerHTML) && regExpTest(/<[/\w]/g, currentNode.textContent)) {
|
|
3383
3273
|
_forceRemove(currentNode);
|
|
3384
3274
|
return true;
|
|
3385
3275
|
}
|
|
3386
|
-
|
|
3387
3276
|
/* Remove any occurrence of processing instructions */
|
|
3388
3277
|
if (currentNode.nodeType === NODE_TYPE.progressingInstruction) {
|
|
3389
3278
|
_forceRemove(currentNode);
|
|
3390
3279
|
return true;
|
|
3391
3280
|
}
|
|
3392
|
-
|
|
3393
3281
|
/* Remove any kind of possibly harmful comments */
|
|
3394
3282
|
if (SAFE_FOR_XML && currentNode.nodeType === NODE_TYPE.comment && regExpTest(/<[/\w]/g, currentNode.data)) {
|
|
3395
3283
|
_forceRemove(currentNode);
|
|
3396
3284
|
return true;
|
|
3397
3285
|
}
|
|
3398
|
-
|
|
3399
3286
|
/* Remove element if anything forbids its presence */
|
|
3400
3287
|
if (!ALLOWED_TAGS[tagName] || FORBID_TAGS[tagName]) {
|
|
3401
3288
|
/* Check if we have a custom element to handle */
|
|
@@ -3407,7 +3294,6 @@ function createDOMPurify() {
|
|
|
3407
3294
|
return false;
|
|
3408
3295
|
}
|
|
3409
3296
|
}
|
|
3410
|
-
|
|
3411
3297
|
/* Keep content except for bad-listed elements */
|
|
3412
3298
|
if (KEEP_CONTENT && !FORBID_CONTENTS[tagName]) {
|
|
3413
3299
|
const parentNode = getParentNode(currentNode) || currentNode.parentNode;
|
|
@@ -3424,19 +3310,16 @@ function createDOMPurify() {
|
|
|
3424
3310
|
_forceRemove(currentNode);
|
|
3425
3311
|
return true;
|
|
3426
3312
|
}
|
|
3427
|
-
|
|
3428
3313
|
/* Check whether element has a valid namespace */
|
|
3429
3314
|
if (currentNode instanceof Element && !_checkValidNamespace(currentNode)) {
|
|
3430
3315
|
_forceRemove(currentNode);
|
|
3431
3316
|
return true;
|
|
3432
3317
|
}
|
|
3433
|
-
|
|
3434
3318
|
/* Make sure that older browsers don't get fallback-tag mXSS */
|
|
3435
3319
|
if ((tagName === 'noscript' || tagName === 'noembed' || tagName === 'noframes') && regExpTest(/<\/no(script|embed|frames)/i, currentNode.innerHTML)) {
|
|
3436
3320
|
_forceRemove(currentNode);
|
|
3437
3321
|
return true;
|
|
3438
3322
|
}
|
|
3439
|
-
|
|
3440
3323
|
/* Sanitize element content to be template-safe */
|
|
3441
3324
|
if (SAFE_FOR_TEMPLATES && currentNode.nodeType === NODE_TYPE.text) {
|
|
3442
3325
|
/* Get the element's text content */
|
|
@@ -3451,19 +3334,17 @@ function createDOMPurify() {
|
|
|
3451
3334
|
currentNode.textContent = content;
|
|
3452
3335
|
}
|
|
3453
3336
|
}
|
|
3454
|
-
|
|
3455
3337
|
/* Execute a hook if present */
|
|
3456
|
-
|
|
3338
|
+
_executeHooks(hooks.afterSanitizeElements, currentNode, null);
|
|
3457
3339
|
return false;
|
|
3458
3340
|
};
|
|
3459
|
-
|
|
3460
3341
|
/**
|
|
3461
3342
|
* _isValidAttribute
|
|
3462
3343
|
*
|
|
3463
|
-
* @param
|
|
3464
|
-
* @param
|
|
3465
|
-
* @param
|
|
3466
|
-
* @return
|
|
3344
|
+
* @param lcTag Lowercase tag name of containing element.
|
|
3345
|
+
* @param lcName Lowercase attribute name.
|
|
3346
|
+
* @param value Attribute value.
|
|
3347
|
+
* @return Returns true if `value` is valid, otherwise false.
|
|
3467
3348
|
*/
|
|
3468
3349
|
// eslint-disable-next-line complexity
|
|
3469
3350
|
const _isValidAttribute = function _isValidAttribute(lcTag, lcName, value) {
|
|
@@ -3471,7 +3352,6 @@ function createDOMPurify() {
|
|
|
3471
3352
|
if (SANITIZE_DOM && (lcName === 'id' || lcName === 'name') && (value in document || value in formElement)) {
|
|
3472
3353
|
return false;
|
|
3473
3354
|
}
|
|
3474
|
-
|
|
3475
3355
|
/* Allow valid data-* attributes: At least one character after "-"
|
|
3476
3356
|
(https://html.spec.whatwg.org/multipage/dom.html#embedding-custom-non-visible-data-with-the-data-*-attributes)
|
|
3477
3357
|
XML-compatible (https://html.spec.whatwg.org/multipage/infrastructure.html#xml-compatible and http://www.w3.org/TR/xml/#d0e804)
|
|
@@ -3493,19 +3373,17 @@ function createDOMPurify() {
|
|
|
3493
3373
|
} else ;
|
|
3494
3374
|
return true;
|
|
3495
3375
|
};
|
|
3496
|
-
|
|
3497
3376
|
/**
|
|
3498
3377
|
* _isBasicCustomElement
|
|
3499
3378
|
* checks if at least one dash is included in tagName, and it's not the first char
|
|
3500
3379
|
* for more sophisticated checking see https://github.com/sindresorhus/validate-element-name
|
|
3501
3380
|
*
|
|
3502
|
-
* @param
|
|
3503
|
-
* @returns
|
|
3381
|
+
* @param tagName name of the tag of the node to sanitize
|
|
3382
|
+
* @returns Returns true if the tag name meets the basic criteria for a custom element, otherwise false.
|
|
3504
3383
|
*/
|
|
3505
3384
|
const _isBasicCustomElement = function _isBasicCustomElement(tagName) {
|
|
3506
3385
|
return tagName !== 'annotation-xml' && stringMatch(tagName, CUSTOM_ELEMENT);
|
|
3507
3386
|
};
|
|
3508
|
-
|
|
3509
3387
|
/**
|
|
3510
3388
|
* _sanitizeAttributes
|
|
3511
3389
|
*
|
|
@@ -3514,27 +3392,26 @@ function createDOMPurify() {
|
|
|
3514
3392
|
* @protect removeAttribute
|
|
3515
3393
|
* @protect setAttribute
|
|
3516
3394
|
*
|
|
3517
|
-
* @param
|
|
3395
|
+
* @param currentNode to sanitize
|
|
3518
3396
|
*/
|
|
3519
3397
|
const _sanitizeAttributes = function _sanitizeAttributes(currentNode) {
|
|
3520
3398
|
/* Execute a hook if present */
|
|
3521
|
-
|
|
3399
|
+
_executeHooks(hooks.beforeSanitizeAttributes, currentNode, null);
|
|
3522
3400
|
const {
|
|
3523
3401
|
attributes
|
|
3524
3402
|
} = currentNode;
|
|
3525
|
-
|
|
3526
3403
|
/* Check if we have attributes; if not we might have a text node */
|
|
3527
|
-
if (!attributes) {
|
|
3404
|
+
if (!attributes || _isClobbered(currentNode)) {
|
|
3528
3405
|
return;
|
|
3529
3406
|
}
|
|
3530
3407
|
const hookEvent = {
|
|
3531
3408
|
attrName: '',
|
|
3532
3409
|
attrValue: '',
|
|
3533
3410
|
keepAttr: true,
|
|
3534
|
-
allowedAttributes: ALLOWED_ATTR
|
|
3411
|
+
allowedAttributes: ALLOWED_ATTR,
|
|
3412
|
+
forceKeepAttr: undefined
|
|
3535
3413
|
};
|
|
3536
3414
|
let l = attributes.length;
|
|
3537
|
-
|
|
3538
3415
|
/* Go backwards over all attributes; safely remove bad ones */
|
|
3539
3416
|
while (l--) {
|
|
3540
3417
|
const attr = attributes[l];
|
|
@@ -3545,64 +3422,53 @@ function createDOMPurify() {
|
|
|
3545
3422
|
} = attr;
|
|
3546
3423
|
const lcName = transformCaseFunc(name);
|
|
3547
3424
|
let value = name === 'value' ? attrValue : stringTrim(attrValue);
|
|
3548
|
-
|
|
3549
3425
|
/* Execute a hook if present */
|
|
3550
3426
|
hookEvent.attrName = lcName;
|
|
3551
3427
|
hookEvent.attrValue = value;
|
|
3552
3428
|
hookEvent.keepAttr = true;
|
|
3553
3429
|
hookEvent.forceKeepAttr = undefined; // Allows developers to see this is a property they can set
|
|
3554
|
-
|
|
3430
|
+
_executeHooks(hooks.uponSanitizeAttribute, currentNode, hookEvent);
|
|
3555
3431
|
value = hookEvent.attrValue;
|
|
3556
|
-
|
|
3432
|
+
/* Full DOM Clobbering protection via namespace isolation,
|
|
3433
|
+
* Prefix id and name attributes with `user-content-`
|
|
3434
|
+
*/
|
|
3435
|
+
if (SANITIZE_NAMED_PROPS && (lcName === 'id' || lcName === 'name')) {
|
|
3436
|
+
// Remove the attribute with this value
|
|
3437
|
+
_removeAttribute(name, currentNode);
|
|
3438
|
+
// Prefix the value and later re-create the attribute with the sanitized value
|
|
3439
|
+
value = SANITIZE_NAMED_PROPS_PREFIX + value;
|
|
3440
|
+
}
|
|
3557
3441
|
/* Work around a security issue with comments inside attributes */
|
|
3558
3442
|
if (SAFE_FOR_XML && regExpTest(/((--!?|])>)|<\/(style|title)/i, value)) {
|
|
3559
3443
|
_removeAttribute(name, currentNode);
|
|
3560
3444
|
continue;
|
|
3561
3445
|
}
|
|
3562
|
-
|
|
3563
3446
|
/* Did the hooks approve of the attribute? */
|
|
3564
3447
|
if (hookEvent.forceKeepAttr) {
|
|
3565
3448
|
continue;
|
|
3566
3449
|
}
|
|
3567
|
-
|
|
3568
3450
|
/* Remove attribute */
|
|
3569
3451
|
_removeAttribute(name, currentNode);
|
|
3570
|
-
|
|
3571
3452
|
/* Did the hooks approve of the attribute? */
|
|
3572
3453
|
if (!hookEvent.keepAttr) {
|
|
3573
3454
|
continue;
|
|
3574
3455
|
}
|
|
3575
|
-
|
|
3576
3456
|
/* Work around a security issue in jQuery 3.0 */
|
|
3577
3457
|
if (!ALLOW_SELF_CLOSE_IN_ATTR && regExpTest(/\/>/i, value)) {
|
|
3578
3458
|
_removeAttribute(name, currentNode);
|
|
3579
3459
|
continue;
|
|
3580
3460
|
}
|
|
3581
|
-
|
|
3582
3461
|
/* Sanitize attribute content to be template-safe */
|
|
3583
3462
|
if (SAFE_FOR_TEMPLATES) {
|
|
3584
3463
|
arrayForEach([MUSTACHE_EXPR, ERB_EXPR, TMPLIT_EXPR], expr => {
|
|
3585
3464
|
value = stringReplace(value, expr, ' ');
|
|
3586
3465
|
});
|
|
3587
3466
|
}
|
|
3588
|
-
|
|
3589
3467
|
/* Is `value` valid for this attribute? */
|
|
3590
3468
|
const lcTag = transformCaseFunc(currentNode.nodeName);
|
|
3591
3469
|
if (!_isValidAttribute(lcTag, lcName, value)) {
|
|
3592
3470
|
continue;
|
|
3593
3471
|
}
|
|
3594
|
-
|
|
3595
|
-
/* Full DOM Clobbering protection via namespace isolation,
|
|
3596
|
-
* Prefix id and name attributes with `user-content-`
|
|
3597
|
-
*/
|
|
3598
|
-
if (SANITIZE_NAMED_PROPS && (lcName === 'id' || lcName === 'name')) {
|
|
3599
|
-
// Remove the attribute with this value
|
|
3600
|
-
_removeAttribute(name, currentNode);
|
|
3601
|
-
|
|
3602
|
-
// Prefix the value and later re-create the attribute with the sanitized value
|
|
3603
|
-
value = SANITIZE_NAMED_PROPS_PREFIX + value;
|
|
3604
|
-
}
|
|
3605
|
-
|
|
3606
3472
|
/* Handle attributes that require Trusted Types */
|
|
3607
3473
|
if (trustedTypesPolicy && typeof trustedTypes === 'object' && typeof trustedTypes.getAttributeType === 'function') {
|
|
3608
3474
|
if (namespaceURI) ; else {
|
|
@@ -3620,7 +3486,6 @@ function createDOMPurify() {
|
|
|
3620
3486
|
}
|
|
3621
3487
|
}
|
|
3622
3488
|
}
|
|
3623
|
-
|
|
3624
3489
|
/* Handle invalid data-* attribute set by try-catching it */
|
|
3625
3490
|
try {
|
|
3626
3491
|
if (namespaceURI) {
|
|
@@ -3636,51 +3501,34 @@ function createDOMPurify() {
|
|
|
3636
3501
|
}
|
|
3637
3502
|
} catch (_) {}
|
|
3638
3503
|
}
|
|
3639
|
-
|
|
3640
3504
|
/* Execute a hook if present */
|
|
3641
|
-
|
|
3505
|
+
_executeHooks(hooks.afterSanitizeAttributes, currentNode, null);
|
|
3642
3506
|
};
|
|
3643
|
-
|
|
3644
3507
|
/**
|
|
3645
3508
|
* _sanitizeShadowDOM
|
|
3646
3509
|
*
|
|
3647
|
-
* @param
|
|
3510
|
+
* @param fragment to iterate over recursively
|
|
3648
3511
|
*/
|
|
3649
3512
|
const _sanitizeShadowDOM = function _sanitizeShadowDOM(fragment) {
|
|
3650
3513
|
let shadowNode = null;
|
|
3651
3514
|
const shadowIterator = _createNodeIterator(fragment);
|
|
3652
|
-
|
|
3653
3515
|
/* Execute a hook if present */
|
|
3654
|
-
|
|
3516
|
+
_executeHooks(hooks.beforeSanitizeShadowDOM, fragment, null);
|
|
3655
3517
|
while (shadowNode = shadowIterator.nextNode()) {
|
|
3656
3518
|
/* Execute a hook if present */
|
|
3657
|
-
|
|
3658
|
-
|
|
3519
|
+
_executeHooks(hooks.uponSanitizeShadowNode, shadowNode, null);
|
|
3659
3520
|
/* Sanitize tags and elements */
|
|
3660
|
-
|
|
3661
|
-
|
|
3662
|
-
|
|
3663
|
-
|
|
3521
|
+
_sanitizeElements(shadowNode);
|
|
3522
|
+
/* Check attributes next */
|
|
3523
|
+
_sanitizeAttributes(shadowNode);
|
|
3664
3524
|
/* Deep shadow DOM detected */
|
|
3665
3525
|
if (shadowNode.content instanceof DocumentFragment) {
|
|
3666
3526
|
_sanitizeShadowDOM(shadowNode.content);
|
|
3667
3527
|
}
|
|
3668
|
-
|
|
3669
|
-
/* Check attributes, sanitize if necessary */
|
|
3670
|
-
_sanitizeAttributes(shadowNode);
|
|
3671
3528
|
}
|
|
3672
|
-
|
|
3673
3529
|
/* Execute a hook if present */
|
|
3674
|
-
|
|
3530
|
+
_executeHooks(hooks.afterSanitizeShadowDOM, fragment, null);
|
|
3675
3531
|
};
|
|
3676
|
-
|
|
3677
|
-
/**
|
|
3678
|
-
* Sanitize
|
|
3679
|
-
* Public method providing core sanitation functionality
|
|
3680
|
-
*
|
|
3681
|
-
* @param {String|Node} dirty string or DOM node
|
|
3682
|
-
* @param {Object} cfg object
|
|
3683
|
-
*/
|
|
3684
3532
|
// eslint-disable-next-line complexity
|
|
3685
3533
|
DOMPurify.sanitize = function (dirty) {
|
|
3686
3534
|
let cfg = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
@@ -3695,7 +3543,6 @@ function createDOMPurify() {
|
|
|
3695
3543
|
if (IS_EMPTY_INPUT) {
|
|
3696
3544
|
dirty = '<!-->';
|
|
3697
3545
|
}
|
|
3698
|
-
|
|
3699
3546
|
/* Stringify, in case dirty is an object */
|
|
3700
3547
|
if (typeof dirty !== 'string' && !_isNode(dirty)) {
|
|
3701
3548
|
if (typeof dirty.toString === 'function') {
|
|
@@ -3707,20 +3554,16 @@ function createDOMPurify() {
|
|
|
3707
3554
|
throw typeErrorCreate('toString is not a function');
|
|
3708
3555
|
}
|
|
3709
3556
|
}
|
|
3710
|
-
|
|
3711
3557
|
/* Return dirty HTML if DOMPurify cannot run */
|
|
3712
3558
|
if (!DOMPurify.isSupported) {
|
|
3713
3559
|
return dirty;
|
|
3714
3560
|
}
|
|
3715
|
-
|
|
3716
3561
|
/* Assign config vars */
|
|
3717
3562
|
if (!SET_CONFIG) {
|
|
3718
3563
|
_parseConfig(cfg);
|
|
3719
3564
|
}
|
|
3720
|
-
|
|
3721
3565
|
/* Clean up removed elements */
|
|
3722
3566
|
DOMPurify.removed = [];
|
|
3723
|
-
|
|
3724
3567
|
/* Check if dirty is correctly typed for IN_PLACE */
|
|
3725
3568
|
if (typeof dirty === 'string') {
|
|
3726
3569
|
IN_PLACE = false;
|
|
@@ -3754,45 +3597,34 @@ function createDOMPurify() {
|
|
|
3754
3597
|
dirty.indexOf('<') === -1) {
|
|
3755
3598
|
return trustedTypesPolicy && RETURN_TRUSTED_TYPE ? trustedTypesPolicy.createHTML(dirty) : dirty;
|
|
3756
3599
|
}
|
|
3757
|
-
|
|
3758
3600
|
/* Initialize the document to work on */
|
|
3759
3601
|
body = _initDocument(dirty);
|
|
3760
|
-
|
|
3761
3602
|
/* Check we have a DOM node from the data */
|
|
3762
3603
|
if (!body) {
|
|
3763
3604
|
return RETURN_DOM ? null : RETURN_TRUSTED_TYPE ? emptyHTML : '';
|
|
3764
3605
|
}
|
|
3765
3606
|
}
|
|
3766
|
-
|
|
3767
3607
|
/* Remove first element node (ours) if FORCE_BODY is set */
|
|
3768
3608
|
if (body && FORCE_BODY) {
|
|
3769
3609
|
_forceRemove(body.firstChild);
|
|
3770
3610
|
}
|
|
3771
|
-
|
|
3772
3611
|
/* Get node iterator */
|
|
3773
3612
|
const nodeIterator = _createNodeIterator(IN_PLACE ? dirty : body);
|
|
3774
|
-
|
|
3775
3613
|
/* Now start iterating over the created document */
|
|
3776
3614
|
while (currentNode = nodeIterator.nextNode()) {
|
|
3777
3615
|
/* Sanitize tags and elements */
|
|
3778
|
-
|
|
3779
|
-
|
|
3780
|
-
|
|
3781
|
-
|
|
3616
|
+
_sanitizeElements(currentNode);
|
|
3617
|
+
/* Check attributes next */
|
|
3618
|
+
_sanitizeAttributes(currentNode);
|
|
3782
3619
|
/* Shadow DOM detected, sanitize it */
|
|
3783
3620
|
if (currentNode.content instanceof DocumentFragment) {
|
|
3784
3621
|
_sanitizeShadowDOM(currentNode.content);
|
|
3785
3622
|
}
|
|
3786
|
-
|
|
3787
|
-
/* Check attributes, sanitize if necessary */
|
|
3788
|
-
_sanitizeAttributes(currentNode);
|
|
3789
3623
|
}
|
|
3790
|
-
|
|
3791
3624
|
/* If we sanitized `dirty` in-place, return it. */
|
|
3792
3625
|
if (IN_PLACE) {
|
|
3793
3626
|
return dirty;
|
|
3794
3627
|
}
|
|
3795
|
-
|
|
3796
3628
|
/* Return sanitized string or DOM */
|
|
3797
3629
|
if (RETURN_DOM) {
|
|
3798
3630
|
if (RETURN_DOM_FRAGMENT) {
|
|
@@ -3817,12 +3649,10 @@ function createDOMPurify() {
|
|
|
3817
3649
|
return returnNode;
|
|
3818
3650
|
}
|
|
3819
3651
|
let serializedHTML = WHOLE_DOCUMENT ? body.outerHTML : body.innerHTML;
|
|
3820
|
-
|
|
3821
3652
|
/* Serialize doctype if allowed */
|
|
3822
3653
|
if (WHOLE_DOCUMENT && ALLOWED_TAGS['!doctype'] && body.ownerDocument && body.ownerDocument.doctype && body.ownerDocument.doctype.name && regExpTest(DOCTYPE_NAME, body.ownerDocument.doctype.name)) {
|
|
3823
3654
|
serializedHTML = '<!DOCTYPE ' + body.ownerDocument.doctype.name + '>\n' + serializedHTML;
|
|
3824
3655
|
}
|
|
3825
|
-
|
|
3826
3656
|
/* Sanitize final string template-safe */
|
|
3827
3657
|
if (SAFE_FOR_TEMPLATES) {
|
|
3828
3658
|
arrayForEach([MUSTACHE_EXPR, ERB_EXPR, TMPLIT_EXPR], expr => {
|
|
@@ -3831,39 +3661,15 @@ function createDOMPurify() {
|
|
|
3831
3661
|
}
|
|
3832
3662
|
return trustedTypesPolicy && RETURN_TRUSTED_TYPE ? trustedTypesPolicy.createHTML(serializedHTML) : serializedHTML;
|
|
3833
3663
|
};
|
|
3834
|
-
|
|
3835
|
-
/**
|
|
3836
|
-
* Public method to set the configuration once
|
|
3837
|
-
* setConfig
|
|
3838
|
-
*
|
|
3839
|
-
* @param {Object} cfg configuration object
|
|
3840
|
-
*/
|
|
3841
3664
|
DOMPurify.setConfig = function () {
|
|
3842
3665
|
let cfg = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
3843
3666
|
_parseConfig(cfg);
|
|
3844
3667
|
SET_CONFIG = true;
|
|
3845
3668
|
};
|
|
3846
|
-
|
|
3847
|
-
/**
|
|
3848
|
-
* Public method to remove the configuration
|
|
3849
|
-
* clearConfig
|
|
3850
|
-
*
|
|
3851
|
-
*/
|
|
3852
3669
|
DOMPurify.clearConfig = function () {
|
|
3853
3670
|
CONFIG = null;
|
|
3854
3671
|
SET_CONFIG = false;
|
|
3855
3672
|
};
|
|
3856
|
-
|
|
3857
|
-
/**
|
|
3858
|
-
* Public method to check if an attribute value is valid.
|
|
3859
|
-
* Uses last set config, if any. Otherwise, uses config defaults.
|
|
3860
|
-
* isValidAttribute
|
|
3861
|
-
*
|
|
3862
|
-
* @param {String} tag Tag name of containing element.
|
|
3863
|
-
* @param {String} attr Attribute name.
|
|
3864
|
-
* @param {String} value Attribute value.
|
|
3865
|
-
* @return {Boolean} Returns true if `value` is valid. Otherwise, returns false.
|
|
3866
|
-
*/
|
|
3867
3673
|
DOMPurify.isValidAttribute = function (tag, attr, value) {
|
|
3868
3674
|
/* Initialize shared config vars if necessary. */
|
|
3869
3675
|
if (!CONFIG) {
|
|
@@ -3873,54 +3679,24 @@ function createDOMPurify() {
|
|
|
3873
3679
|
const lcName = transformCaseFunc(attr);
|
|
3874
3680
|
return _isValidAttribute(lcTag, lcName, value);
|
|
3875
3681
|
};
|
|
3876
|
-
|
|
3877
|
-
/**
|
|
3878
|
-
* AddHook
|
|
3879
|
-
* Public method to add DOMPurify hooks
|
|
3880
|
-
*
|
|
3881
|
-
* @param {String} entryPoint entry point for the hook to add
|
|
3882
|
-
* @param {Function} hookFunction function to execute
|
|
3883
|
-
*/
|
|
3884
3682
|
DOMPurify.addHook = function (entryPoint, hookFunction) {
|
|
3885
3683
|
if (typeof hookFunction !== 'function') {
|
|
3886
3684
|
return;
|
|
3887
3685
|
}
|
|
3888
|
-
hooks[entryPoint] = hooks[entryPoint] || [];
|
|
3889
3686
|
arrayPush(hooks[entryPoint], hookFunction);
|
|
3890
3687
|
};
|
|
3891
|
-
|
|
3892
|
-
|
|
3893
|
-
|
|
3894
|
-
|
|
3895
|
-
* (pops it from the stack of hooks if more are present)
|
|
3896
|
-
*
|
|
3897
|
-
* @param {String} entryPoint entry point for the hook to remove
|
|
3898
|
-
* @return {Function} removed(popped) hook
|
|
3899
|
-
*/
|
|
3900
|
-
DOMPurify.removeHook = function (entryPoint) {
|
|
3901
|
-
if (hooks[entryPoint]) {
|
|
3902
|
-
return arrayPop(hooks[entryPoint]);
|
|
3688
|
+
DOMPurify.removeHook = function (entryPoint, hookFunction) {
|
|
3689
|
+
if (hookFunction !== undefined) {
|
|
3690
|
+
const index = arrayLastIndexOf(hooks[entryPoint], hookFunction);
|
|
3691
|
+
return index === -1 ? undefined : arraySplice(hooks[entryPoint], index, 1)[0];
|
|
3903
3692
|
}
|
|
3693
|
+
return arrayPop(hooks[entryPoint]);
|
|
3904
3694
|
};
|
|
3905
|
-
|
|
3906
|
-
/**
|
|
3907
|
-
* RemoveHooks
|
|
3908
|
-
* Public method to remove all DOMPurify hooks at a given entryPoint
|
|
3909
|
-
*
|
|
3910
|
-
* @param {String} entryPoint entry point for the hooks to remove
|
|
3911
|
-
*/
|
|
3912
3695
|
DOMPurify.removeHooks = function (entryPoint) {
|
|
3913
|
-
|
|
3914
|
-
hooks[entryPoint] = [];
|
|
3915
|
-
}
|
|
3696
|
+
hooks[entryPoint] = [];
|
|
3916
3697
|
};
|
|
3917
|
-
|
|
3918
|
-
/**
|
|
3919
|
-
* RemoveAllHooks
|
|
3920
|
-
* Public method to remove all DOMPurify hooks
|
|
3921
|
-
*/
|
|
3922
3698
|
DOMPurify.removeAllHooks = function () {
|
|
3923
|
-
hooks =
|
|
3699
|
+
hooks = _createHooksMap();
|
|
3924
3700
|
};
|
|
3925
3701
|
return DOMPurify;
|
|
3926
3702
|
}
|
|
@@ -4000,7 +3776,7 @@ try {
|
|
|
4000
3776
|
// swallow
|
|
4001
3777
|
}
|
|
4002
3778
|
const trusted = createPolicy('trusted', policyOptions);
|
|
4003
|
-
/*! version: 0.
|
|
3779
|
+
/*! version: 0.26.2 */
|
|
4004
3780
|
|
|
4005
3781
|
/*!
|
|
4006
3782
|
* Copyright (C) 2019 salesforce.com, inc.
|
|
@@ -4072,7 +3848,6 @@ function createSantizerHooksRegistry$LWS(sandboxKey$LWS) {
|
|
|
4072
3848
|
return {
|
|
4073
3849
|
__proto__: null,
|
|
4074
3850
|
// uponSanitizeAttribute is generic, so its definition can be a reused function
|
|
4075
|
-
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
|
4076
3851
|
uponSanitizeAttribute: uponSanitizeAttribute$LWS,
|
|
4077
3852
|
// uponSanitizeElement is sandbox-key-specific
|
|
4078
3853
|
uponSanitizeElement(node$LWS, data$LWS, config$LWS) {
|
|
@@ -4120,7 +3895,13 @@ function getSanitizerForConfig$LWS(sandboxKey$LWS, configName$LWS) {
|
|
|
4120
3895
|
configuredDOMPurifyInstance$LWS.setConfig(config$LWS);
|
|
4121
3896
|
const hooksRegistry$LWS = createSantizerHooksRegistry$LWS(sandboxKey$LWS);
|
|
4122
3897
|
for (const hookName$LWS in hooksRegistry$LWS) {
|
|
4123
|
-
|
|
3898
|
+
if (hookName$LWS === 'uponSanitizeElement') {
|
|
3899
|
+
configuredDOMPurifyInstance$LWS.addHook('uponSanitizeElement', hooksRegistry$LWS[hookName$LWS]);
|
|
3900
|
+
} else if (hookName$LWS === 'uponSanitizeAttribute') {
|
|
3901
|
+
configuredDOMPurifyInstance$LWS.addHook('uponSanitizeAttribute', hooksRegistry$LWS[hookName$LWS]);
|
|
3902
|
+
} else {
|
|
3903
|
+
configuredDOMPurifyInstance$LWS.addHook(hookName$LWS, hooksRegistry$LWS[hookName$LWS]);
|
|
3904
|
+
}
|
|
4124
3905
|
}
|
|
4125
3906
|
sandboxConfiguredSanitizerInstances$LWS[configName$LWS] = configuredDOMPurifyInstance$LWS;
|
|
4126
3907
|
}
|
|
@@ -4197,7 +3978,6 @@ function fetchAndSanitize$LWS(normalizedHref$LWS) {
|
|
|
4197
3978
|
if (status$LWS === 200) {
|
|
4198
3979
|
// Retrieved content should be sanitized immediately.
|
|
4199
3980
|
const responseText$LWS = ReflectApply$LWS$1(XhrProtoResponseTextGetter$LWS, xhr$LWS, []);
|
|
4200
|
-
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
|
4201
3981
|
const fragment$LWS = sanitizeSvgTextReturnDOM$LWS(responseText$LWS);
|
|
4202
3982
|
// Look for the container again in case other requests have finished
|
|
4203
3983
|
// earlier for the same URL.
|
|
@@ -4261,7 +4041,7 @@ function blobSanitizer$LWS(sandboxKey$LWS) {
|
|
|
4261
4041
|
}
|
|
4262
4042
|
return getSanitizerForConfig$LWS(sandboxKey$LWS, 'STRING_BLOB_HTML');
|
|
4263
4043
|
}
|
|
4264
|
-
/*! version: 0.
|
|
4044
|
+
/*! version: 0.26.2 */
|
|
4265
4045
|
|
|
4266
4046
|
/*!
|
|
4267
4047
|
* Copyright (C) 2023 salesforce.com, inc.
|
|
@@ -4311,8 +4091,6 @@ function abortInFlightRequest$LWS(element$LWS) {
|
|
|
4311
4091
|
}
|
|
4312
4092
|
const EVALUATOR_PROPERTY_KEY$LWS = '$evaluator$';
|
|
4313
4093
|
const BLOB_SCRIPT_SOURCE$LWS = `document.currentScript['${EVALUATOR_PROPERTY_KEY$LWS}']`;
|
|
4314
|
-
|
|
4315
|
-
// eslint-disable-next-line no-shadow
|
|
4316
4094
|
var ContentType$LWS;
|
|
4317
4095
|
(function (ContentType$LWS) {
|
|
4318
4096
|
ContentType$LWS[ContentType$LWS["HTML"] = 0] = "HTML";
|
|
@@ -4460,12 +4238,13 @@ function createScriptSrcURLSetter$LWS(targetElement$LWS) {
|
|
|
4460
4238
|
ReflectApply$LWS$1(ElementProtoSetAttributeNS$LWS, targetElement$LWS, [attributeNamespaceURI$LWS, attributeName$LWS, src$LWS]);
|
|
4461
4239
|
};
|
|
4462
4240
|
}
|
|
4463
|
-
/*! version: 0.
|
|
4241
|
+
/*! version: 0.26.2 */
|
|
4464
4242
|
|
|
4465
4243
|
/*!
|
|
4466
4244
|
* Copyright (C) 2019 salesforce.com, inc.
|
|
4467
4245
|
*/
|
|
4468
4246
|
var _rootWindow$CustomEle$LWS;
|
|
4247
|
+
function _extends$LWS() { return _extends$LWS = Object.assign ? Object.assign.bind() : function (n$LWS) { for (var e$LWS = 1; e$LWS < arguments.length; e$LWS++) { var t$LWS = arguments[e$LWS]; for (var r$LWS in t$LWS) ({}).hasOwnProperty.call(t$LWS, r$LWS) && (n$LWS[r$LWS] = t$LWS[r$LWS]); } return n$LWS; }, _extends$LWS.apply(null, arguments); }
|
|
4469
4248
|
const ERR_ILLEGAL_CONSTRUCTOR$LWS = 'Illegal constructor';
|
|
4470
4249
|
const ERR_ILLEGAL_INVOCATION$LWS = 'Illegal invocation.';
|
|
4471
4250
|
const ERR_NO_NEW_OP_HTML_ELEMENT$LWS = "Failed to construct 'HTMLElement': Please use the 'new' operator, this DOM object constructor cannot be called as a function.";
|
|
@@ -5791,7 +5570,7 @@ function initDistortionCookieStoreOnChange$LWS({
|
|
|
5791
5570
|
CookieStore: CookieStore$LWS
|
|
5792
5571
|
}
|
|
5793
5572
|
}) {
|
|
5794
|
-
return createEventDistortionFactory$LWS(
|
|
5573
|
+
return createEventDistortionFactory$LWS(/* istanbul ignore next: optional chaining and nullish coalescing results in an expansion that contains an unreachable "void 0" branch for every occurrence of the operator */CookieStore$LWS == null ? void 0 : CookieStore$LWS.prototype, CookieStore$LWS, 'change');
|
|
5795
5574
|
}
|
|
5796
5575
|
|
|
5797
5576
|
/* istanbul ignore next: only available in secure context */
|
|
@@ -6275,17 +6054,22 @@ function initDistortionDOMParserParseFromString$LWS({
|
|
|
6275
6054
|
default:
|
|
6276
6055
|
contentType$LWS = ContentType$LWS.HTML;
|
|
6277
6056
|
}
|
|
6278
|
-
if (contentType$LWS === ContentType$LWS.XML) {
|
|
6279
|
-
if (isInherentlyUnsecure$LWS(string$LWS)) {
|
|
6280
|
-
throw new LockerSecurityError$LWS(`Cannot 'parseFromString' using an unsecure ${toSafeTemplateStringValue$LWS(string$LWS)}.`);
|
|
6281
|
-
}
|
|
6282
|
-
}
|
|
6283
6057
|
// This must be called to signal to the virtual
|
|
6284
6058
|
// CustomElementRegistry that the next thing created
|
|
6285
6059
|
// MAY CONTAIN a custom element, which must be marked for
|
|
6286
6060
|
// association to this sandbox.
|
|
6287
6061
|
setCustomElementsRegistry$LWS(document$LWS, key$LWS);
|
|
6288
|
-
|
|
6062
|
+
const trustedHtml$LWS = lwsInternalPolicy$LWS.createHTML(string$LWS, key$LWS, contentType$LWS);
|
|
6063
|
+
if (contentType$LWS === ContentType$LWS.XML) {
|
|
6064
|
+
if (isInherentlyUnsecure$LWS(trustedHtml$LWS)) {
|
|
6065
|
+
throw new LockerSecurityError$LWS(`Cannot 'parseFromString' using an unsecure ${toSafeTemplateStringValue$LWS(trustedHtml$LWS)}.`);
|
|
6066
|
+
}
|
|
6067
|
+
}
|
|
6068
|
+
// Reassign args with sanitized string
|
|
6069
|
+
args$LWS[0] = trustedHtml$LWS;
|
|
6070
|
+
// Prevent shapeshifting arg from manipulating the
|
|
6071
|
+
// outcome when passed to originalParseFromString call
|
|
6072
|
+
args$LWS[1] = mimeType$LWS;
|
|
6289
6073
|
}
|
|
6290
6074
|
return ReflectApply$LWS$1(originalParseFromString$LWS, this, args$LWS);
|
|
6291
6075
|
}];
|
|
@@ -6547,7 +6331,7 @@ function scriptPropertySetters$LWS(incomingThis$LWS, property$LWS, valueAsTruste
|
|
|
6547
6331
|
return false;
|
|
6548
6332
|
}
|
|
6549
6333
|
const {
|
|
6550
|
-
isInherentlyUnsecure: isInherentlyUnsecure$
|
|
6334
|
+
isInherentlyUnsecure: isInherentlyUnsecure$4$LWS,
|
|
6551
6335
|
isSharedElement: isSharedElement$o$LWS
|
|
6552
6336
|
} = rootValidator$LWS;
|
|
6553
6337
|
function initDistortionElementInnerHTMLSetter$LWS({
|
|
@@ -6591,7 +6375,7 @@ function initDistortionElementInnerHTMLSetter$LWS({
|
|
|
6591
6375
|
const contentType$LWS = this instanceof SVGElement$LWS ? ContentType$LWS.SVG : ContentType$LWS.HTML;
|
|
6592
6376
|
value$LWS = lwsInternalPolicy$LWS.createHTML(value$LWS, key$LWS, contentType$LWS);
|
|
6593
6377
|
}
|
|
6594
|
-
if (isInherentlyUnsecure$
|
|
6378
|
+
if (isInherentlyUnsecure$4$LWS(value$LWS)) {
|
|
6595
6379
|
throw new LockerSecurityError$LWS(`Cannot set 'innerHTML' using an unsecure ${toSafeTemplateStringValue$LWS(value$LWS)}.`);
|
|
6596
6380
|
}
|
|
6597
6381
|
ReflectApply$LWS$1(originalInnerHTMLSetter$LWS, this, [value$LWS]);
|
|
@@ -6629,6 +6413,7 @@ function initDistortionElementInsertAdjacentElement$LWS({
|
|
|
6629
6413
|
};
|
|
6630
6414
|
}
|
|
6631
6415
|
const {
|
|
6416
|
+
isInherentlyUnsecure: isInherentlyUnsecure$3$LWS,
|
|
6632
6417
|
isSharedElement: isSharedElement$m$LWS
|
|
6633
6418
|
} = rootValidator$LWS;
|
|
6634
6419
|
const allowedElementHTMLRegExp$LWS = /^\s*<(link|script|style)/i;
|
|
@@ -6659,12 +6444,17 @@ function initDistortionElementInsertAdjacentHTML$LWS({
|
|
|
6659
6444
|
setCustomElementsRegistry$LWS(document$LWS, key$LWS);
|
|
6660
6445
|
const contentType$LWS = this instanceof SVGElement ? ContentType$LWS.SVG : ContentType$LWS.HTML;
|
|
6661
6446
|
args$LWS[1] = lwsInternalPolicy$LWS.createHTML(args$LWS[1], key$LWS, contentType$LWS);
|
|
6447
|
+
// If the sanitized string is still insecure, throw an exception
|
|
6448
|
+
if (isInherentlyUnsecure$3$LWS(args$LWS[1])) {
|
|
6449
|
+
throw new LockerSecurityError$LWS(`Cannot set 'insertAdjacentHTML' using an unsecure ${toSafeTemplateStringValue$LWS(args$LWS[1])}.`);
|
|
6450
|
+
}
|
|
6662
6451
|
}
|
|
6663
6452
|
ReflectApply$LWS$1(originalInsertAdjacentHTML$LWS, this, args$LWS);
|
|
6664
6453
|
}];
|
|
6665
6454
|
};
|
|
6666
6455
|
}
|
|
6667
6456
|
const {
|
|
6457
|
+
isInherentlyUnsecure: isInherentlyUnsecure$2$LWS,
|
|
6668
6458
|
isSharedElement: isSharedElement$l$LWS
|
|
6669
6459
|
} = rootValidator$LWS;
|
|
6670
6460
|
function initDistortionElementOuterHTMLSetter$LWS({
|
|
@@ -6688,6 +6478,12 @@ function initDistortionElementOuterHTMLSetter$LWS({
|
|
|
6688
6478
|
// association to this sandbox.
|
|
6689
6479
|
setCustomElementsRegistry$LWS(document$LWS, key$LWS);
|
|
6690
6480
|
const html$LWS = lwsInternalPolicy$LWS.createHTML(value$LWS, key$LWS, ContentType$LWS.HTML);
|
|
6481
|
+
// Ensure that the created html snippet is secure (no mXSS)
|
|
6482
|
+
if (isGaterEnabledFeature$LWS('changesSince.260')) {
|
|
6483
|
+
if (isInherentlyUnsecure$2$LWS(html$LWS)) {
|
|
6484
|
+
throw new LockerSecurityError$LWS(`Cannot set 'outerHTML' using an unsecure ${toSafeTemplateStringValue$LWS(value$LWS)}.`);
|
|
6485
|
+
}
|
|
6486
|
+
}
|
|
6691
6487
|
ReflectApply$LWS$1(originalOuterHTMLSetter$LWS, this, [html$LWS]);
|
|
6692
6488
|
}];
|
|
6693
6489
|
};
|
|
@@ -7765,9 +7561,7 @@ function createBlockedAttributeDistortionFactoryInitializer$LWS(Ctor$LWS, ctorNa
|
|
|
7765
7561
|
function createGetThrowerFactoryInitializer$LWS(proto$LWS, key$LWS) {
|
|
7766
7562
|
const originalGet$LWS = ObjectLookupOwnGetter$LWS$1(proto$LWS, key$LWS);
|
|
7767
7563
|
const keyAsString$LWS = toSafeTemplateStringValue$LWS(key$LWS);
|
|
7768
|
-
const distortionEntry$LWS = [originalGet$LWS,
|
|
7769
|
-
// eslint-disable-next-line prefer-arrow-callback
|
|
7770
|
-
function get$LWS() {
|
|
7564
|
+
const distortionEntry$LWS = [originalGet$LWS, function get$LWS() {
|
|
7771
7565
|
throw new LockerSecurityError$LWS(`Cannot access ${keyAsString$LWS}.`);
|
|
7772
7566
|
}];
|
|
7773
7567
|
function getThrowerDistortionFactory$LWS() {
|
|
@@ -7780,9 +7574,7 @@ function createGetThrowerFactoryInitializer$LWS(proto$LWS, key$LWS) {
|
|
|
7780
7574
|
function createSetThrowerFactoryInitializer$LWS(proto$LWS, key$LWS) {
|
|
7781
7575
|
const originalSet$LWS = ObjectLookupOwnSetter$LWS(proto$LWS, key$LWS);
|
|
7782
7576
|
const keyAsString$LWS = toSafeTemplateStringValue$LWS(key$LWS);
|
|
7783
|
-
const distortionEntry$LWS = [originalSet$LWS,
|
|
7784
|
-
// eslint-disable-next-line prefer-arrow-callback
|
|
7785
|
-
function set$LWS() {
|
|
7577
|
+
const distortionEntry$LWS = [originalSet$LWS, function set$LWS() {
|
|
7786
7578
|
throw new LockerSecurityError$LWS(`Cannot access ${keyAsString$LWS}.`);
|
|
7787
7579
|
}];
|
|
7788
7580
|
function setThrowerDistortionFactory$LWS() {
|
|
@@ -7797,9 +7589,7 @@ function createValueThrowerFactoryInitializer$LWS(proto$LWS, key$LWS) {
|
|
|
7797
7589
|
[key$LWS]: originalValue$LWS
|
|
7798
7590
|
} = proto$LWS;
|
|
7799
7591
|
const keyAsString$LWS = toSafeTemplateStringValue$LWS(key$LWS);
|
|
7800
|
-
const distortionEntry$LWS = [originalValue$LWS,
|
|
7801
|
-
// eslint-disable-next-line prefer-arrow-callback
|
|
7802
|
-
function value$LWS() {
|
|
7592
|
+
const distortionEntry$LWS = [originalValue$LWS, function value$LWS() {
|
|
7803
7593
|
throw new LockerSecurityError$LWS(`Cannot access ${keyAsString$LWS}.`);
|
|
7804
7594
|
}];
|
|
7805
7595
|
function valueThrowerDistortionFactory$LWS() {
|
|
@@ -8565,6 +8355,32 @@ function initDistortionPerformanceMarkCtor$LWS({
|
|
|
8565
8355
|
return distortionEntry$LWS;
|
|
8566
8356
|
};
|
|
8567
8357
|
}
|
|
8358
|
+
function initDistortionPromiseTry$LWS({
|
|
8359
|
+
globalObject: {
|
|
8360
|
+
Promise: Promise$LWS
|
|
8361
|
+
}
|
|
8362
|
+
}) {
|
|
8363
|
+
const originalPromiseTry$LWS = Promise$LWS == null ? void 0 : Promise$LWS.try;
|
|
8364
|
+
if (typeof originalPromiseTry$LWS !== 'function') {
|
|
8365
|
+
return noop$LWS$1;
|
|
8366
|
+
}
|
|
8367
|
+
const distortionEntry$LWS = [originalPromiseTry$LWS, function (...args$LWS) {
|
|
8368
|
+
const {
|
|
8369
|
+
0: callback$LWS
|
|
8370
|
+
} = args$LWS;
|
|
8371
|
+
if (typeof callback$LWS === 'function') {
|
|
8372
|
+
if (isGaterEnabledFeature$LWS('changesSince.260') &&
|
|
8373
|
+
// @ts-ignore callback and eval have different type defs, but that's ok for this condition
|
|
8374
|
+
callback$LWS === eval) {
|
|
8375
|
+
throw new LockerSecurityError$LWS('Cannot pass unsafe eval reference.');
|
|
8376
|
+
}
|
|
8377
|
+
}
|
|
8378
|
+
return ReflectApply$LWS$1(originalPromiseTry$LWS, this, args$LWS);
|
|
8379
|
+
}];
|
|
8380
|
+
return function distortionPromiseTry$LWS() {
|
|
8381
|
+
return distortionEntry$LWS;
|
|
8382
|
+
};
|
|
8383
|
+
}
|
|
8568
8384
|
function initDistortionRangeCreateContextualFragment$LWS({
|
|
8569
8385
|
document: document$LWS,
|
|
8570
8386
|
globalObject: {
|
|
@@ -9723,6 +9539,126 @@ function initDistortionURLCreateObjectURL$LWS({
|
|
|
9723
9539
|
}];
|
|
9724
9540
|
};
|
|
9725
9541
|
}
|
|
9542
|
+
|
|
9543
|
+
/**
|
|
9544
|
+
* Recursively checks if an object contains a reference to the eval function
|
|
9545
|
+
* @param obj - The object to check
|
|
9546
|
+
* @param originalEval - The original eval function reference
|
|
9547
|
+
* @returns true if eval is found, false otherwise
|
|
9548
|
+
*/
|
|
9549
|
+
function containsEval$LWS(obj$LWS, originalEval$LWS) {
|
|
9550
|
+
if (obj$LWS === originalEval$LWS) {
|
|
9551
|
+
return true;
|
|
9552
|
+
}
|
|
9553
|
+
if (typeof obj$LWS === 'object' && obj$LWS !== null) {
|
|
9554
|
+
for (const key$LWS in obj$LWS) {
|
|
9555
|
+
if (ObjectHasOwn$LWS$1(obj$LWS, key$LWS)) {
|
|
9556
|
+
if (containsEval$LWS(obj$LWS[key$LWS], originalEval$LWS)) {
|
|
9557
|
+
return true;
|
|
9558
|
+
}
|
|
9559
|
+
}
|
|
9560
|
+
}
|
|
9561
|
+
}
|
|
9562
|
+
return false;
|
|
9563
|
+
}
|
|
9564
|
+
function initDistortionWebAssemblyInstanceExportsGetter$LWS({
|
|
9565
|
+
globalObject: {
|
|
9566
|
+
WebAssembly: {
|
|
9567
|
+
Instance: WebAssemblyInstance$LWS
|
|
9568
|
+
},
|
|
9569
|
+
eval: originalEval$LWS
|
|
9570
|
+
}
|
|
9571
|
+
}) {
|
|
9572
|
+
const originalExportsGetter$LWS = ObjectLookupOwnGetter$LWS$1(WebAssemblyInstance$LWS.prototype, 'exports');
|
|
9573
|
+
const distortionEntry$LWS = [originalExportsGetter$LWS, function exportsGetter$LWS() {
|
|
9574
|
+
const exportsGetterThis$LWS = this;
|
|
9575
|
+
const actualExportsDescriptors$LWS = ObjectGetOwnPropertyDescriptors$LWS(ReflectApply$LWS$1(originalExportsGetter$LWS, this, []));
|
|
9576
|
+
const actualExportsKeys$LWS = ObjectKeys$LWS$1(actualExportsDescriptors$LWS);
|
|
9577
|
+
const wrappedExports$LWS = {
|
|
9578
|
+
__proto__: null
|
|
9579
|
+
};
|
|
9580
|
+
for (const key$LWS of actualExportsKeys$LWS) {
|
|
9581
|
+
const descriptor$LWS = actualExportsDescriptors$LWS[key$LWS];
|
|
9582
|
+
const {
|
|
9583
|
+
value: originalValue$LWS
|
|
9584
|
+
} = descriptor$LWS;
|
|
9585
|
+
if (typeof originalValue$LWS === 'function') {
|
|
9586
|
+
// These descriptors are writable: false, configurable: false, so we need to
|
|
9587
|
+
// create a new descriptor for the safely wrapped function.
|
|
9588
|
+
const safeDescriptor$LWS = _extends$LWS({
|
|
9589
|
+
__proto__: null
|
|
9590
|
+
}, descriptor$LWS);
|
|
9591
|
+
safeDescriptor$LWS.value = function (...args$LWS) {
|
|
9592
|
+
if (isGaterEnabledFeature$LWS('changesSince.260') && containsEval$LWS(args$LWS, originalEval$LWS)) {
|
|
9593
|
+
throw new LockerSecurityError$LWS(`Cannot call WebAssembly.Instance exported function with eval.`);
|
|
9594
|
+
}
|
|
9595
|
+
return ReflectApply$LWS$1(originalValue$LWS, exportsGetterThis$LWS, args$LWS);
|
|
9596
|
+
};
|
|
9597
|
+
ReflectDefineProperty$LWS$1(wrappedExports$LWS, key$LWS, safeDescriptor$LWS);
|
|
9598
|
+
} else {
|
|
9599
|
+
ReflectDefineProperty$LWS$1(wrappedExports$LWS, key$LWS, descriptor$LWS);
|
|
9600
|
+
}
|
|
9601
|
+
}
|
|
9602
|
+
return wrappedExports$LWS;
|
|
9603
|
+
}];
|
|
9604
|
+
return function distortionWebAssemblyInstanceExportsGetter$LWS() {
|
|
9605
|
+
return distortionEntry$LWS;
|
|
9606
|
+
};
|
|
9607
|
+
}
|
|
9608
|
+
function initDistortionWebAssemblyInstantiate$LWS({
|
|
9609
|
+
globalObject: {
|
|
9610
|
+
WebAssembly: {
|
|
9611
|
+
instantiate: originalInstantiate$LWS
|
|
9612
|
+
},
|
|
9613
|
+
eval: originalEval$LWS
|
|
9614
|
+
}
|
|
9615
|
+
}) {
|
|
9616
|
+
return function distortionWebAssemblyInstantiate$LWS() {
|
|
9617
|
+
return [originalInstantiate$LWS, function instantiate$LWS(...args$LWS) {
|
|
9618
|
+
const {
|
|
9619
|
+
length: length$LWS
|
|
9620
|
+
} = args$LWS;
|
|
9621
|
+
if (length$LWS > 1) {
|
|
9622
|
+
const {
|
|
9623
|
+
1: importObject$LWS
|
|
9624
|
+
} = args$LWS;
|
|
9625
|
+
if (importObject$LWS !== undefined && importObject$LWS !== null) {
|
|
9626
|
+
if (isGaterEnabledFeature$LWS('changesSince.260') && containsEval$LWS(importObject$LWS, originalEval$LWS)) {
|
|
9627
|
+
throw new LockerSecurityError$LWS('WebAssembly.instantiate: Import object contains eval, which is not allowed.');
|
|
9628
|
+
}
|
|
9629
|
+
}
|
|
9630
|
+
}
|
|
9631
|
+
return ReflectApply$LWS$1(originalInstantiate$LWS, this, args$LWS);
|
|
9632
|
+
}];
|
|
9633
|
+
};
|
|
9634
|
+
}
|
|
9635
|
+
function initDistortionWebAssemblyInstantiateStreaming$LWS({
|
|
9636
|
+
globalObject: {
|
|
9637
|
+
WebAssembly: {
|
|
9638
|
+
instantiateStreaming: originalInstantiateStreaming$LWS
|
|
9639
|
+
},
|
|
9640
|
+
eval: originalEval$LWS
|
|
9641
|
+
}
|
|
9642
|
+
}) {
|
|
9643
|
+
return function distortionWebAssemblyInstantiateStreaming$LWS() {
|
|
9644
|
+
return [originalInstantiateStreaming$LWS, function instantiateStreaming$LWS(...args$LWS) {
|
|
9645
|
+
const {
|
|
9646
|
+
length: length$LWS
|
|
9647
|
+
} = args$LWS;
|
|
9648
|
+
if (length$LWS > 1) {
|
|
9649
|
+
const {
|
|
9650
|
+
1: importObject$LWS
|
|
9651
|
+
} = args$LWS;
|
|
9652
|
+
if (importObject$LWS !== undefined && importObject$LWS !== null) {
|
|
9653
|
+
if (isGaterEnabledFeature$LWS('changesSince.260') && containsEval$LWS(importObject$LWS, originalEval$LWS)) {
|
|
9654
|
+
throw new LockerSecurityError$LWS('WebAssembly.instantiateStreaming: Import object contains eval, which is not allowed.');
|
|
9655
|
+
}
|
|
9656
|
+
}
|
|
9657
|
+
}
|
|
9658
|
+
return ReflectApply$LWS$1(originalInstantiateStreaming$LWS, this, args$LWS);
|
|
9659
|
+
}];
|
|
9660
|
+
};
|
|
9661
|
+
}
|
|
9726
9662
|
function initDistortionWindowFetch$LWS({
|
|
9727
9663
|
globalObject: {
|
|
9728
9664
|
fetch: originalFetch$LWS
|
|
@@ -9988,9 +9924,7 @@ function initDistortionWindowFramesGetter$LWS({
|
|
|
9988
9924
|
return new ProxyCtor$LWS(shadowFrames$LWS, shadowFramesHandler$LWS);
|
|
9989
9925
|
};
|
|
9990
9926
|
let framesProxy$LWS;
|
|
9991
|
-
const distortionEntry$LWS = [originalWindowFramesGetter$LWS,
|
|
9992
|
-
// eslint-disable-next-line prefer-arrow-callback
|
|
9993
|
-
function frames$LWS() {
|
|
9927
|
+
const distortionEntry$LWS = [originalWindowFramesGetter$LWS, function frames$LWS() {
|
|
9994
9928
|
if (framesProxy$LWS === undefined) {
|
|
9995
9929
|
framesProxy$LWS = createFramesProxy$LWS();
|
|
9996
9930
|
}
|
|
@@ -10423,6 +10357,8 @@ initDistortionNodeRemoveChild$LWS, initDistortionNodeReplaceChild$LWS,
|
|
|
10423
10357
|
initDistortionPerformanceMark$LWS, initDistortionPerformanceMeasure$LWS,
|
|
10424
10358
|
// PerformanceMark
|
|
10425
10359
|
initDistortionPerformanceMarkCtor$LWS,
|
|
10360
|
+
// Promise
|
|
10361
|
+
initDistortionPromiseTry$LWS,
|
|
10426
10362
|
// Notification
|
|
10427
10363
|
initDistortionNotificationCtor$LWS,
|
|
10428
10364
|
// Range
|
|
@@ -10502,6 +10438,8 @@ initDistortionSVGScriptElementHrefGetter$LWS, initDistortionSVGScriptElementHref
|
|
|
10502
10438
|
initDistortionSVGSetElementAttributeNameAttribute$LWS, initDistortionSVGElementOnsecuritypolicyviolation$LWS,
|
|
10503
10439
|
// URL
|
|
10504
10440
|
initDistortionURLCreateObjectURL$LWS,
|
|
10441
|
+
// WebAssembly
|
|
10442
|
+
initDistortionWebAssemblyInstanceExportsGetter$LWS, initDistortionWebAssemblyInstantiate$LWS, initDistortionWebAssemblyInstantiateStreaming$LWS,
|
|
10505
10443
|
// Window
|
|
10506
10444
|
initDistortionWindowOnrejectionhandled$LWS, initDistortionWindowOnsecuritypolicyviolation$LWS, initDistortionWindowOnstorage$LWS, initDistortionWindowOnunhandledrejection$LWS, initDistortionWindowSetInterval$LWS, initDistortionWindowSetTimeout$LWS,
|
|
10507
10445
|
// XHR
|
|
@@ -10533,10 +10471,9 @@ const HTMLScriptElementProtoBlockedProperties$LWS = ['nonce'];
|
|
|
10533
10471
|
const SVGElementBlockedAttributes$LWS = ['nonce'];
|
|
10534
10472
|
const SVGElementProtoBlockedProperties$LWS = ['nonce'];
|
|
10535
10473
|
const UIEventProtoBlockedProperties$LWS = ['rangeParent'];
|
|
10536
|
-
const WebAssemblyBlockedProperties$LWS = ['CompileError', 'Exception', 'Global', 'Instance', 'instantiate', 'instantiateStreaming', 'LinkError', 'Memory', 'Module', 'RuntimeError', 'Table', 'Tag', 'compile', 'compileStreaming', 'validate'];
|
|
10537
10474
|
const WindowBlockedProperties$LWS = ['find', 'requestFileSystem', 'webkitRequestFileSystem'];
|
|
10538
10475
|
const XSLTProcessorProtoBlockedProperties$LWS = ['transformToDocument', 'transformToFragment'];
|
|
10539
|
-
/*! version: 0.
|
|
10476
|
+
/*! version: 0.26.2 */
|
|
10540
10477
|
|
|
10541
10478
|
/*!
|
|
10542
10479
|
* Copyright (C) 2019 salesforce.com, inc.
|
|
@@ -10685,7 +10622,6 @@ function createDistortionToggleSwitchWrapper$LWS(sandboxKey$LWS, toggleSwitchNam
|
|
|
10685
10622
|
// descriptors already set. Once that is done, there is no way to affect the behavior of a distortion
|
|
10686
10623
|
// during runtime without wrapping the distortion function value with a function that side channel communicates
|
|
10687
10624
|
// with the exposed flags interface.
|
|
10688
|
-
// eslint-disable-next-line @typescript-eslint/no-loop-func
|
|
10689
10625
|
return function (...args$LWS) {
|
|
10690
10626
|
var _root$LWS$namespaces$LWS;
|
|
10691
10627
|
const {
|
|
@@ -10734,7 +10670,7 @@ function createDistortionEntries$LWS(record$LWS, factories$LWS) {
|
|
|
10734
10670
|
} = entry$LWS;
|
|
10735
10671
|
if (typeof originalValue$LWS === 'function') {
|
|
10736
10672
|
const proxyMaskedFunctionDistortion$LWS = proxyMaskFunctionDistortion$LWS(record$LWS, factory$LWS, distortedValue$LWS, originalValue$LWS);
|
|
10737
|
-
const toggleSwitchName$LWS = ENABLE_DISTORTION_TOGGLE_SWITCHES$LWS && (
|
|
10673
|
+
const toggleSwitchName$LWS = ENABLE_DISTORTION_TOGGLE_SWITCHES$LWS && (/* istanbul ignore next: optional chaining and nullish coalescing results in an expansion that contains an unreachable "void 0" branch for every occurrence of the operator */distortionFactoryToToggleSwitch$LWS == null ? void 0 : distortionFactoryToToggleSwitch$LWS.get(factory$LWS));
|
|
10738
10674
|
let distortionToggleSwitchWrapperOrProxyMaskedFunction$LWS = proxyMaskedFunctionDistortion$LWS;
|
|
10739
10675
|
if (ENABLE_DISTORTION_TOGGLE_SWITCHES$LWS && toggleSwitchName$LWS) {
|
|
10740
10676
|
distortionToggleSwitchWrapperOrProxyMaskedFunction$LWS = createDistortionToggleSwitchWrapper$LWS(record$LWS.key, toggleSwitchName$LWS, proxyMaskedFunctionDistortion$LWS, originalValue$LWS);
|
|
@@ -10818,7 +10754,6 @@ function getDistortionFactories$LWS(record$LWS) {
|
|
|
10818
10754
|
addBlockedPropertyDistortionFactoryInitializers$LWS(record$LWS, HTMLScriptElement$LWS.prototype, HTMLScriptElementProtoBlockedProperties$LWS, initializers$LWS);
|
|
10819
10755
|
addBlockedPropertyDistortionFactoryInitializers$LWS(record$LWS, SVGElement$LWS.prototype, SVGElementProtoBlockedProperties$LWS, initializers$LWS);
|
|
10820
10756
|
addBlockedPropertyDistortionFactoryInitializers$LWS(record$LWS, UIEvent$LWS.prototype, UIEventProtoBlockedProperties$LWS, initializers$LWS);
|
|
10821
|
-
addBlockedPropertyDistortionFactoryInitializers$LWS(record$LWS, WebAssembly, WebAssemblyBlockedProperties$LWS, initializers$LWS);
|
|
10822
10757
|
addBlockedPropertyDistortionFactoryInitializers$LWS(record$LWS, globalObject$LWS, WindowBlockedProperties$LWS, initializers$LWS);
|
|
10823
10758
|
// istanbul ignore else: this is a safety precaution that is unreachable via tests
|
|
10824
10759
|
if (typeof XSLTProcessor$LWS === 'function') {
|
|
@@ -15587,7 +15522,6 @@ const EMPTY_EVAL_HELPERS$LWS = {
|
|
|
15587
15522
|
const EVAL_HELPERS_SOURCE_TEXT$LWS = `'use strict';
|
|
15588
15523
|
${SANDBOX_EVAL_CONTEXT_NAME$LWS}(${function redHelpersFactory$LWS(baseGenToAsync$LWS, forAwaitOf$LWS, loadScript$LWS, loadStyle$LWS) {
|
|
15589
15524
|
const ArrayCtor$LWS = Array;
|
|
15590
|
-
// eslint-disable-next-line @typescript-eslint/no-shadow, no-shadow
|
|
15591
15525
|
const {
|
|
15592
15526
|
iterator: SymbolIterator$LWS
|
|
15593
15527
|
} = Symbol;
|
|
@@ -15596,8 +15530,9 @@ const EVAL_HELPERS_SOURCE_TEXT$LWS = `'use strict';
|
|
|
15596
15530
|
} = ArrayCtor$LWS.prototype;
|
|
15597
15531
|
// The Generator prototype object is %GeneratorFunction.prototype.prototype%.
|
|
15598
15532
|
// https://tc39.es/ecma262/#sec-generatorfunction.prototype.prototype
|
|
15599
|
-
|
|
15600
|
-
|
|
15533
|
+
const GeneratorProto$LWS = function* () {
|
|
15534
|
+
// Intentionally Empty...
|
|
15535
|
+
}.constructor.prototype.prototype;
|
|
15601
15536
|
const {
|
|
15602
15537
|
next: GeneratorProtoNext$LWS,
|
|
15603
15538
|
throw: GeneratorProtoThrow$LWS
|
|
@@ -15607,7 +15542,6 @@ const EVAL_HELPERS_SOURCE_TEXT$LWS = `'use strict';
|
|
|
15607
15542
|
freeze: ObjectFreeze$LWS
|
|
15608
15543
|
} = Object;
|
|
15609
15544
|
const {
|
|
15610
|
-
// eslint-disable-next-line @typescript-eslint/no-shadow, no-shadow
|
|
15611
15545
|
apply: ReflectApply$LWS,
|
|
15612
15546
|
get: ReflectGet$LWS,
|
|
15613
15547
|
getPrototypeOf: ReflectGetPrototypeOf$LWS,
|
|
@@ -15644,10 +15578,10 @@ const EVAL_HELPERS_SOURCE_TEXT$LWS = `'use strict';
|
|
|
15644
15578
|
length: length$LWS
|
|
15645
15579
|
} = bindings$LWS; i$LWS < length$LWS; i$LWS += 1) {
|
|
15646
15580
|
try {
|
|
15647
|
-
// eslint-disable-next-line
|
|
15581
|
+
// eslint-disable-next-line no-unused-expressions
|
|
15648
15582
|
bindings$LWS[i$LWS];
|
|
15649
15583
|
// eslint-disable-next-line no-empty
|
|
15650
|
-
} catch (
|
|
15584
|
+
} catch (_unused0$LWS) {}
|
|
15651
15585
|
}
|
|
15652
15586
|
return spreadable$LWS(args$LWS);
|
|
15653
15587
|
};
|
|
@@ -15889,7 +15823,7 @@ function toSourceText$LWS(value$LWS, sourceType$LWS) {
|
|
|
15889
15823
|
// tools from mistaking the regexp or the replacement string for an
|
|
15890
15824
|
// actual source mapping URL.
|
|
15891
15825
|
/\/\/# sandbox(?=MappingURL=.*?\s*$)/, '//# source']);
|
|
15892
|
-
sourceText$LWS = `\n//# LWS Version = "0.
|
|
15826
|
+
sourceText$LWS = `\n//# LWS Version = "0.26.2"\n${sourceText$LWS}`;
|
|
15893
15827
|
return sourceType$LWS === 1 /* SourceType.Module */ && indexOfPragma$LWS(sourceText$LWS, 'use strict') === -1 ?
|
|
15894
15828
|
// Append "'use strict'" to the extracted function body so it is
|
|
15895
15829
|
// evaluated in strict mode.
|
|
@@ -16016,7 +15950,7 @@ function createVirtualEnvironment$LWS(record$LWS) {
|
|
|
16016
15950
|
if (!ObjectHasOwn$LWS$1(originalTarget$LWS, 'location')) {
|
|
16017
15951
|
return originalTarget$LWS;
|
|
16018
15952
|
}
|
|
16019
|
-
} catch (
|
|
15953
|
+
} catch (_unused1$LWS) {
|
|
16020
15954
|
// Likely an opaque object of a cross-origin window.
|
|
16021
15955
|
// istanbul ignore next: an access of property iframe.contentWindow.location.href on an opaque window, that should reach this catch clause IS tested (see packages/integration-karma/test/distortions/HTMLIFrameElement/untrusted/snippets.js, "doesNotThrowOnCreationOrAccessOfCrossOriginIframeContentWindow"), but reported as uncovered
|
|
16022
15956
|
return originalTarget$LWS;
|
|
@@ -16032,7 +15966,7 @@ function createVirtualEnvironment$LWS(record$LWS) {
|
|
|
16032
15966
|
// not a window object, or if it is an opaque cross-origin window.
|
|
16033
15967
|
originalTargetDocument$LWS = ReflectApply$LWS$1(WindowDocumentGetter$LWS, originalTarget$LWS, []);
|
|
16034
15968
|
originalTargetWindow$LWS = originalTarget$LWS;
|
|
16035
|
-
} catch (
|
|
15969
|
+
} catch (_unused35$LWS) {
|
|
16036
15970
|
try {
|
|
16037
15971
|
// istanbul ignore else: current tests have no way of expressing a state that would cause this condition to evaluate false
|
|
16038
15972
|
if (ReflectApply$LWS$1(WindowLocationGetter$LWS, originalTarget$LWS, [])) {
|
|
@@ -16044,7 +15978,7 @@ function createVirtualEnvironment$LWS(record$LWS) {
|
|
|
16044
15978
|
return originalTarget$LWS;
|
|
16045
15979
|
}
|
|
16046
15980
|
// eslint-disable-next-line no-empty
|
|
16047
|
-
} catch (
|
|
15981
|
+
} catch (_unused36$LWS) {}
|
|
16048
15982
|
}
|
|
16049
15983
|
// Check if originalTarget is a document and get its defaultView.
|
|
16050
15984
|
} else if ('defaultView' in originalTarget$LWS) {
|
|
@@ -16058,7 +15992,7 @@ function createVirtualEnvironment$LWS(record$LWS) {
|
|
|
16058
15992
|
// This will throw if `originalTarget` is not a document object.
|
|
16059
15993
|
defaultView$LWS = ReflectApply$LWS$1(DocumentProtoDefaultViewGetter$LWS, originalTarget$LWS, []);
|
|
16060
15994
|
// eslint-disable-next-line no-empty
|
|
16061
|
-
} catch (
|
|
15995
|
+
} catch (_unused37$LWS) {}
|
|
16062
15996
|
if (defaultView$LWS) {
|
|
16063
15997
|
originalTargetDocument$LWS = originalTarget$LWS;
|
|
16064
15998
|
originalTargetWindow$LWS = defaultView$LWS;
|
|
@@ -16317,7 +16251,7 @@ function createSecondaryWindowSandboxRecord$LWS({
|
|
|
16317
16251
|
type: type$LWS
|
|
16318
16252
|
}, _root$LWS);
|
|
16319
16253
|
}
|
|
16320
|
-
} catch (
|
|
16254
|
+
} catch (_unused38$LWS) {
|
|
16321
16255
|
// istanbul ignore next: this is a safety precaution that is unreachable via tests
|
|
16322
16256
|
createOpaqueSecondaryWindowSandboxRecord$LWS({
|
|
16323
16257
|
globalObject: globalObject$LWS,
|
|
@@ -16356,7 +16290,7 @@ function createSecondaryWindowSandboxRecord$LWS({
|
|
|
16356
16290
|
ReflectApply$LWS$1(EventTargetProtoAddEventListener$LWS, globalObject$LWS, ['DOMContentLoaded', onDOMContentLoadedOrWindowLoad$LWS, true]);
|
|
16357
16291
|
// istanbul ignore next: currently unreachable via tests
|
|
16358
16292
|
ReflectApply$LWS$1(EventTargetProtoAddEventListener$LWS, globalObject$LWS, ['unload', onWindowUnload$LWS, true]);
|
|
16359
|
-
} catch (
|
|
16293
|
+
} catch (_unused39$LWS) {
|
|
16360
16294
|
// istanbul ignore next: this is a safety precaution that is unreachable via tests
|
|
16361
16295
|
createOpaqueSecondaryWindowSandboxRecord$LWS({
|
|
16362
16296
|
globalObject: globalObject$LWS,
|
|
@@ -16612,7 +16546,7 @@ function wrapPlatformResourceLoader$LWS(dep$LWS, key$LWS) {
|
|
|
16612
16546
|
depRegistry$LWS.set(dep$LWS, secureDep$LWS);
|
|
16613
16547
|
return secureDep$LWS;
|
|
16614
16548
|
}
|
|
16615
|
-
/*! version: 0.
|
|
16549
|
+
/*! version: 0.26.2 */
|
|
16616
16550
|
|
|
16617
16551
|
export { $LWS, CORE_SANDBOX_KEY$LWS as CORE_SANDBOX_KEY, createRootWindowSandboxRecord$LWS as createRootWindowSandboxRecord, evaluateFunction$LWS as evaluateFunction, evaluateInCoreSandbox$LWS as evaluateInCoreSandbox, evaluateInSandbox$LWS as evaluateInSandbox, trusted, wrapDependency$LWS as wrapDependency };
|
|
16618
16552
|
//# sourceMappingURL=lockerSandbox.js.map
|