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.es.mjs
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
|
const {
|
|
4
4
|
entries,
|
|
@@ -48,10 +48,6 @@ const stringTrim = unapply(String.prototype.trim);
|
|
|
48
48
|
const objectHasOwnProperty = unapply(Object.prototype.hasOwnProperty);
|
|
49
49
|
const regExpTest = unapply(RegExp.prototype.test);
|
|
50
50
|
const typeErrorCreate = unconstruct(TypeError);
|
|
51
|
-
function numberIsNaN(x) {
|
|
52
|
-
// eslint-disable-next-line unicorn/prefer-number-properties
|
|
53
|
-
return typeof x === 'number' && isNaN(x);
|
|
54
|
-
}
|
|
55
51
|
|
|
56
52
|
/**
|
|
57
53
|
* Creates a new function that calls the given function with a specified thisArg and arguments.
|
|
@@ -304,7 +300,7 @@ function createDOMPurify() {
|
|
|
304
300
|
* Version label, exposed for easier checks
|
|
305
301
|
* if DOMPurify is up to date or not
|
|
306
302
|
*/
|
|
307
|
-
DOMPurify.version = '3.1.
|
|
303
|
+
DOMPurify.version = '3.1.5';
|
|
308
304
|
|
|
309
305
|
/**
|
|
310
306
|
* Array of elements that DOMPurify removed during sanitation.
|
|
@@ -537,9 +533,6 @@ function createDOMPurify() {
|
|
|
537
533
|
/* Keep a reference to config to pass to hooks */
|
|
538
534
|
let CONFIG = null;
|
|
539
535
|
|
|
540
|
-
/* Specify the maximum element nesting depth to prevent mXSS */
|
|
541
|
-
const MAX_NESTING_DEPTH = 255;
|
|
542
|
-
|
|
543
536
|
/* Ideally, do not touch anything below this line */
|
|
544
537
|
/* ______________________________________________ */
|
|
545
538
|
|
|
@@ -950,11 +943,7 @@ function createDOMPurify() {
|
|
|
950
943
|
* @return {Boolean} true if clobbered, false if safe
|
|
951
944
|
*/
|
|
952
945
|
const _isClobbered = function _isClobbered(elm) {
|
|
953
|
-
return elm instanceof HTMLFormElement && (
|
|
954
|
-
// eslint-disable-next-line unicorn/no-typeof-undefined
|
|
955
|
-
typeof elm.__depth !== 'undefined' && typeof elm.__depth !== 'number' ||
|
|
956
|
-
// eslint-disable-next-line unicorn/no-typeof-undefined
|
|
957
|
-
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');
|
|
946
|
+
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');
|
|
958
947
|
};
|
|
959
948
|
|
|
960
949
|
/**
|
|
@@ -1105,7 +1094,7 @@ function createDOMPurify() {
|
|
|
1105
1094
|
// eslint-disable-next-line complexity
|
|
1106
1095
|
const _isValidAttribute = function _isValidAttribute(lcTag, lcName, value) {
|
|
1107
1096
|
/* Make sure attribute cannot clobber */
|
|
1108
|
-
if (SANITIZE_DOM && (lcName === 'id' || lcName === 'name') && (value in document || value in formElement
|
|
1097
|
+
if (SANITIZE_DOM && (lcName === 'id' || lcName === 'name') && (value in document || value in formElement)) {
|
|
1109
1098
|
return false;
|
|
1110
1099
|
}
|
|
1111
1100
|
|
|
@@ -1296,32 +1285,9 @@ function createDOMPurify() {
|
|
|
1296
1285
|
if (_sanitizeElements(shadowNode)) {
|
|
1297
1286
|
continue;
|
|
1298
1287
|
}
|
|
1299
|
-
const parentNode = getParentNode(shadowNode);
|
|
1300
|
-
|
|
1301
|
-
/* Set the nesting depth of an element */
|
|
1302
|
-
if (shadowNode.nodeType === NODE_TYPE.element) {
|
|
1303
|
-
if (parentNode && parentNode.__depth) {
|
|
1304
|
-
/*
|
|
1305
|
-
We want the depth of the node in the original tree, which can
|
|
1306
|
-
change when it's removed from its parent.
|
|
1307
|
-
*/
|
|
1308
|
-
shadowNode.__depth = (shadowNode.__removalCount || 0) + parentNode.__depth + 1;
|
|
1309
|
-
} else {
|
|
1310
|
-
shadowNode.__depth = 1;
|
|
1311
|
-
}
|
|
1312
|
-
}
|
|
1313
|
-
|
|
1314
|
-
/*
|
|
1315
|
-
* Remove an element if nested too deeply to avoid mXSS
|
|
1316
|
-
* or if the __depth might have been tampered with
|
|
1317
|
-
*/
|
|
1318
|
-
if (shadowNode.__depth >= MAX_NESTING_DEPTH || shadowNode.__depth < 0 || numberIsNaN(shadowNode.__depth)) {
|
|
1319
|
-
_forceRemove(shadowNode);
|
|
1320
|
-
}
|
|
1321
1288
|
|
|
1322
1289
|
/* Deep shadow DOM detected */
|
|
1323
1290
|
if (shadowNode.content instanceof DocumentFragment) {
|
|
1324
|
-
shadowNode.content.__depth = shadowNode.__depth;
|
|
1325
1291
|
_sanitizeShadowDOM(shadowNode.content);
|
|
1326
1292
|
}
|
|
1327
1293
|
|
|
@@ -1437,32 +1403,9 @@ function createDOMPurify() {
|
|
|
1437
1403
|
if (_sanitizeElements(currentNode)) {
|
|
1438
1404
|
continue;
|
|
1439
1405
|
}
|
|
1440
|
-
const parentNode = getParentNode(currentNode);
|
|
1441
|
-
|
|
1442
|
-
/* Set the nesting depth of an element */
|
|
1443
|
-
if (currentNode.nodeType === NODE_TYPE.element) {
|
|
1444
|
-
if (parentNode && parentNode.__depth) {
|
|
1445
|
-
/*
|
|
1446
|
-
We want the depth of the node in the original tree, which can
|
|
1447
|
-
change when it's removed from its parent.
|
|
1448
|
-
*/
|
|
1449
|
-
currentNode.__depth = (currentNode.__removalCount || 0) + parentNode.__depth + 1;
|
|
1450
|
-
} else {
|
|
1451
|
-
currentNode.__depth = 1;
|
|
1452
|
-
}
|
|
1453
|
-
}
|
|
1454
|
-
|
|
1455
|
-
/*
|
|
1456
|
-
* Remove an element if nested too deeply to avoid mXSS
|
|
1457
|
-
* or if the __depth might have been tampered with
|
|
1458
|
-
*/
|
|
1459
|
-
if (currentNode.__depth >= MAX_NESTING_DEPTH || currentNode.__depth < 0 || numberIsNaN(currentNode.__depth)) {
|
|
1460
|
-
_forceRemove(currentNode);
|
|
1461
|
-
}
|
|
1462
1406
|
|
|
1463
1407
|
/* Shadow DOM detected, sanitize it */
|
|
1464
1408
|
if (currentNode.content instanceof DocumentFragment) {
|
|
1465
|
-
currentNode.content.__depth = currentNode.__depth;
|
|
1466
1409
|
_sanitizeShadowDOM(currentNode.content);
|
|
1467
1410
|
}
|
|
1468
1411
|
|