@xmldom/xmldom 0.9.8 → 0.9.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/CHANGELOG.md +48 -0
- package/index.d.ts +46 -2
- package/lib/dom.js +59 -2
- package/package.json +10 -9
- package/readme.md +7 -0
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,54 @@ 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.9](https://github.com/xmldom/xmldom/compare/0.9.8...0.9.9)
|
|
8
|
+
|
|
9
|
+
### Added
|
|
10
|
+
|
|
11
|
+
- implement `ParentNode.children` getter [`#960`](https://github.com/xmldom/xmldom/pull/960) / [`#410`](https://github.com/xmldom/xmldom/issues/410)
|
|
12
|
+
|
|
13
|
+
### Fixed
|
|
14
|
+
|
|
15
|
+
- Security: `createCDATASection` now throws `InvalidCharacterError` when `data` contains `"]]>"`, as required by the [WHATWG DOM spec](https://dom.spec.whatwg.org/#dom-document-createcdatasection). [`GHSA-wh4c-j3r5-mjhp`](https://github.com/xmldom/xmldom/security/advisories/GHSA-wh4c-j3r5-mjhp)
|
|
16
|
+
- Security: `XMLSerializer` now splits CDATASection nodes whose data contains `"]]>"` into adjacent CDATA sections at serialization time, preventing XML injection via mutation methods (`appendData`, `replaceData`, `.data =`, `.textContent =`). [`GHSA-wh4c-j3r5-mjhp`](https://github.com/xmldom/xmldom/security/advisories/GHSA-wh4c-j3r5-mjhp)
|
|
17
|
+
- correctly traverse ancestor chain in `Node.contains` [`#931`](https://github.com/xmldom/xmldom/pull/931)
|
|
18
|
+
|
|
19
|
+
Code that passes a string containing `"]]>"` to `createCDATASection` and relied on the previously unsafe behavior will now receive `InvalidCharacterError`. Use a mutation method such as `appendData` if you intentionally need `"]]>"` in a CDATASection node's data.
|
|
20
|
+
|
|
21
|
+
### Chore
|
|
22
|
+
|
|
23
|
+
- updated dependencies
|
|
24
|
+
|
|
25
|
+
Thank you,
|
|
26
|
+
[@stevenobiajulu](https://github.com/stevenobiajulu),
|
|
27
|
+
[@yoshi389111](https://github.com/yoshi389111),
|
|
28
|
+
[@thesmartshadow](https://github.com/thesmartshadow),
|
|
29
|
+
for your contributions
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
## [0.8.12](https://github.com/xmldom/xmldom/compare/0.8.11...0.8.12)
|
|
33
|
+
|
|
34
|
+
### Fixed
|
|
35
|
+
|
|
36
|
+
- preserve trailing whitespace in ProcessingInstruction data [`#962`](https://github.com/xmldom/xmldom/pull/962) / [`#42`](https://github.com/xmldom/xmldom/issues/42)
|
|
37
|
+
- Security: `createCDATASection` now throws `InvalidCharacterError` when `data` contains `"]]>"`, as required by the [WHATWG DOM spec](https://dom.spec.whatwg.org/#dom-document-createcdatasection). [`GHSA-wh4c-j3r5-mjhp`](https://github.com/xmldom/xmldom/security/advisories/GHSA-wh4c-j3r5-mjhp)
|
|
38
|
+
- Security: `XMLSerializer` now splits CDATASection nodes whose data contains `"]]>"` into adjacent CDATA sections at serialization time, preventing XML injection via mutation methods (`appendData`, `replaceData`, `.data =`, `.textContent =`). [`GHSA-wh4c-j3r5-mjhp`](https://github.com/xmldom/xmldom/security/advisories/GHSA-wh4c-j3r5-mjhp)
|
|
39
|
+
|
|
40
|
+
Code that passes a string containing `"]]>"` to `createCDATASection` and relied on the previously unsafe behavior will now receive `InvalidCharacterError`. Use a mutation method such as `appendData` if you intentionally need `"]]>"` in a CDATASection node's data.
|
|
41
|
+
|
|
42
|
+
Thank you,
|
|
43
|
+
[@thesmartshadow](https://github.com/thesmartshadow),
|
|
44
|
+
[@stevenobiajulu](https://github.com/stevenobiajulu),
|
|
45
|
+
for your contributions
|
|
46
|
+
|
|
47
|
+
## [0.8.11](https://github.com/xmldom/xmldom/compare/0.8.10...0.8.11)
|
|
48
|
+
|
|
49
|
+
### Fixed
|
|
50
|
+
|
|
51
|
+
- update `ownerDocument` when moving nodes between documents [`#933`](https://github.com/xmldom/xmldom/pull/933) / [`#932`](https://github.com/xmldom/xmldom/issues/932)
|
|
52
|
+
|
|
53
|
+
Thank you, [@shunkica](https://github.com/shunkica), for your contributions
|
|
54
|
+
|
|
7
55
|
## [0.9.8](https://github.com/xmldom/xmldom/compare/0.9.8...0.9.7)
|
|
8
56
|
|
|
9
57
|
### Fixed
|
package/index.d.ts
CHANGED
|
@@ -827,6 +827,15 @@ declare module '@xmldom/xmldom' {
|
|
|
827
827
|
*/
|
|
828
828
|
readonly tagName: string;
|
|
829
829
|
|
|
830
|
+
/**
|
|
831
|
+
* Returns a live collection of the direct child elements of this element.
|
|
832
|
+
*
|
|
833
|
+
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/children)
|
|
834
|
+
*
|
|
835
|
+
* @see https://dom.spec.whatwg.org/#dom-parentnode-children
|
|
836
|
+
*/
|
|
837
|
+
readonly children: LiveNodeList<Element>;
|
|
838
|
+
|
|
830
839
|
/**
|
|
831
840
|
* Returns element's first attribute whose qualified name is qualifiedName, and null if there
|
|
832
841
|
* is no such attribute otherwise.
|
|
@@ -1085,6 +1094,16 @@ declare module '@xmldom/xmldom' {
|
|
|
1085
1094
|
*/
|
|
1086
1095
|
interface DocumentFragment extends Node {
|
|
1087
1096
|
readonly ownerDocument: Document;
|
|
1097
|
+
|
|
1098
|
+
/**
|
|
1099
|
+
* Returns a live collection of the direct child elements of this document fragment.
|
|
1100
|
+
*
|
|
1101
|
+
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/DocumentFragment/children)
|
|
1102
|
+
*
|
|
1103
|
+
* @see https://dom.spec.whatwg.org/#dom-parentnode-children
|
|
1104
|
+
*/
|
|
1105
|
+
readonly children: LiveNodeList<Element>;
|
|
1106
|
+
|
|
1088
1107
|
getElementById(elementId: string): Element | null;
|
|
1089
1108
|
}
|
|
1090
1109
|
var DocumentFragment: InstanceOf<DocumentFragment>;
|
|
@@ -1152,6 +1171,15 @@ declare module '@xmldom/xmldom' {
|
|
|
1152
1171
|
*/
|
|
1153
1172
|
readonly documentElement: Element | null;
|
|
1154
1173
|
|
|
1174
|
+
/**
|
|
1175
|
+
* Returns a live collection of the direct child elements of this document.
|
|
1176
|
+
*
|
|
1177
|
+
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Document/children)
|
|
1178
|
+
*
|
|
1179
|
+
* @see https://dom.spec.whatwg.org/#dom-parentnode-children
|
|
1180
|
+
*/
|
|
1181
|
+
readonly children: LiveNodeList<Element>;
|
|
1182
|
+
|
|
1155
1183
|
/**
|
|
1156
1184
|
* Creates an attribute object with a specified name.
|
|
1157
1185
|
*
|
|
@@ -1163,9 +1191,15 @@ declare module '@xmldom/xmldom' {
|
|
|
1163
1191
|
createAttributeNS(namespace: string | null, qualifiedName: string): Attr;
|
|
1164
1192
|
|
|
1165
1193
|
/**
|
|
1166
|
-
* Returns a CDATASection node whose data is data
|
|
1194
|
+
* Returns a new CDATASection node whose data is `data`.
|
|
1195
|
+
*
|
|
1196
|
+
* __This implementation differs from the specification:__ - calling this method on an HTML
|
|
1197
|
+
* document does not throw `NotSupportedError`.
|
|
1167
1198
|
*
|
|
1168
|
-
*
|
|
1199
|
+
* @throws {DOMException}
|
|
1200
|
+
* With code `INVALID_CHARACTER_ERR` if `data` contains `"]]>"`.
|
|
1201
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/API/Document/createCDATASection
|
|
1202
|
+
* @see https://dom.spec.whatwg.org/#dom-document-createcdatasection
|
|
1169
1203
|
*/
|
|
1170
1204
|
createCDATASection(data: string): CDATASection;
|
|
1171
1205
|
|
|
@@ -1430,6 +1464,16 @@ declare module '@xmldom/xmldom' {
|
|
|
1430
1464
|
}
|
|
1431
1465
|
|
|
1432
1466
|
class XMLSerializer {
|
|
1467
|
+
/**
|
|
1468
|
+
* Returns the result of serializing `node` to XML.
|
|
1469
|
+
*
|
|
1470
|
+
* __This implementation differs from the specification:__ - CDATASection nodes whose data
|
|
1471
|
+
* contains `]]>` are serialized by splitting the section at each `]]>` occurrence (following
|
|
1472
|
+
* W3C DOM Level 3 Core `split-cdata-sections`
|
|
1473
|
+
* default behaviour). A configurable option is not yet implemented.
|
|
1474
|
+
*
|
|
1475
|
+
* @see https://html.spec.whatwg.org/#dom-xmlserializer-serializetostring
|
|
1476
|
+
*/
|
|
1433
1477
|
serializeToString(node: Node, nodeFilter?: (node: Node) => boolean): string;
|
|
1434
1478
|
}
|
|
1435
1479
|
// END ./lib/dom.js
|
package/lib/dom.js
CHANGED
|
@@ -1082,7 +1082,7 @@ Node.prototype = {
|
|
|
1082
1082
|
var parent = other;
|
|
1083
1083
|
do {
|
|
1084
1084
|
if (this === parent) return true;
|
|
1085
|
-
parent =
|
|
1085
|
+
parent = parent.parentNode;
|
|
1086
1086
|
} while (parent);
|
|
1087
1087
|
return false;
|
|
1088
1088
|
},
|
|
@@ -2210,10 +2210,22 @@ Document.prototype = {
|
|
|
2210
2210
|
return node;
|
|
2211
2211
|
},
|
|
2212
2212
|
/**
|
|
2213
|
+
* Returns a new CDATASection node whose data is `data`.
|
|
2214
|
+
*
|
|
2215
|
+
* __This implementation differs from the specification:__ - calling this method on an HTML
|
|
2216
|
+
* document does not throw `NotSupportedError`.
|
|
2217
|
+
*
|
|
2213
2218
|
* @param {string} data
|
|
2214
2219
|
* @returns {CDATASection}
|
|
2220
|
+
* @throws {DOMException}
|
|
2221
|
+
* With code `INVALID_CHARACTER_ERR` if `data` contains `"]]>"`.
|
|
2222
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/API/Document/createCDATASection
|
|
2223
|
+
* @see https://dom.spec.whatwg.org/#dom-document-createcdatasection
|
|
2215
2224
|
*/
|
|
2216
2225
|
createCDATASection: function (data) {
|
|
2226
|
+
if (data.indexOf(']]>') !== -1) {
|
|
2227
|
+
throw new DOMException(DOMException.INVALID_CHARACTER_ERR, 'data contains "]]>"');
|
|
2228
|
+
}
|
|
2217
2229
|
var node = new CDATASection(PDC);
|
|
2218
2230
|
node.ownerDocument = this;
|
|
2219
2231
|
node.childNodes = new NodeList();
|
|
@@ -2693,6 +2705,19 @@ function ProcessingInstruction(symbol) {
|
|
|
2693
2705
|
ProcessingInstruction.prototype.nodeType = PROCESSING_INSTRUCTION_NODE;
|
|
2694
2706
|
_extends(ProcessingInstruction, CharacterData);
|
|
2695
2707
|
function XMLSerializer() {}
|
|
2708
|
+
/**
|
|
2709
|
+
* Returns the result of serializing `node` to XML.
|
|
2710
|
+
*
|
|
2711
|
+
* __This implementation differs from the specification:__ - CDATASection nodes whose data
|
|
2712
|
+
* contains `]]>` are serialized by splitting the section at each `]]>` occurrence (following
|
|
2713
|
+
* W3C DOM Level 3 Core `split-cdata-sections`
|
|
2714
|
+
* default behaviour). A configurable option is not yet implemented.
|
|
2715
|
+
*
|
|
2716
|
+
* @param {Node} node
|
|
2717
|
+
* @param {function} [nodeFilter]
|
|
2718
|
+
* @returns {string}
|
|
2719
|
+
* @see https://html.spec.whatwg.org/#dom-xmlserializer-serializetostring
|
|
2720
|
+
*/
|
|
2696
2721
|
XMLSerializer.prototype.serializeToString = function (node, nodeFilter) {
|
|
2697
2722
|
return nodeSerializeToString.call(node, nodeFilter);
|
|
2698
2723
|
};
|
|
@@ -2917,7 +2942,7 @@ function serializeToString(node, buf, nodeFilter, visibleNamespaces) {
|
|
|
2917
2942
|
*/
|
|
2918
2943
|
return buf.push(node.data.replace(/[<&>]/g, _xmlEncoder));
|
|
2919
2944
|
case CDATA_SECTION_NODE:
|
|
2920
|
-
return buf.push(g.CDATA_START, node.data, g.CDATA_END);
|
|
2945
|
+
return buf.push(g.CDATA_START, node.data.replace(/]]>/g, ']]]]><![CDATA[>'), g.CDATA_END);
|
|
2921
2946
|
case COMMENT_NODE:
|
|
2922
2947
|
return buf.push(g.COMMENT_START, node.data, g.COMMENT_END);
|
|
2923
2948
|
case DOCUMENT_TYPE_NODE:
|
|
@@ -3051,6 +3076,22 @@ function cloneNode(doc, node, deep) {
|
|
|
3051
3076
|
function __set__(object, key, value) {
|
|
3052
3077
|
object[key] = value;
|
|
3053
3078
|
}
|
|
3079
|
+
|
|
3080
|
+
// Returns a new array of direct Element children.
|
|
3081
|
+
// Passed to LiveNodeList to implement ParentNode.children.
|
|
3082
|
+
// https://dom.spec.whatwg.org/#dom-parentnode-children
|
|
3083
|
+
function childrenRefresh(node) {
|
|
3084
|
+
var ls = [];
|
|
3085
|
+
var child = node.firstChild;
|
|
3086
|
+
while (child) {
|
|
3087
|
+
if (child.nodeType === ELEMENT_NODE) {
|
|
3088
|
+
ls.push(child);
|
|
3089
|
+
}
|
|
3090
|
+
child = child.nextSibling;
|
|
3091
|
+
}
|
|
3092
|
+
return ls;
|
|
3093
|
+
}
|
|
3094
|
+
|
|
3054
3095
|
//do dynamic
|
|
3055
3096
|
try {
|
|
3056
3097
|
if (Object.defineProperty) {
|
|
@@ -3104,6 +3145,22 @@ try {
|
|
|
3104
3145
|
}
|
|
3105
3146
|
}
|
|
3106
3147
|
|
|
3148
|
+
Object.defineProperty(Element.prototype, 'children', {
|
|
3149
|
+
get: function () {
|
|
3150
|
+
return new LiveNodeList(this, childrenRefresh);
|
|
3151
|
+
},
|
|
3152
|
+
});
|
|
3153
|
+
Object.defineProperty(Document.prototype, 'children', {
|
|
3154
|
+
get: function () {
|
|
3155
|
+
return new LiveNodeList(this, childrenRefresh);
|
|
3156
|
+
},
|
|
3157
|
+
});
|
|
3158
|
+
Object.defineProperty(DocumentFragment.prototype, 'children', {
|
|
3159
|
+
get: function () {
|
|
3160
|
+
return new LiveNodeList(this, childrenRefresh);
|
|
3161
|
+
},
|
|
3162
|
+
});
|
|
3163
|
+
|
|
3107
3164
|
__set__ = function (object, key, value) {
|
|
3108
3165
|
//console.log(value)
|
|
3109
3166
|
object['$$' + key] = value;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xmldom/xmldom",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.9",
|
|
4
4
|
"description": "A pure JavaScript W3C standard-based (XML DOM Level 2 Core) DOMParser and XMLSerializer module.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"w3c",
|
|
@@ -30,6 +30,7 @@
|
|
|
30
30
|
"scripts": {
|
|
31
31
|
"lint": "eslint examples lib test",
|
|
32
32
|
"format": "prettier --write examples lib test index.d.ts",
|
|
33
|
+
"format:check": "prettier --check examples lib test index.d.ts",
|
|
33
34
|
"changelog": "auto-changelog --unreleased-only",
|
|
34
35
|
"start": "nodemon --watch package.json --watch lib --watch test --exec 'npm --silent run test && npm --silent run lint'",
|
|
35
36
|
"test": "jest",
|
|
@@ -43,21 +44,21 @@
|
|
|
43
44
|
"node": ">=14.6"
|
|
44
45
|
},
|
|
45
46
|
"devDependencies": {
|
|
46
|
-
"@homer0/prettier-plugin-jsdoc": "
|
|
47
|
+
"@homer0/prettier-plugin-jsdoc": "10.0.0",
|
|
47
48
|
"auto-changelog": "2.5.0",
|
|
48
49
|
"eslint": "8.57.1",
|
|
49
|
-
"eslint-config-prettier": "10.
|
|
50
|
+
"eslint-config-prettier": "10.1.8",
|
|
50
51
|
"eslint-plugin-anti-trojan-source": "1.1.1",
|
|
51
52
|
"eslint-plugin-es5": "1.5.0",
|
|
52
|
-
"eslint-plugin-n": "17.
|
|
53
|
-
"eslint-plugin-prettier": "5.
|
|
53
|
+
"eslint-plugin-n": "17.21.3",
|
|
54
|
+
"eslint-plugin-prettier": "5.5.4",
|
|
54
55
|
"get-stream": "6.0.1",
|
|
55
56
|
"jest": "29.7.0",
|
|
56
|
-
"nodemon": "3.1.
|
|
57
|
+
"nodemon": "3.1.10",
|
|
57
58
|
"np": "8.0.4",
|
|
58
|
-
"prettier": "3.
|
|
59
|
+
"prettier": "3.6.2",
|
|
59
60
|
"xmltest": "2.0.3",
|
|
60
|
-
"yauzl": "3.2.
|
|
61
|
+
"yauzl": "3.2.1"
|
|
61
62
|
},
|
|
62
63
|
"bugs": {
|
|
63
64
|
"url": "https://github.com/xmldom/xmldom/issues"
|
|
@@ -69,5 +70,5 @@
|
|
|
69
70
|
"tagPrefix": "",
|
|
70
71
|
"template": "./auto-changelog.hbs"
|
|
71
72
|
},
|
|
72
|
-
"packageManager": "npm@11.
|
|
73
|
+
"packageManager": "npm@11.6.3+sha512.4085a763162e0e3acd19a4e9d23ad3aa0978e501ccf947dd7233c12a689ae0bb0190763c4ef12366990056b34eec438903ffed38fde4fbd722a17c2a7407ee92"
|
|
73
74
|
}
|
package/readme.md
CHANGED
|
@@ -289,6 +289,13 @@ import { DOMParser } from '@xmldom/xmldom'
|
|
|
289
289
|
- `isDefaultNamespace(namespaceURI)`
|
|
290
290
|
- `lookupNamespaceURI(prefix)`
|
|
291
291
|
|
|
292
|
+
### DOM Living Standard support:
|
|
293
|
+
|
|
294
|
+
* [ParentNode](https://dom.spec.whatwg.org/#interface-parentnode) mixin (on `Document`, `DocumentFragment`, `Element`)
|
|
295
|
+
|
|
296
|
+
readonly attribute:
|
|
297
|
+
- `children`
|
|
298
|
+
|
|
292
299
|
### DOM extension by xmldom
|
|
293
300
|
|
|
294
301
|
* [Node] Source position extension;
|