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.es.mjs
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
|
const {
|
|
4
4
|
entries,
|
|
@@ -45,6 +45,7 @@ const stringMatch = unapply(String.prototype.match);
|
|
|
45
45
|
const stringReplace = unapply(String.prototype.replace);
|
|
46
46
|
const stringIndexOf = unapply(String.prototype.indexOf);
|
|
47
47
|
const stringTrim = unapply(String.prototype.trim);
|
|
48
|
+
const objectHasOwnProperty = unapply(Object.prototype.hasOwnProperty);
|
|
48
49
|
const regExpTest = unapply(RegExp.prototype.test);
|
|
49
50
|
const typeErrorCreate = unconstruct(TypeError);
|
|
50
51
|
|
|
@@ -120,7 +121,8 @@ function addToSet(set, array) {
|
|
|
120
121
|
*/
|
|
121
122
|
function cleanArray(array) {
|
|
122
123
|
for (let index = 0; index < array.length; index++) {
|
|
123
|
-
|
|
124
|
+
const isPropertyExist = objectHasOwnProperty(array, index);
|
|
125
|
+
if (!isPropertyExist) {
|
|
124
126
|
array[index] = null;
|
|
125
127
|
}
|
|
126
128
|
}
|
|
@@ -136,10 +138,11 @@ function cleanArray(array) {
|
|
|
136
138
|
function clone(object) {
|
|
137
139
|
const newObject = create(null);
|
|
138
140
|
for (const [property, value] of entries(object)) {
|
|
139
|
-
|
|
141
|
+
const isPropertyExist = objectHasOwnProperty(object, property);
|
|
142
|
+
if (isPropertyExist) {
|
|
140
143
|
if (Array.isArray(value)) {
|
|
141
144
|
newObject[property] = cleanArray(value);
|
|
142
|
-
} else if (typeof value === 'object' && value.constructor === Object) {
|
|
145
|
+
} else if (value && typeof value === 'object' && value.constructor === Object) {
|
|
143
146
|
newObject[property] = clone(value);
|
|
144
147
|
} else {
|
|
145
148
|
newObject[property] = value;
|
|
@@ -169,8 +172,7 @@ function lookupGetter(object, prop) {
|
|
|
169
172
|
}
|
|
170
173
|
object = getPrototypeOf(object);
|
|
171
174
|
}
|
|
172
|
-
function fallbackValue(
|
|
173
|
-
console.warn('fallback value for', element);
|
|
175
|
+
function fallbackValue() {
|
|
174
176
|
return null;
|
|
175
177
|
}
|
|
176
178
|
return fallbackValue;
|
|
@@ -278,7 +280,7 @@ function createDOMPurify() {
|
|
|
278
280
|
* Version label, exposed for easier checks
|
|
279
281
|
* if DOMPurify is up to date or not
|
|
280
282
|
*/
|
|
281
|
-
DOMPurify.version = '3.0.
|
|
283
|
+
DOMPurify.version = '3.0.9';
|
|
282
284
|
|
|
283
285
|
/**
|
|
284
286
|
* Array of elements that DOMPurify removed during sanitation.
|
|
@@ -540,27 +542,27 @@ function createDOMPurify() {
|
|
|
540
542
|
transformCaseFunc = PARSER_MEDIA_TYPE === 'application/xhtml+xml' ? stringToString : stringToLowerCase;
|
|
541
543
|
|
|
542
544
|
/* Set configuration parameters */
|
|
543
|
-
ALLOWED_TAGS = 'ALLOWED_TAGS'
|
|
544
|
-
ALLOWED_ATTR = 'ALLOWED_ATTR'
|
|
545
|
-
ALLOWED_NAMESPACES = 'ALLOWED_NAMESPACES'
|
|
546
|
-
URI_SAFE_ATTRIBUTES = 'ADD_URI_SAFE_ATTR'
|
|
545
|
+
ALLOWED_TAGS = objectHasOwnProperty(cfg, 'ALLOWED_TAGS') ? addToSet({}, cfg.ALLOWED_TAGS, transformCaseFunc) : DEFAULT_ALLOWED_TAGS;
|
|
546
|
+
ALLOWED_ATTR = objectHasOwnProperty(cfg, 'ALLOWED_ATTR') ? addToSet({}, cfg.ALLOWED_ATTR, transformCaseFunc) : DEFAULT_ALLOWED_ATTR;
|
|
547
|
+
ALLOWED_NAMESPACES = objectHasOwnProperty(cfg, 'ALLOWED_NAMESPACES') ? addToSet({}, cfg.ALLOWED_NAMESPACES, stringToString) : DEFAULT_ALLOWED_NAMESPACES;
|
|
548
|
+
URI_SAFE_ATTRIBUTES = objectHasOwnProperty(cfg, 'ADD_URI_SAFE_ATTR') ? addToSet(clone(DEFAULT_URI_SAFE_ATTRIBUTES),
|
|
547
549
|
// eslint-disable-line indent
|
|
548
550
|
cfg.ADD_URI_SAFE_ATTR,
|
|
549
551
|
// eslint-disable-line indent
|
|
550
552
|
transformCaseFunc // eslint-disable-line indent
|
|
551
553
|
) // eslint-disable-line indent
|
|
552
554
|
: DEFAULT_URI_SAFE_ATTRIBUTES;
|
|
553
|
-
DATA_URI_TAGS = 'ADD_DATA_URI_TAGS'
|
|
555
|
+
DATA_URI_TAGS = objectHasOwnProperty(cfg, 'ADD_DATA_URI_TAGS') ? addToSet(clone(DEFAULT_DATA_URI_TAGS),
|
|
554
556
|
// eslint-disable-line indent
|
|
555
557
|
cfg.ADD_DATA_URI_TAGS,
|
|
556
558
|
// eslint-disable-line indent
|
|
557
559
|
transformCaseFunc // eslint-disable-line indent
|
|
558
560
|
) // eslint-disable-line indent
|
|
559
561
|
: DEFAULT_DATA_URI_TAGS;
|
|
560
|
-
FORBID_CONTENTS = 'FORBID_CONTENTS'
|
|
561
|
-
FORBID_TAGS = 'FORBID_TAGS'
|
|
562
|
-
FORBID_ATTR = 'FORBID_ATTR'
|
|
563
|
-
USE_PROFILES = 'USE_PROFILES'
|
|
562
|
+
FORBID_CONTENTS = objectHasOwnProperty(cfg, 'FORBID_CONTENTS') ? addToSet({}, cfg.FORBID_CONTENTS, transformCaseFunc) : DEFAULT_FORBID_CONTENTS;
|
|
563
|
+
FORBID_TAGS = objectHasOwnProperty(cfg, 'FORBID_TAGS') ? addToSet({}, cfg.FORBID_TAGS, transformCaseFunc) : {};
|
|
564
|
+
FORBID_ATTR = objectHasOwnProperty(cfg, 'FORBID_ATTR') ? addToSet({}, cfg.FORBID_ATTR, transformCaseFunc) : {};
|
|
565
|
+
USE_PROFILES = objectHasOwnProperty(cfg, 'USE_PROFILES') ? cfg.USE_PROFILES : false;
|
|
564
566
|
ALLOW_ARIA_ATTR = cfg.ALLOW_ARIA_ATTR !== false; // Default true
|
|
565
567
|
ALLOW_DATA_ATTR = cfg.ALLOW_DATA_ATTR !== false; // Default true
|
|
566
568
|
ALLOW_UNKNOWN_PROTOCOLS = cfg.ALLOW_UNKNOWN_PROTOCOLS || false; // Default false
|
|
@@ -1086,7 +1088,7 @@ function createDOMPurify() {
|
|
|
1086
1088
|
* @returns {boolean} Returns true if the tag name meets the basic criteria for a custom element, otherwise false.
|
|
1087
1089
|
*/
|
|
1088
1090
|
const _isBasicCustomElement = function _isBasicCustomElement(tagName) {
|
|
1089
|
-
return tagName.indexOf('-') > 0;
|
|
1091
|
+
return tagName !== 'annotation-xml' && tagName.indexOf('-') > 0;
|
|
1090
1092
|
};
|
|
1091
1093
|
|
|
1092
1094
|
/**
|