@xmldom/xmldom 0.9.0-beta.3 → 0.9.0-beta.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/CHANGELOG.md +72 -0
- package/lib/.eslintrc.yml +1 -0
- package/lib/conventions.js +60 -29
- package/lib/dom-parser.js +141 -139
- package/lib/dom.js +852 -716
- package/lib/entities.js +250 -244
- package/lib/index.js +5 -5
- package/lib/sax.js +442 -437
- package/package.json +7 -4
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,78 @@ All notable changes to this project will be documented in this file.
|
|
|
4
4
|
|
|
5
5
|
This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
6
6
|
|
|
7
|
+
## [0.9.0-beta.5](https://github.com/xmldom/xmldom/compare/0.9.0-beta.4...0.9.0-beta.5)
|
|
8
|
+
|
|
9
|
+
### Merged
|
|
10
|
+
|
|
11
|
+
- fix: Restore ES5 compatibility [`#452`](https://github.com/xmldom/xmldom/pull/452) / [`#453`](https://github.com/xmldom/xmldom/issues/453)
|
|
12
|
+
|
|
13
|
+
Thank you, [@fengxinming](https://github.com/fengxinming), for your contributions
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
## [0.8.5](https://github.com/xmldom/xmldom/compare/0.8.4...0.8.5)
|
|
17
|
+
|
|
18
|
+
### Merged
|
|
19
|
+
|
|
20
|
+
- fix: Restore ES5 compatibility [`#452`](https://github.com/xmldom/xmldom/pull/452) / [`#453`](https://github.com/xmldom/xmldom/issues/453)
|
|
21
|
+
|
|
22
|
+
Thank you, [@fengxinming](https://github.com/fengxinming), for your contributions
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
## [0.7.8](https://github.com/xmldom/xmldom/compare/0.7.7...0.7.8)
|
|
26
|
+
|
|
27
|
+
### Merged
|
|
28
|
+
|
|
29
|
+
- fix: Restore ES5 compatibility [`#452`](https://github.com/xmldom/xmldom/pull/452) / [`#453`](https://github.com/xmldom/xmldom/issues/453)
|
|
30
|
+
|
|
31
|
+
Thank you, [@fengxinming](https://github.com/fengxinming), for your contributions
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
## [0.9.0-beta.4](https://github.com/xmldom/xmldom/compare/0.9.0-beta.3...0.9.0-beta.4)
|
|
35
|
+
|
|
36
|
+
### Fixed
|
|
37
|
+
|
|
38
|
+
- Security: Prevent inserting DOM nodes when they are not well-formed [`CVE-2022-39353`](https://github.com/xmldom/xmldom/security/advisories/GHSA-crh6-fp67-6883)
|
|
39
|
+
In case such a DOM would be created, the part that is not well-formed will be transformed into text nodes, in which xml specific characters like `<` and `>` are encoded accordingly.
|
|
40
|
+
In the upcoming version 0.9.0 those text nodes will no longer be added and an error will be thrown instead.
|
|
41
|
+
This change can break your code, if you relied on this behavior, e.g. multiple root elements in the past. We consider it more important to align with the specs that we want to be aligned with, considering the potential security issues that might derive from people not being aware of the difference in behavior.
|
|
42
|
+
Related Spec: <https://dom.spec.whatwg.org/#concept-node-ensure-pre-insertion-validity>
|
|
43
|
+
|
|
44
|
+
### Chore
|
|
45
|
+
|
|
46
|
+
- update multiple devDependencies
|
|
47
|
+
- Add eslint-plugin-node for `lib` [`#448`](https://github.com/xmldom/xmldom/pull/448) / [`#190`](https://github.com/xmldom/xmldom/issues/190)
|
|
48
|
+
- style: Apply prettier to all code [`#447`](https://github.com/xmldom/xmldom/pull/447) / [`#29`](https://github.com/xmldom/xmldom/issues/29) / [`#130`](https://github.com/xmldom/xmldom/issues/130)
|
|
49
|
+
|
|
50
|
+
Thank you, [@XhmikosR](https://github.com/XhmikosR), [@awwright](https://github.com/awwright), [@frumioj](https://github.com/frumioj), [@cjbarth](https://github.com/cjbarth), [@markgollnick](https://github.com/markgollnick) for your contributions
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
## [0.8.4](https://github.com/xmldom/xmldom/compare/0.8.3...0.8.4)
|
|
54
|
+
|
|
55
|
+
### Fixed
|
|
56
|
+
|
|
57
|
+
- Security: Prevent inserting DOM nodes when they are not well-formed [`CVE-2022-39353`](https://github.com/xmldom/xmldom/security/advisories/GHSA-crh6-fp67-6883)
|
|
58
|
+
In case such a DOM would be created, the part that is not well-formed will be transformed into text nodes, in which xml specific characters like `<` and `>` are encoded accordingly.
|
|
59
|
+
In the upcoming version 0.9.0 those text nodes will no longer be added and an error will be thrown instead.
|
|
60
|
+
This change can break your code, if you relied on this behavior, e.g. multiple root elements in the past. We consider it more important to align with the specs that we want to be aligned with, considering the potential security issues that might derive from people not being aware of the difference in behavior.
|
|
61
|
+
Related Spec: <https://dom.spec.whatwg.org/#concept-node-ensure-pre-insertion-validity>
|
|
62
|
+
|
|
63
|
+
Thank you, [@frumioj](https://github.com/frumioj), [@cjbarth](https://github.com/cjbarth), [@markgollnick](https://github.com/markgollnick) for your contributions
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
## [0.7.7](https://github.com/xmldom/xmldom/compare/0.7.6...0.7.7)
|
|
67
|
+
|
|
68
|
+
### Fixed
|
|
69
|
+
|
|
70
|
+
- Security: Prevent inserting DOM nodes when they are not well-formed [`CVE-2022-39353`](https://github.com/xmldom/xmldom/security/advisories/GHSA-crh6-fp67-6883)
|
|
71
|
+
In case such a DOM would be created, the part that is not well-formed will be transformed into text nodes, in which xml specific characters like `<` and `>` are encoded accordingly.
|
|
72
|
+
In the upcoming version 0.9.0 those text nodes will no longer be added and an error will be thrown instead.
|
|
73
|
+
This change can break your code, if you relied on this behavior, e.g. multiple root elements in the past. We consider it more important to align with the specs that we want to be aligned with, considering the potential security issues that might derive from people not being aware of the difference in behavior.
|
|
74
|
+
Related Spec: <https://dom.spec.whatwg.org/#concept-node-ensure-pre-insertion-validity>
|
|
75
|
+
|
|
76
|
+
Thank you, [@frumioj](https://github.com/frumioj), [@cjbarth](https://github.com/cjbarth), [@markgollnick](https://github.com/markgollnick) for your contributions
|
|
77
|
+
|
|
78
|
+
|
|
7
79
|
## [0.9.0-beta.3](https://github.com/xmldom/xmldom/compare/0.9.0-beta.2...0.9.0-beta.3)
|
|
8
80
|
|
|
9
81
|
### Fixed
|
package/lib/.eslintrc.yml
CHANGED
package/lib/conventions.js
CHANGED
|
@@ -1,4 +1,36 @@
|
|
|
1
|
-
'use strict'
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Ponyfill for `Array.prototype.find` which is only available in ES6 runtimes.
|
|
5
|
+
*
|
|
6
|
+
* Works with anything that has a `length` property and index access properties, including NodeList.
|
|
7
|
+
*
|
|
8
|
+
* @template {unknown} T
|
|
9
|
+
* @param {Array<T> | ({length:number, [number]: T})} list
|
|
10
|
+
* @param {function (item: T, index: number, list:Array<T> | ({length:number, [number]: T})):boolean} predicate
|
|
11
|
+
* @param {Partial<Pick<ArrayConstructor['prototype'], 'find'>>?} ac `Array.prototype` by default,
|
|
12
|
+
* allows injecting a custom implementation in tests
|
|
13
|
+
* @returns {T | undefined}
|
|
14
|
+
*
|
|
15
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/find
|
|
16
|
+
* @see https://tc39.es/ecma262/multipage/indexed-collections.html#sec-array.prototype.find
|
|
17
|
+
*/
|
|
18
|
+
function find(list, predicate, ac) {
|
|
19
|
+
if (ac === undefined) {
|
|
20
|
+
ac = Array.prototype;
|
|
21
|
+
}
|
|
22
|
+
if (list && typeof ac.find === 'function') {
|
|
23
|
+
return ac.find.call(list, predicate);
|
|
24
|
+
}
|
|
25
|
+
for (var i = 0; i < list.length; i++) {
|
|
26
|
+
if (Object.prototype.hasOwnProperty.call(list, i)) {
|
|
27
|
+
var item = list[i];
|
|
28
|
+
if (predicate.call(undefined, item, i, list)) {
|
|
29
|
+
return item;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
2
34
|
|
|
3
35
|
/**
|
|
4
36
|
* "Shallow freezes" an object to render it immutable.
|
|
@@ -17,9 +49,9 @@
|
|
|
17
49
|
*/
|
|
18
50
|
function freeze(object, oc) {
|
|
19
51
|
if (oc === undefined) {
|
|
20
|
-
oc = Object
|
|
52
|
+
oc = Object;
|
|
21
53
|
}
|
|
22
|
-
return oc && typeof oc.freeze === 'function' ? oc.freeze(object) : object
|
|
54
|
+
return oc && typeof oc.freeze === 'function' ? oc.freeze(object) : object;
|
|
23
55
|
}
|
|
24
56
|
|
|
25
57
|
/**
|
|
@@ -37,14 +69,14 @@ function freeze(object, oc) {
|
|
|
37
69
|
*/
|
|
38
70
|
function assign(target, source) {
|
|
39
71
|
if (target === null || typeof target !== 'object') {
|
|
40
|
-
throw new TypeError('target is not an object')
|
|
72
|
+
throw new TypeError('target is not an object');
|
|
41
73
|
}
|
|
42
74
|
for (var key in source) {
|
|
43
75
|
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
44
|
-
target[key] = source[key]
|
|
76
|
+
target[key] = source[key];
|
|
45
77
|
}
|
|
46
78
|
}
|
|
47
|
-
return target
|
|
79
|
+
return target;
|
|
48
80
|
}
|
|
49
81
|
|
|
50
82
|
/**
|
|
@@ -87,7 +119,7 @@ var HTML_BOOLEAN_ATTRIBUTES = freeze({
|
|
|
87
119
|
required: true,
|
|
88
120
|
reversed: true,
|
|
89
121
|
selected: true,
|
|
90
|
-
})
|
|
122
|
+
});
|
|
91
123
|
|
|
92
124
|
/**
|
|
93
125
|
* Check if `name` is matching one of the HTML boolean attribute names.
|
|
@@ -100,7 +132,7 @@ var HTML_BOOLEAN_ATTRIBUTES = freeze({
|
|
|
100
132
|
* @see https://html.spec.whatwg.org/#attributes-3
|
|
101
133
|
*/
|
|
102
134
|
function isHTMLBooleanAttribute(name) {
|
|
103
|
-
return HTML_BOOLEAN_ATTRIBUTES.hasOwnProperty(name.toLowerCase())
|
|
135
|
+
return HTML_BOOLEAN_ATTRIBUTES.hasOwnProperty(name.toLowerCase());
|
|
104
136
|
}
|
|
105
137
|
|
|
106
138
|
/**
|
|
@@ -131,7 +163,7 @@ var HTML_VOID_ELEMENTS = freeze({
|
|
|
131
163
|
source: true,
|
|
132
164
|
track: true,
|
|
133
165
|
wbr: true,
|
|
134
|
-
})
|
|
166
|
+
});
|
|
135
167
|
|
|
136
168
|
/**
|
|
137
169
|
* Check if `tagName` is matching one of the HTML void element names.
|
|
@@ -144,7 +176,7 @@ var HTML_VOID_ELEMENTS = freeze({
|
|
|
144
176
|
* @see https://html.spec.whatwg.org/#void-elements
|
|
145
177
|
*/
|
|
146
178
|
function isHTMLVoidElement(tagName) {
|
|
147
|
-
return HTML_VOID_ELEMENTS.hasOwnProperty(tagName.toLowerCase())
|
|
179
|
+
return HTML_VOID_ELEMENTS.hasOwnProperty(tagName.toLowerCase());
|
|
148
180
|
}
|
|
149
181
|
|
|
150
182
|
/**
|
|
@@ -161,7 +193,7 @@ var HTML_RAW_TEXT_ELEMENTS = freeze({
|
|
|
161
193
|
style: false,
|
|
162
194
|
textarea: true,
|
|
163
195
|
title: true,
|
|
164
|
-
})
|
|
196
|
+
});
|
|
165
197
|
|
|
166
198
|
/**
|
|
167
199
|
* Check if `tagName` is matching one of the HTML raw text element names.
|
|
@@ -227,7 +259,7 @@ var MIME_TYPE = freeze({
|
|
|
227
259
|
* @see [`DOMParser.parseFromString` @ HTML Specification](https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#dom-domparser-parsefromstring)
|
|
228
260
|
*/
|
|
229
261
|
isHTML: function (value) {
|
|
230
|
-
return value === MIME_TYPE.HTML
|
|
262
|
+
return value === MIME_TYPE.HTML;
|
|
231
263
|
},
|
|
232
264
|
|
|
233
265
|
/**
|
|
@@ -242,9 +274,7 @@ var MIME_TYPE = freeze({
|
|
|
242
274
|
* @see https://dom.spec.whatwg.org/#dom-domimplementation-createhtmldocument
|
|
243
275
|
*/
|
|
244
276
|
hasDefaultHTMLNamespace: function (mimeType) {
|
|
245
|
-
return (
|
|
246
|
-
MIME_TYPE.isHTML(mimeType) || mimeType === MIME_TYPE.XML_XHTML_APPLICATION
|
|
247
|
-
)
|
|
277
|
+
return MIME_TYPE.isHTML(mimeType) || mimeType === MIME_TYPE.XML_XHTML_APPLICATION;
|
|
248
278
|
},
|
|
249
279
|
|
|
250
280
|
/**
|
|
@@ -283,7 +313,7 @@ var MIME_TYPE = freeze({
|
|
|
283
313
|
* @see https://en.wikipedia.org/wiki/Scalable_Vector_Graphics Wikipedia
|
|
284
314
|
*/
|
|
285
315
|
XML_SVG_IMAGE: 'image/svg+xml',
|
|
286
|
-
})
|
|
316
|
+
});
|
|
287
317
|
|
|
288
318
|
/**
|
|
289
319
|
* Namespaces that are used in this code base.
|
|
@@ -306,7 +336,7 @@ var NAMESPACE = freeze({
|
|
|
306
336
|
* @see NAMESPACE.HTML
|
|
307
337
|
*/
|
|
308
338
|
isHTML: function (uri) {
|
|
309
|
-
return uri === NAMESPACE.HTML
|
|
339
|
+
return uri === NAMESPACE.HTML;
|
|
310
340
|
},
|
|
311
341
|
|
|
312
342
|
/**
|
|
@@ -329,16 +359,17 @@ var NAMESPACE = freeze({
|
|
|
329
359
|
* @see https://www.w3.org/2000/xmlns/
|
|
330
360
|
*/
|
|
331
361
|
XMLNS: 'http://www.w3.org/2000/xmlns/',
|
|
332
|
-
})
|
|
362
|
+
});
|
|
333
363
|
|
|
334
|
-
exports.assign = assign
|
|
335
|
-
exports.
|
|
336
|
-
exports.
|
|
337
|
-
exports.
|
|
338
|
-
exports.
|
|
339
|
-
exports.
|
|
340
|
-
exports.
|
|
341
|
-
exports.
|
|
342
|
-
exports.
|
|
343
|
-
exports.
|
|
344
|
-
exports.
|
|
364
|
+
exports.assign = assign;
|
|
365
|
+
exports.find = find;
|
|
366
|
+
exports.freeze = freeze;
|
|
367
|
+
exports.HTML_BOOLEAN_ATTRIBUTES = HTML_BOOLEAN_ATTRIBUTES;
|
|
368
|
+
exports.HTML_RAW_TEXT_ELEMENTS = HTML_RAW_TEXT_ELEMENTS;
|
|
369
|
+
exports.HTML_VOID_ELEMENTS = HTML_VOID_ELEMENTS;
|
|
370
|
+
exports.isHTMLBooleanAttribute = isHTMLBooleanAttribute;
|
|
371
|
+
exports.isHTMLRawTextElement = isHTMLRawTextElement;
|
|
372
|
+
exports.isHTMLEscapableRawTextElement = isHTMLEscapableRawTextElement;
|
|
373
|
+
exports.isHTMLVoidElement = isHTMLVoidElement;
|
|
374
|
+
exports.MIME_TYPE = MIME_TYPE;
|
|
375
|
+
exports.NAMESPACE = NAMESPACE;
|