dompurify 3.0.7 → 3.0.9
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 +19 -17
- package/dist/purify.cjs.js.map +1 -1
- package/dist/purify.es.mjs +19 -17
- package/dist/purify.es.mjs.map +1 -1
- package/dist/purify.js +19 -17
- 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 -8
package/dist/purify.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @license DOMPurify 3.0.
|
|
1
|
+
/*! @license DOMPurify 3.0.9 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.0.9/LICENSE */
|
|
2
2
|
|
|
3
3
|
(function (global, factory) {
|
|
4
4
|
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
|
|
@@ -51,6 +51,7 @@
|
|
|
51
51
|
const stringReplace = unapply(String.prototype.replace);
|
|
52
52
|
const stringIndexOf = unapply(String.prototype.indexOf);
|
|
53
53
|
const stringTrim = unapply(String.prototype.trim);
|
|
54
|
+
const objectHasOwnProperty = unapply(Object.prototype.hasOwnProperty);
|
|
54
55
|
const regExpTest = unapply(RegExp.prototype.test);
|
|
55
56
|
const typeErrorCreate = unconstruct(TypeError);
|
|
56
57
|
|
|
@@ -126,7 +127,8 @@
|
|
|
126
127
|
*/
|
|
127
128
|
function cleanArray(array) {
|
|
128
129
|
for (let index = 0; index < array.length; index++) {
|
|
129
|
-
|
|
130
|
+
const isPropertyExist = objectHasOwnProperty(array, index);
|
|
131
|
+
if (!isPropertyExist) {
|
|
130
132
|
array[index] = null;
|
|
131
133
|
}
|
|
132
134
|
}
|
|
@@ -142,10 +144,11 @@
|
|
|
142
144
|
function clone(object) {
|
|
143
145
|
const newObject = create(null);
|
|
144
146
|
for (const [property, value] of entries(object)) {
|
|
145
|
-
|
|
147
|
+
const isPropertyExist = objectHasOwnProperty(object, property);
|
|
148
|
+
if (isPropertyExist) {
|
|
146
149
|
if (Array.isArray(value)) {
|
|
147
150
|
newObject[property] = cleanArray(value);
|
|
148
|
-
} else if (typeof value === 'object' && value.constructor === Object) {
|
|
151
|
+
} else if (value && typeof value === 'object' && value.constructor === Object) {
|
|
149
152
|
newObject[property] = clone(value);
|
|
150
153
|
} else {
|
|
151
154
|
newObject[property] = value;
|
|
@@ -175,8 +178,7 @@
|
|
|
175
178
|
}
|
|
176
179
|
object = getPrototypeOf(object);
|
|
177
180
|
}
|
|
178
|
-
function fallbackValue(
|
|
179
|
-
console.warn('fallback value for', element);
|
|
181
|
+
function fallbackValue() {
|
|
180
182
|
return null;
|
|
181
183
|
}
|
|
182
184
|
return fallbackValue;
|
|
@@ -284,7 +286,7 @@
|
|
|
284
286
|
* Version label, exposed for easier checks
|
|
285
287
|
* if DOMPurify is up to date or not
|
|
286
288
|
*/
|
|
287
|
-
DOMPurify.version = '3.0.
|
|
289
|
+
DOMPurify.version = '3.0.9';
|
|
288
290
|
|
|
289
291
|
/**
|
|
290
292
|
* Array of elements that DOMPurify removed during sanitation.
|
|
@@ -546,27 +548,27 @@
|
|
|
546
548
|
transformCaseFunc = PARSER_MEDIA_TYPE === 'application/xhtml+xml' ? stringToString : stringToLowerCase;
|
|
547
549
|
|
|
548
550
|
/* Set configuration parameters */
|
|
549
|
-
ALLOWED_TAGS = 'ALLOWED_TAGS'
|
|
550
|
-
ALLOWED_ATTR = 'ALLOWED_ATTR'
|
|
551
|
-
ALLOWED_NAMESPACES = 'ALLOWED_NAMESPACES'
|
|
552
|
-
URI_SAFE_ATTRIBUTES = 'ADD_URI_SAFE_ATTR'
|
|
551
|
+
ALLOWED_TAGS = objectHasOwnProperty(cfg, 'ALLOWED_TAGS') ? addToSet({}, cfg.ALLOWED_TAGS, transformCaseFunc) : DEFAULT_ALLOWED_TAGS;
|
|
552
|
+
ALLOWED_ATTR = objectHasOwnProperty(cfg, 'ALLOWED_ATTR') ? addToSet({}, cfg.ALLOWED_ATTR, transformCaseFunc) : DEFAULT_ALLOWED_ATTR;
|
|
553
|
+
ALLOWED_NAMESPACES = objectHasOwnProperty(cfg, 'ALLOWED_NAMESPACES') ? addToSet({}, cfg.ALLOWED_NAMESPACES, stringToString) : DEFAULT_ALLOWED_NAMESPACES;
|
|
554
|
+
URI_SAFE_ATTRIBUTES = objectHasOwnProperty(cfg, 'ADD_URI_SAFE_ATTR') ? addToSet(clone(DEFAULT_URI_SAFE_ATTRIBUTES),
|
|
553
555
|
// eslint-disable-line indent
|
|
554
556
|
cfg.ADD_URI_SAFE_ATTR,
|
|
555
557
|
// eslint-disable-line indent
|
|
556
558
|
transformCaseFunc // eslint-disable-line indent
|
|
557
559
|
) // eslint-disable-line indent
|
|
558
560
|
: DEFAULT_URI_SAFE_ATTRIBUTES;
|
|
559
|
-
DATA_URI_TAGS = 'ADD_DATA_URI_TAGS'
|
|
561
|
+
DATA_URI_TAGS = objectHasOwnProperty(cfg, 'ADD_DATA_URI_TAGS') ? addToSet(clone(DEFAULT_DATA_URI_TAGS),
|
|
560
562
|
// eslint-disable-line indent
|
|
561
563
|
cfg.ADD_DATA_URI_TAGS,
|
|
562
564
|
// eslint-disable-line indent
|
|
563
565
|
transformCaseFunc // eslint-disable-line indent
|
|
564
566
|
) // eslint-disable-line indent
|
|
565
567
|
: DEFAULT_DATA_URI_TAGS;
|
|
566
|
-
FORBID_CONTENTS = 'FORBID_CONTENTS'
|
|
567
|
-
FORBID_TAGS = 'FORBID_TAGS'
|
|
568
|
-
FORBID_ATTR = 'FORBID_ATTR'
|
|
569
|
-
USE_PROFILES = 'USE_PROFILES'
|
|
568
|
+
FORBID_CONTENTS = objectHasOwnProperty(cfg, 'FORBID_CONTENTS') ? addToSet({}, cfg.FORBID_CONTENTS, transformCaseFunc) : DEFAULT_FORBID_CONTENTS;
|
|
569
|
+
FORBID_TAGS = objectHasOwnProperty(cfg, 'FORBID_TAGS') ? addToSet({}, cfg.FORBID_TAGS, transformCaseFunc) : {};
|
|
570
|
+
FORBID_ATTR = objectHasOwnProperty(cfg, 'FORBID_ATTR') ? addToSet({}, cfg.FORBID_ATTR, transformCaseFunc) : {};
|
|
571
|
+
USE_PROFILES = objectHasOwnProperty(cfg, 'USE_PROFILES') ? cfg.USE_PROFILES : false;
|
|
570
572
|
ALLOW_ARIA_ATTR = cfg.ALLOW_ARIA_ATTR !== false; // Default true
|
|
571
573
|
ALLOW_DATA_ATTR = cfg.ALLOW_DATA_ATTR !== false; // Default true
|
|
572
574
|
ALLOW_UNKNOWN_PROTOCOLS = cfg.ALLOW_UNKNOWN_PROTOCOLS || false; // Default false
|
|
@@ -1092,7 +1094,7 @@
|
|
|
1092
1094
|
* @returns {boolean} Returns true if the tag name meets the basic criteria for a custom element, otherwise false.
|
|
1093
1095
|
*/
|
|
1094
1096
|
const _isBasicCustomElement = function _isBasicCustomElement(tagName) {
|
|
1095
|
-
return tagName.indexOf('-') > 0;
|
|
1097
|
+
return tagName !== 'annotation-xml' && tagName.indexOf('-') > 0;
|
|
1096
1098
|
};
|
|
1097
1099
|
|
|
1098
1100
|
/**
|