@xmldom/xmldom 0.9.7 → 0.9.8
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 +18 -0
- package/index.d.ts +29 -3
- package/lib/dom-parser.js +10 -6
- package/lib/index.js +1 -0
- package/lib/sax.js +9 -9
- package/package.json +5 -7
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,24 @@ 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.8](https://github.com/xmldom/xmldom/compare/0.9.8...0.9.7)
|
|
8
|
+
|
|
9
|
+
### Fixed
|
|
10
|
+
|
|
11
|
+
- fix: replace \u2029 as part of normalizeLineEndings [`#839`](https://github.com/xmldom/xmldom/pull/839) / [`#838`](https://github.com/xmldom/xmldom/issues/838)
|
|
12
|
+
- perf: speed up line detection [`#847`](https://github.com/xmldom/xmldom/pull/847) / [`#838`](https://github.com/xmldom/xmldom/issues/838)
|
|
13
|
+
|
|
14
|
+
### Chore
|
|
15
|
+
|
|
16
|
+
- updated dependencies
|
|
17
|
+
- drop jazzer and rxjs devDependencies [`#845`](https://github.com/xmldom/xmldom/pull/845)
|
|
18
|
+
|
|
19
|
+
Thank you,
|
|
20
|
+
[@kboshold](https://github.com/kboshold),
|
|
21
|
+
[@Ponynjaa](https://github.com/Ponynjaa),
|
|
22
|
+
for your contributions.
|
|
23
|
+
|
|
24
|
+
|
|
7
25
|
## [0.9.7](https://github.com/xmldom/xmldom/compare/0.9.6...0.9.7)
|
|
8
26
|
|
|
9
27
|
### Added
|
package/index.d.ts
CHANGED
|
@@ -1527,12 +1527,15 @@ declare module '@xmldom/xmldom' {
|
|
|
1527
1527
|
readonly locator?: boolean;
|
|
1528
1528
|
|
|
1529
1529
|
/**
|
|
1530
|
-
* used to replace line endings before parsing, defaults to `normalizeLineEndings`,
|
|
1531
|
-
* which normalizes line endings according to <https://www.w3.org/TR/xml11/#sec-line-ends
|
|
1530
|
+
* used to replace line endings before parsing, defaults to exported `normalizeLineEndings`,
|
|
1531
|
+
* which normalizes line endings according to <https://www.w3.org/TR/xml11/#sec-line-ends>,
|
|
1532
|
+
* including some Unicode "newline" characters.
|
|
1533
|
+
*
|
|
1534
|
+
* @see {@link normalizeLineEndings}
|
|
1532
1535
|
*/
|
|
1533
1536
|
readonly normalizeLineEndings?: (source: string) => string;
|
|
1534
1537
|
/**
|
|
1535
|
-
* A function
|
|
1538
|
+
* A function invoked for every error that occurs during parsing.
|
|
1536
1539
|
*
|
|
1537
1540
|
* If it is not provided, all errors are reported to `console.error`
|
|
1538
1541
|
* and only `fatalError`s are thrown as a `ParseError`,
|
|
@@ -1572,6 +1575,29 @@ declare module '@xmldom/xmldom' {
|
|
|
1572
1575
|
): void;
|
|
1573
1576
|
}
|
|
1574
1577
|
|
|
1578
|
+
/**
|
|
1579
|
+
* Normalizes line ending according to <https://www.w3.org/TR/xml11/#sec-line-ends>,
|
|
1580
|
+
* including some Unicode "newline" characters:
|
|
1581
|
+
*
|
|
1582
|
+
* > XML parsed entities are often stored in computer files which,
|
|
1583
|
+
* > for editing convenience, are organized into lines.
|
|
1584
|
+
* > These lines are typically separated by some combination
|
|
1585
|
+
* > of the characters CARRIAGE RETURN (#xD) and LINE FEED (#xA).
|
|
1586
|
+
* >
|
|
1587
|
+
* > To simplify the tasks of applications, the XML processor must behave
|
|
1588
|
+
* > as if it normalized all line breaks in external parsed entities (including the document entity)
|
|
1589
|
+
* > on input, before parsing, by translating the following to a single #xA character:
|
|
1590
|
+
* >
|
|
1591
|
+
* > 1. the two-character sequence #xD #xA,
|
|
1592
|
+
* > 2. the two-character sequence #xD #x85,
|
|
1593
|
+
* > 3. the single character #x85,
|
|
1594
|
+
* > 4. the single character #x2028,
|
|
1595
|
+
* > 5. the single character #x2029,
|
|
1596
|
+
* > 6. any #xD character that is not immediately followed by #xA or #x85.
|
|
1597
|
+
*
|
|
1598
|
+
* @prettierignore
|
|
1599
|
+
*/
|
|
1600
|
+
function normalizeLineEndings(input: string): string;
|
|
1575
1601
|
/**
|
|
1576
1602
|
* A method that prevents any further parsing when an `error`
|
|
1577
1603
|
* with level `error` is reported during parsing.
|
package/lib/dom-parser.js
CHANGED
|
@@ -18,7 +18,8 @@ var ParseError = errors.ParseError;
|
|
|
18
18
|
var XMLReader = sax.XMLReader;
|
|
19
19
|
|
|
20
20
|
/**
|
|
21
|
-
* Normalizes line ending according to <https://www.w3.org/TR/xml11/#sec-line-ends
|
|
21
|
+
* Normalizes line ending according to <https://www.w3.org/TR/xml11/#sec-line-ends>,
|
|
22
|
+
* including some Unicode "newline" characters:
|
|
22
23
|
*
|
|
23
24
|
* > XML parsed entities are often stored in computer files which,
|
|
24
25
|
* > for editing convenience, are organized into lines.
|
|
@@ -27,20 +28,21 @@ var XMLReader = sax.XMLReader;
|
|
|
27
28
|
* >
|
|
28
29
|
* > To simplify the tasks of applications, the XML processor must behave
|
|
29
30
|
* > as if it normalized all line breaks in external parsed entities (including the document entity)
|
|
30
|
-
* > on input, before parsing, by translating
|
|
31
|
+
* > on input, before parsing, by translating the following to a single #xA character:
|
|
31
32
|
* >
|
|
32
33
|
* > 1. the two-character sequence #xD #xA,
|
|
33
34
|
* > 2. the two-character sequence #xD #x85,
|
|
34
35
|
* > 3. the single character #x85,
|
|
35
36
|
* > 4. the single character #x2028,
|
|
36
|
-
* > 5.
|
|
37
|
+
* > 5. the single character #x2029,
|
|
38
|
+
* > 6. any #xD character that is not immediately followed by #xA or #x85.
|
|
37
39
|
*
|
|
38
40
|
* @param {string} input
|
|
39
41
|
* @returns {string}
|
|
40
42
|
* @prettierignore
|
|
41
43
|
*/
|
|
42
44
|
function normalizeLineEndings(input) {
|
|
43
|
-
return input.replace(/\r[\n\u0085]/g, '\n').replace(/[\r\u0085\u2028]/g, '\n');
|
|
45
|
+
return input.replace(/\r[\n\u0085]/g, '\n').replace(/[\r\u0085\u2028\u2029]/g, '\n');
|
|
44
46
|
}
|
|
45
47
|
|
|
46
48
|
/**
|
|
@@ -63,7 +65,7 @@ function normalizeLineEndings(input) {
|
|
|
63
65
|
* DEPRECATED! use `onError` instead.
|
|
64
66
|
* @property {function(level:ErrorLevel, message:string, context: DOMHandler):void}
|
|
65
67
|
* [onError]
|
|
66
|
-
* A function
|
|
68
|
+
* A function invoked for every error that occurs during parsing.
|
|
67
69
|
*
|
|
68
70
|
* If it is not provided, all errors are reported to `console.error`
|
|
69
71
|
* and only `fatalError`s are thrown as a `ParseError`,
|
|
@@ -78,7 +80,9 @@ function normalizeLineEndings(input) {
|
|
|
78
80
|
* attribute describing their location in the XML string.
|
|
79
81
|
* Default is true.
|
|
80
82
|
* @property {(string) => string} [normalizeLineEndings]
|
|
81
|
-
* used to replace line endings before parsing, defaults to `normalizeLineEndings
|
|
83
|
+
* used to replace line endings before parsing, defaults to exported `normalizeLineEndings`,
|
|
84
|
+
* which normalizes line endings according to <https://www.w3.org/TR/xml11/#sec-line-ends>,
|
|
85
|
+
* including some Unicode "newline" characters.
|
|
82
86
|
* @property {Object} [xmlns]
|
|
83
87
|
* The XML namespaces that should be assumed when parsing.
|
|
84
88
|
* The default namespace can be provided by the key that is the empty string.
|
package/lib/index.js
CHANGED
|
@@ -36,5 +36,6 @@ exports.XMLSerializer = dom.XMLSerializer;
|
|
|
36
36
|
|
|
37
37
|
var domParser = require('./dom-parser');
|
|
38
38
|
exports.DOMParser = domParser.DOMParser;
|
|
39
|
+
exports.normalizeLineEndings = domParser.normalizeLineEndings;
|
|
39
40
|
exports.onErrorStopParsing = domParser.onErrorStopParsing;
|
|
40
41
|
exports.onWarningStopParsing = domParser.onWarningStopParsing;
|
package/lib/sax.js
CHANGED
|
@@ -81,7 +81,7 @@ function parse(source, defaultNSMapCopy, entityMap, domBuilder, errorHandler) {
|
|
|
81
81
|
if (hasOwn(entityMap, k)) {
|
|
82
82
|
return entityMap[k];
|
|
83
83
|
} else if (k.charAt(0) === '#') {
|
|
84
|
-
return fixedFromCharCode(parseInt(k.
|
|
84
|
+
return fixedFromCharCode(parseInt(k.substring(1).replace('x', '0x')));
|
|
85
85
|
} else {
|
|
86
86
|
errorHandler.error('entity not found:' + a);
|
|
87
87
|
return a;
|
|
@@ -98,20 +98,20 @@ function parse(source, defaultNSMapCopy, entityMap, domBuilder, errorHandler) {
|
|
|
98
98
|
}
|
|
99
99
|
}
|
|
100
100
|
|
|
101
|
+
var lineStart = 0;
|
|
102
|
+
var lineEnd = 0;
|
|
103
|
+
var linePattern = /\r\n?|\n|$/g;
|
|
104
|
+
var locator = domBuilder.locator;
|
|
105
|
+
|
|
101
106
|
function position(p, m) {
|
|
102
107
|
while (p >= lineEnd && (m = linePattern.exec(source))) {
|
|
103
|
-
lineStart =
|
|
104
|
-
lineEnd =
|
|
108
|
+
lineStart = lineEnd;
|
|
109
|
+
lineEnd = m.index + m[0].length;
|
|
105
110
|
locator.lineNumber++;
|
|
106
111
|
}
|
|
107
112
|
locator.columnNumber = p - lineStart + 1;
|
|
108
113
|
}
|
|
109
114
|
|
|
110
|
-
var lineStart = 0;
|
|
111
|
-
var lineEnd = 0;
|
|
112
|
-
var linePattern = /.*(?:\r\n?|\n)|.*$/g;
|
|
113
|
-
var locator = domBuilder.locator;
|
|
114
|
-
|
|
115
115
|
var parseStack = [{ currentNSMap: defaultNSMapCopy }];
|
|
116
116
|
var unclosedTags = [];
|
|
117
117
|
var start = 0;
|
|
@@ -124,7 +124,7 @@ function parse(source, defaultNSMapCopy, entityMap, domBuilder, errorHandler) {
|
|
|
124
124
|
}
|
|
125
125
|
if (!source.substring(start).match(/^\s*$/)) {
|
|
126
126
|
var doc = domBuilder.doc;
|
|
127
|
-
var text = doc.createTextNode(source.
|
|
127
|
+
var text = doc.createTextNode(source.substring(start));
|
|
128
128
|
if (doc.documentElement) {
|
|
129
129
|
return errorHandler.error('Extra content at the end of the document');
|
|
130
130
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xmldom/xmldom",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.8",
|
|
4
4
|
"description": "A pure JavaScript W3C standard-based (XML DOM Level 2 Core) DOMParser and XMLSerializer module.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"w3c",
|
|
@@ -44,21 +44,18 @@
|
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
46
|
"@homer0/prettier-plugin-jsdoc": "9.1.0",
|
|
47
|
-
"@jazzer.js/core": "2.1.0",
|
|
48
|
-
"@jazzer.js/jest-runner": "2.1.0",
|
|
49
47
|
"auto-changelog": "2.5.0",
|
|
50
48
|
"eslint": "8.57.1",
|
|
51
49
|
"eslint-config-prettier": "10.0.1",
|
|
52
50
|
"eslint-plugin-anti-trojan-source": "1.1.1",
|
|
53
51
|
"eslint-plugin-es5": "1.5.0",
|
|
54
52
|
"eslint-plugin-n": "17.15.1",
|
|
55
|
-
"eslint-plugin-prettier": "5.2.
|
|
53
|
+
"eslint-plugin-prettier": "5.2.3",
|
|
56
54
|
"get-stream": "6.0.1",
|
|
57
55
|
"jest": "29.7.0",
|
|
58
56
|
"nodemon": "3.1.9",
|
|
59
57
|
"np": "8.0.4",
|
|
60
|
-
"prettier": "3.
|
|
61
|
-
"rxjs": "7.8.1",
|
|
58
|
+
"prettier": "3.5.2",
|
|
62
59
|
"xmltest": "2.0.3",
|
|
63
60
|
"yauzl": "3.2.0"
|
|
64
61
|
},
|
|
@@ -71,5 +68,6 @@
|
|
|
71
68
|
"remote": "origin",
|
|
72
69
|
"tagPrefix": "",
|
|
73
70
|
"template": "./auto-changelog.hbs"
|
|
74
|
-
}
|
|
71
|
+
},
|
|
72
|
+
"packageManager": "npm@11.1.0+sha512.acf301ad9b9ddba948fcb72341e2f0fcae477f56a95cc2a092934d133a7461062633cefbf93d5934a3dc0768674e2edee9f04dcfcc4bb4c327ff0e3a7d552a1b"
|
|
75
73
|
}
|