dompurify 2.3.10 → 2.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +45 -18
- package/dist/purify.cjs.js +37 -4
- package/dist/purify.cjs.js.map +1 -1
- package/dist/purify.es.js +37 -4
- package/dist/purify.es.js.map +1 -1
- package/dist/purify.js +37 -4
- 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 +3 -1
package/dist/purify.es.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @license DOMPurify 2.
|
|
1
|
+
/*! @license DOMPurify 2.4.0 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/2.4.0/LICENSE */
|
|
2
2
|
|
|
3
3
|
function _typeof(obj) {
|
|
4
4
|
"@babel/helpers - typeof";
|
|
@@ -320,7 +320,7 @@ function createDOMPurify() {
|
|
|
320
320
|
*/
|
|
321
321
|
|
|
322
322
|
|
|
323
|
-
DOMPurify.version = '2.
|
|
323
|
+
DOMPurify.version = '2.4.0';
|
|
324
324
|
/**
|
|
325
325
|
* Array of elements that DOMPurify removed during sanitation.
|
|
326
326
|
* Empty if nothing was removed.
|
|
@@ -478,9 +478,27 @@ function createDOMPurify() {
|
|
|
478
478
|
* case Trusted Types are not supported */
|
|
479
479
|
|
|
480
480
|
var RETURN_TRUSTED_TYPE = false;
|
|
481
|
-
/* Output should be free from DOM clobbering attacks?
|
|
481
|
+
/* Output should be free from DOM clobbering attacks?
|
|
482
|
+
* This sanitizes markups named with colliding, clobberable built-in DOM APIs.
|
|
483
|
+
*/
|
|
482
484
|
|
|
483
485
|
var SANITIZE_DOM = true;
|
|
486
|
+
/* Achieve full DOM Clobbering protection by isolating the namespace of named
|
|
487
|
+
* properties and JS variables, mitigating attacks that abuse the HTML/DOM spec rules.
|
|
488
|
+
*
|
|
489
|
+
* HTML/DOM spec rules that enable DOM Clobbering:
|
|
490
|
+
* - Named Access on Window (§7.3.3)
|
|
491
|
+
* - DOM Tree Accessors (§3.1.5)
|
|
492
|
+
* - Form Element Parent-Child Relations (§4.10.3)
|
|
493
|
+
* - Iframe srcdoc / Nested WindowProxies (§4.8.5)
|
|
494
|
+
* - HTMLCollection (§4.2.10.2)
|
|
495
|
+
*
|
|
496
|
+
* Namespace isolation is implemented by prefixing `id` and `name` attributes
|
|
497
|
+
* with a constant string, i.e., `user-content-`
|
|
498
|
+
*/
|
|
499
|
+
|
|
500
|
+
var SANITIZE_NAMED_PROPS = false;
|
|
501
|
+
var SANITIZE_NAMED_PROPS_PREFIX = 'user-content-';
|
|
484
502
|
/* Keep element content when removing element? */
|
|
485
503
|
|
|
486
504
|
var KEEP_CONTENT = true;
|
|
@@ -594,6 +612,8 @@ function createDOMPurify() {
|
|
|
594
612
|
|
|
595
613
|
SANITIZE_DOM = cfg.SANITIZE_DOM !== false; // Default true
|
|
596
614
|
|
|
615
|
+
SANITIZE_NAMED_PROPS = cfg.SANITIZE_NAMED_PROPS || false; // Default false
|
|
616
|
+
|
|
597
617
|
KEEP_CONTENT = cfg.KEEP_CONTENT !== false; // Default true
|
|
598
618
|
|
|
599
619
|
IN_PLACE = cfg.IN_PLACE || false; // Default false
|
|
@@ -1250,6 +1270,18 @@ function createDOMPurify() {
|
|
|
1250
1270
|
if (!_isValidAttribute(lcTag, lcName, value)) {
|
|
1251
1271
|
continue;
|
|
1252
1272
|
}
|
|
1273
|
+
/* Full DOM Clobbering protection via namespace isolation,
|
|
1274
|
+
* Prefix id and name attributes with `user-content-`
|
|
1275
|
+
*/
|
|
1276
|
+
|
|
1277
|
+
|
|
1278
|
+
if (SANITIZE_NAMED_PROPS && (lcName === 'id' || lcName === 'name')) {
|
|
1279
|
+
// Remove the attribute with this value
|
|
1280
|
+
_removeAttribute(name, currentNode); // Prefix the value and later re-create the attribute with the sanitized value
|
|
1281
|
+
|
|
1282
|
+
|
|
1283
|
+
value = SANITIZE_NAMED_PROPS_PREFIX + value;
|
|
1284
|
+
}
|
|
1253
1285
|
/* Handle attributes that require Trusted Types */
|
|
1254
1286
|
|
|
1255
1287
|
|
|
@@ -1336,7 +1368,8 @@ function createDOMPurify() {
|
|
|
1336
1368
|
// eslint-disable-next-line complexity
|
|
1337
1369
|
|
|
1338
1370
|
|
|
1339
|
-
DOMPurify.sanitize = function (dirty
|
|
1371
|
+
DOMPurify.sanitize = function (dirty) {
|
|
1372
|
+
var cfg = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
1340
1373
|
var body;
|
|
1341
1374
|
var importedNode;
|
|
1342
1375
|
var currentNode;
|