dompurify 3.1.4 → 3.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/purify.cjs.js +4 -61
- package/dist/purify.cjs.js.map +1 -1
- package/dist/purify.es.mjs +4 -61
- package/dist/purify.es.mjs.map +1 -1
- package/dist/purify.js +4 -61
- package/dist/purify.js.map +1 -1
- package/dist/purify.min.js +2 -2
- package/dist/purify.min.js.map +1 -1
- package/package.json +1 -1
package/dist/purify.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @license DOMPurify 3.1.
|
|
1
|
+
/*! @license DOMPurify 3.1.5 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.1.5/LICENSE */
|
|
2
2
|
|
|
3
3
|
(function (global, factory) {
|
|
4
4
|
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
|
|
@@ -54,10 +54,6 @@
|
|
|
54
54
|
const objectHasOwnProperty = unapply(Object.prototype.hasOwnProperty);
|
|
55
55
|
const regExpTest = unapply(RegExp.prototype.test);
|
|
56
56
|
const typeErrorCreate = unconstruct(TypeError);
|
|
57
|
-
function numberIsNaN(x) {
|
|
58
|
-
// eslint-disable-next-line unicorn/prefer-number-properties
|
|
59
|
-
return typeof x === 'number' && isNaN(x);
|
|
60
|
-
}
|
|
61
57
|
|
|
62
58
|
/**
|
|
63
59
|
* Creates a new function that calls the given function with a specified thisArg and arguments.
|
|
@@ -310,7 +306,7 @@
|
|
|
310
306
|
* Version label, exposed for easier checks
|
|
311
307
|
* if DOMPurify is up to date or not
|
|
312
308
|
*/
|
|
313
|
-
DOMPurify.version = '3.1.
|
|
309
|
+
DOMPurify.version = '3.1.5';
|
|
314
310
|
|
|
315
311
|
/**
|
|
316
312
|
* Array of elements that DOMPurify removed during sanitation.
|
|
@@ -543,9 +539,6 @@
|
|
|
543
539
|
/* Keep a reference to config to pass to hooks */
|
|
544
540
|
let CONFIG = null;
|
|
545
541
|
|
|
546
|
-
/* Specify the maximum element nesting depth to prevent mXSS */
|
|
547
|
-
const MAX_NESTING_DEPTH = 255;
|
|
548
|
-
|
|
549
542
|
/* Ideally, do not touch anything below this line */
|
|
550
543
|
/* ______________________________________________ */
|
|
551
544
|
|
|
@@ -956,11 +949,7 @@
|
|
|
956
949
|
* @return {Boolean} true if clobbered, false if safe
|
|
957
950
|
*/
|
|
958
951
|
const _isClobbered = function _isClobbered(elm) {
|
|
959
|
-
return elm instanceof HTMLFormElement && (
|
|
960
|
-
// eslint-disable-next-line unicorn/no-typeof-undefined
|
|
961
|
-
typeof elm.__depth !== 'undefined' && typeof elm.__depth !== 'number' ||
|
|
962
|
-
// eslint-disable-next-line unicorn/no-typeof-undefined
|
|
963
|
-
typeof elm.__removalCount !== 'undefined' && typeof elm.__removalCount !== 'number' || typeof elm.nodeName !== 'string' || typeof elm.textContent !== 'string' || typeof elm.removeChild !== 'function' || !(elm.attributes instanceof NamedNodeMap) || typeof elm.removeAttribute !== 'function' || typeof elm.setAttribute !== 'function' || typeof elm.namespaceURI !== 'string' || typeof elm.insertBefore !== 'function' || typeof elm.hasChildNodes !== 'function');
|
|
952
|
+
return elm instanceof HTMLFormElement && (typeof elm.nodeName !== 'string' || typeof elm.textContent !== 'string' || typeof elm.removeChild !== 'function' || !(elm.attributes instanceof NamedNodeMap) || typeof elm.removeAttribute !== 'function' || typeof elm.setAttribute !== 'function' || typeof elm.namespaceURI !== 'string' || typeof elm.insertBefore !== 'function' || typeof elm.hasChildNodes !== 'function');
|
|
964
953
|
};
|
|
965
954
|
|
|
966
955
|
/**
|
|
@@ -1111,7 +1100,7 @@
|
|
|
1111
1100
|
// eslint-disable-next-line complexity
|
|
1112
1101
|
const _isValidAttribute = function _isValidAttribute(lcTag, lcName, value) {
|
|
1113
1102
|
/* Make sure attribute cannot clobber */
|
|
1114
|
-
if (SANITIZE_DOM && (lcName === 'id' || lcName === 'name') && (value in document || value in formElement
|
|
1103
|
+
if (SANITIZE_DOM && (lcName === 'id' || lcName === 'name') && (value in document || value in formElement)) {
|
|
1115
1104
|
return false;
|
|
1116
1105
|
}
|
|
1117
1106
|
|
|
@@ -1302,32 +1291,9 @@
|
|
|
1302
1291
|
if (_sanitizeElements(shadowNode)) {
|
|
1303
1292
|
continue;
|
|
1304
1293
|
}
|
|
1305
|
-
const parentNode = getParentNode(shadowNode);
|
|
1306
|
-
|
|
1307
|
-
/* Set the nesting depth of an element */
|
|
1308
|
-
if (shadowNode.nodeType === NODE_TYPE.element) {
|
|
1309
|
-
if (parentNode && parentNode.__depth) {
|
|
1310
|
-
/*
|
|
1311
|
-
We want the depth of the node in the original tree, which can
|
|
1312
|
-
change when it's removed from its parent.
|
|
1313
|
-
*/
|
|
1314
|
-
shadowNode.__depth = (shadowNode.__removalCount || 0) + parentNode.__depth + 1;
|
|
1315
|
-
} else {
|
|
1316
|
-
shadowNode.__depth = 1;
|
|
1317
|
-
}
|
|
1318
|
-
}
|
|
1319
|
-
|
|
1320
|
-
/*
|
|
1321
|
-
* Remove an element if nested too deeply to avoid mXSS
|
|
1322
|
-
* or if the __depth might have been tampered with
|
|
1323
|
-
*/
|
|
1324
|
-
if (shadowNode.__depth >= MAX_NESTING_DEPTH || shadowNode.__depth < 0 || numberIsNaN(shadowNode.__depth)) {
|
|
1325
|
-
_forceRemove(shadowNode);
|
|
1326
|
-
}
|
|
1327
1294
|
|
|
1328
1295
|
/* Deep shadow DOM detected */
|
|
1329
1296
|
if (shadowNode.content instanceof DocumentFragment) {
|
|
1330
|
-
shadowNode.content.__depth = shadowNode.__depth;
|
|
1331
1297
|
_sanitizeShadowDOM(shadowNode.content);
|
|
1332
1298
|
}
|
|
1333
1299
|
|
|
@@ -1443,32 +1409,9 @@
|
|
|
1443
1409
|
if (_sanitizeElements(currentNode)) {
|
|
1444
1410
|
continue;
|
|
1445
1411
|
}
|
|
1446
|
-
const parentNode = getParentNode(currentNode);
|
|
1447
|
-
|
|
1448
|
-
/* Set the nesting depth of an element */
|
|
1449
|
-
if (currentNode.nodeType === NODE_TYPE.element) {
|
|
1450
|
-
if (parentNode && parentNode.__depth) {
|
|
1451
|
-
/*
|
|
1452
|
-
We want the depth of the node in the original tree, which can
|
|
1453
|
-
change when it's removed from its parent.
|
|
1454
|
-
*/
|
|
1455
|
-
currentNode.__depth = (currentNode.__removalCount || 0) + parentNode.__depth + 1;
|
|
1456
|
-
} else {
|
|
1457
|
-
currentNode.__depth = 1;
|
|
1458
|
-
}
|
|
1459
|
-
}
|
|
1460
|
-
|
|
1461
|
-
/*
|
|
1462
|
-
* Remove an element if nested too deeply to avoid mXSS
|
|
1463
|
-
* or if the __depth might have been tampered with
|
|
1464
|
-
*/
|
|
1465
|
-
if (currentNode.__depth >= MAX_NESTING_DEPTH || currentNode.__depth < 0 || numberIsNaN(currentNode.__depth)) {
|
|
1466
|
-
_forceRemove(currentNode);
|
|
1467
|
-
}
|
|
1468
1412
|
|
|
1469
1413
|
/* Shadow DOM detected, sanitize it */
|
|
1470
1414
|
if (currentNode.content instanceof DocumentFragment) {
|
|
1471
|
-
currentNode.content.__depth = currentNode.__depth;
|
|
1472
1415
|
_sanitizeShadowDOM(currentNode.content);
|
|
1473
1416
|
}
|
|
1474
1417
|
|