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/README.md
CHANGED
|
@@ -6,11 +6,11 @@
|
|
|
6
6
|
|
|
7
7
|
DOMPurify is a DOM-only, super-fast, uber-tolerant XSS sanitizer for HTML, MathML and SVG.
|
|
8
8
|
|
|
9
|
-
It's also very simple to use and get started with. DOMPurify was [started in February 2014](https://github.com/cure53/DOMPurify/commit/a630922616927373485e0e787ab19e73e3691b2b) and, meanwhile, has reached version **v3.1.
|
|
9
|
+
It's also very simple to use and get started with. DOMPurify was [started in February 2014](https://github.com/cure53/DOMPurify/commit/a630922616927373485e0e787ab19e73e3691b2b) and, meanwhile, has reached version **v3.1.5**.
|
|
10
10
|
|
|
11
11
|
DOMPurify is written in JavaScript and works in all modern browsers (Safari (10+), Opera (15+), Edge, Firefox and Chrome - as well as almost anything else using Blink, Gecko or WebKit). It doesn't break on MSIE or other legacy browsers. It simply does nothing.
|
|
12
12
|
|
|
13
|
-
**Note that [DOMPurify v2.5.
|
|
13
|
+
**Note that [DOMPurify v2.5.5](https://github.com/cure53/DOMPurify/releases/tag/2.5.5) is the latest version supporting MSIE. For important security updates compatible with MSIE, please use the [2.x branch](https://github.com/cure53/DOMPurify/tree/2.x).**
|
|
14
14
|
|
|
15
15
|
Our automated tests cover [19 different browsers](https://github.com/cure53/DOMPurify/blob/main/test/karma.custom-launchers.config.js#L5) right now, more to come. We also cover Node.js v16.x, v17.x, v18.x and v19.x, running DOMPurify on [jsdom](https://github.com/jsdom/jsdom). Older Node versions are known to work as well, but hey... no guarantees.
|
|
16
16
|
|
package/dist/purify.cjs.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
|
'use strict';
|
|
4
4
|
|
|
@@ -50,10 +50,6 @@ const stringTrim = unapply(String.prototype.trim);
|
|
|
50
50
|
const objectHasOwnProperty = unapply(Object.prototype.hasOwnProperty);
|
|
51
51
|
const regExpTest = unapply(RegExp.prototype.test);
|
|
52
52
|
const typeErrorCreate = unconstruct(TypeError);
|
|
53
|
-
function numberIsNaN(x) {
|
|
54
|
-
// eslint-disable-next-line unicorn/prefer-number-properties
|
|
55
|
-
return typeof x === 'number' && isNaN(x);
|
|
56
|
-
}
|
|
57
53
|
|
|
58
54
|
/**
|
|
59
55
|
* Creates a new function that calls the given function with a specified thisArg and arguments.
|
|
@@ -306,7 +302,7 @@ function createDOMPurify() {
|
|
|
306
302
|
* Version label, exposed for easier checks
|
|
307
303
|
* if DOMPurify is up to date or not
|
|
308
304
|
*/
|
|
309
|
-
DOMPurify.version = '3.1.
|
|
305
|
+
DOMPurify.version = '3.1.5';
|
|
310
306
|
|
|
311
307
|
/**
|
|
312
308
|
* Array of elements that DOMPurify removed during sanitation.
|
|
@@ -539,9 +535,6 @@ function createDOMPurify() {
|
|
|
539
535
|
/* Keep a reference to config to pass to hooks */
|
|
540
536
|
let CONFIG = null;
|
|
541
537
|
|
|
542
|
-
/* Specify the maximum element nesting depth to prevent mXSS */
|
|
543
|
-
const MAX_NESTING_DEPTH = 255;
|
|
544
|
-
|
|
545
538
|
/* Ideally, do not touch anything below this line */
|
|
546
539
|
/* ______________________________________________ */
|
|
547
540
|
|
|
@@ -952,11 +945,7 @@ function createDOMPurify() {
|
|
|
952
945
|
* @return {Boolean} true if clobbered, false if safe
|
|
953
946
|
*/
|
|
954
947
|
const _isClobbered = function _isClobbered(elm) {
|
|
955
|
-
return elm instanceof HTMLFormElement && (
|
|
956
|
-
// eslint-disable-next-line unicorn/no-typeof-undefined
|
|
957
|
-
typeof elm.__depth !== 'undefined' && typeof elm.__depth !== 'number' ||
|
|
958
|
-
// eslint-disable-next-line unicorn/no-typeof-undefined
|
|
959
|
-
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');
|
|
948
|
+
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');
|
|
960
949
|
};
|
|
961
950
|
|
|
962
951
|
/**
|
|
@@ -1107,7 +1096,7 @@ function createDOMPurify() {
|
|
|
1107
1096
|
// eslint-disable-next-line complexity
|
|
1108
1097
|
const _isValidAttribute = function _isValidAttribute(lcTag, lcName, value) {
|
|
1109
1098
|
/* Make sure attribute cannot clobber */
|
|
1110
|
-
if (SANITIZE_DOM && (lcName === 'id' || lcName === 'name') && (value in document || value in formElement
|
|
1099
|
+
if (SANITIZE_DOM && (lcName === 'id' || lcName === 'name') && (value in document || value in formElement)) {
|
|
1111
1100
|
return false;
|
|
1112
1101
|
}
|
|
1113
1102
|
|
|
@@ -1298,32 +1287,9 @@ function createDOMPurify() {
|
|
|
1298
1287
|
if (_sanitizeElements(shadowNode)) {
|
|
1299
1288
|
continue;
|
|
1300
1289
|
}
|
|
1301
|
-
const parentNode = getParentNode(shadowNode);
|
|
1302
|
-
|
|
1303
|
-
/* Set the nesting depth of an element */
|
|
1304
|
-
if (shadowNode.nodeType === NODE_TYPE.element) {
|
|
1305
|
-
if (parentNode && parentNode.__depth) {
|
|
1306
|
-
/*
|
|
1307
|
-
We want the depth of the node in the original tree, which can
|
|
1308
|
-
change when it's removed from its parent.
|
|
1309
|
-
*/
|
|
1310
|
-
shadowNode.__depth = (shadowNode.__removalCount || 0) + parentNode.__depth + 1;
|
|
1311
|
-
} else {
|
|
1312
|
-
shadowNode.__depth = 1;
|
|
1313
|
-
}
|
|
1314
|
-
}
|
|
1315
|
-
|
|
1316
|
-
/*
|
|
1317
|
-
* Remove an element if nested too deeply to avoid mXSS
|
|
1318
|
-
* or if the __depth might have been tampered with
|
|
1319
|
-
*/
|
|
1320
|
-
if (shadowNode.__depth >= MAX_NESTING_DEPTH || shadowNode.__depth < 0 || numberIsNaN(shadowNode.__depth)) {
|
|
1321
|
-
_forceRemove(shadowNode);
|
|
1322
|
-
}
|
|
1323
1290
|
|
|
1324
1291
|
/* Deep shadow DOM detected */
|
|
1325
1292
|
if (shadowNode.content instanceof DocumentFragment) {
|
|
1326
|
-
shadowNode.content.__depth = shadowNode.__depth;
|
|
1327
1293
|
_sanitizeShadowDOM(shadowNode.content);
|
|
1328
1294
|
}
|
|
1329
1295
|
|
|
@@ -1439,32 +1405,9 @@ function createDOMPurify() {
|
|
|
1439
1405
|
if (_sanitizeElements(currentNode)) {
|
|
1440
1406
|
continue;
|
|
1441
1407
|
}
|
|
1442
|
-
const parentNode = getParentNode(currentNode);
|
|
1443
|
-
|
|
1444
|
-
/* Set the nesting depth of an element */
|
|
1445
|
-
if (currentNode.nodeType === NODE_TYPE.element) {
|
|
1446
|
-
if (parentNode && parentNode.__depth) {
|
|
1447
|
-
/*
|
|
1448
|
-
We want the depth of the node in the original tree, which can
|
|
1449
|
-
change when it's removed from its parent.
|
|
1450
|
-
*/
|
|
1451
|
-
currentNode.__depth = (currentNode.__removalCount || 0) + parentNode.__depth + 1;
|
|
1452
|
-
} else {
|
|
1453
|
-
currentNode.__depth = 1;
|
|
1454
|
-
}
|
|
1455
|
-
}
|
|
1456
|
-
|
|
1457
|
-
/*
|
|
1458
|
-
* Remove an element if nested too deeply to avoid mXSS
|
|
1459
|
-
* or if the __depth might have been tampered with
|
|
1460
|
-
*/
|
|
1461
|
-
if (currentNode.__depth >= MAX_NESTING_DEPTH || currentNode.__depth < 0 || numberIsNaN(currentNode.__depth)) {
|
|
1462
|
-
_forceRemove(currentNode);
|
|
1463
|
-
}
|
|
1464
1408
|
|
|
1465
1409
|
/* Shadow DOM detected, sanitize it */
|
|
1466
1410
|
if (currentNode.content instanceof DocumentFragment) {
|
|
1467
|
-
currentNode.content.__depth = currentNode.__depth;
|
|
1468
1411
|
_sanitizeShadowDOM(currentNode.content);
|
|
1469
1412
|
}
|
|
1470
1413
|
|