@xmldom/xmldom 0.9.6 → 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 +44 -0
- package/index.d.ts +29 -3
- package/lib/conventions.js +1 -1
- package/lib/dom-parser.js +14 -7
- package/lib/dom.js +36 -22
- package/lib/grammar.js +5 -0
- package/lib/index.js +1 -0
- package/lib/sax.js +42 -16
- package/package.json +8 -10
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,50 @@ 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
|
+
|
|
25
|
+
## [0.9.7](https://github.com/xmldom/xmldom/compare/0.9.6...0.9.7)
|
|
26
|
+
|
|
27
|
+
### Added
|
|
28
|
+
|
|
29
|
+
- Implementation of `hasAttributes` [`#804`](https://github.com/xmldom/xmldom/pull/804)
|
|
30
|
+
|
|
31
|
+
### Fixed
|
|
32
|
+
|
|
33
|
+
- locator is now true even when other options are being used for the DOMParser [`#802`](https://github.com/xmldom/xmldom/issues/802) / [`#803`](https://github.com/xmldom/xmldom/pull/803)
|
|
34
|
+
- allow case-insensitive DOCTYPE in HTML [`#817`](https://github.com/xmldom/xmldom/issues/817) / [`#819`](https://github.com/xmldom/xmldom/pull/819)
|
|
35
|
+
|
|
36
|
+
### Performance
|
|
37
|
+
|
|
38
|
+
- simplify `DOM.compareDocumentPosition` [`#805`](https://github.com/xmldom/xmldom/pull/805)
|
|
39
|
+
|
|
40
|
+
### Chore
|
|
41
|
+
|
|
42
|
+
- updated devDependencies
|
|
43
|
+
|
|
44
|
+
Thank you,
|
|
45
|
+
[@zorkow](https://github.com/zorkow),
|
|
46
|
+
[@Ponynjaa](https://github.com/Ponynjaa),
|
|
47
|
+
[@WesselKroos](https://github.com/WesselKroos),
|
|
48
|
+
for your contributions.
|
|
49
|
+
|
|
50
|
+
|
|
7
51
|
## [0.9.6](https://github.com/xmldom/xmldom/compare/0.9.5...0.9.6)
|
|
8
52
|
|
|
9
53
|
### Fixed
|
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/conventions.js
CHANGED
|
@@ -324,7 +324,7 @@ var MIME_TYPE = freeze({
|
|
|
324
324
|
XML_APPLICATION: 'application/xml',
|
|
325
325
|
|
|
326
326
|
/**
|
|
327
|
-
* `text/
|
|
327
|
+
* `text/xml`, an alias for `application/xml`.
|
|
328
328
|
*
|
|
329
329
|
* @see https://tools.ietf.org/html/rfc7303#section-9.2 RFC 7303
|
|
330
330
|
* @see https://www.iana.org/assignments/media-types/text/xml IANA MimeType registration
|
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.
|
|
@@ -101,7 +105,10 @@ function normalizeLineEndings(input) {
|
|
|
101
105
|
* @see https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#dom-parsing-and-serialization
|
|
102
106
|
*/
|
|
103
107
|
function DOMParser(options) {
|
|
104
|
-
options = options || {
|
|
108
|
+
options = options || {};
|
|
109
|
+
if (options.locator === undefined) {
|
|
110
|
+
options.locator = true;
|
|
111
|
+
}
|
|
105
112
|
|
|
106
113
|
/**
|
|
107
114
|
* The method to use instead of `conventions.assign`, which is used to copy values from
|
package/lib/dom.js
CHANGED
|
@@ -257,23 +257,6 @@ var DocumentPosition = conventions.freeze({
|
|
|
257
257
|
});
|
|
258
258
|
|
|
259
259
|
//helper functions for compareDocumentPosition
|
|
260
|
-
/**
|
|
261
|
-
* Constructs a parent chain for a node.
|
|
262
|
-
*
|
|
263
|
-
* @param {Node} node
|
|
264
|
-
* The start node from which the parent chain will be constructed.
|
|
265
|
-
* @returns {Node[]}
|
|
266
|
-
* The array of nodes representing the parent chain from the root to the specified node.
|
|
267
|
-
*/
|
|
268
|
-
function parentChain(node) {
|
|
269
|
-
var chain = [];
|
|
270
|
-
while (node.parentNode || node.ownerElement) {
|
|
271
|
-
node = node.parentNode || node.ownerElement;
|
|
272
|
-
chain.unshift(node);
|
|
273
|
-
}
|
|
274
|
-
return chain;
|
|
275
|
-
}
|
|
276
|
-
|
|
277
260
|
/**
|
|
278
261
|
* Finds the common ancestor in two parent chains.
|
|
279
262
|
*
|
|
@@ -1476,15 +1459,36 @@ Node.prototype = {
|
|
|
1476
1459
|
: DocumentPosition.DOCUMENT_POSITION_PRECEDING)
|
|
1477
1460
|
);
|
|
1478
1461
|
}
|
|
1479
|
-
|
|
1480
|
-
var chain2 = parentChain(node2);
|
|
1481
|
-
if ((!attr1 && chain2.indexOf(node1) >= 0) || (attr2 && node1 === node2)) {
|
|
1462
|
+
if (attr2 && node1 === node2) {
|
|
1482
1463
|
return DocumentPosition.DOCUMENT_POSITION_CONTAINS + DocumentPosition.DOCUMENT_POSITION_PRECEDING;
|
|
1483
1464
|
}
|
|
1484
|
-
if (
|
|
1465
|
+
if (attr1 && node1 === node2) {
|
|
1485
1466
|
return DocumentPosition.DOCUMENT_POSITION_CONTAINED_BY + DocumentPosition.DOCUMENT_POSITION_FOLLOWING;
|
|
1486
1467
|
}
|
|
1487
|
-
|
|
1468
|
+
|
|
1469
|
+
var chain1 = [];
|
|
1470
|
+
var ancestor1 = node1.parentNode;
|
|
1471
|
+
while (ancestor1) {
|
|
1472
|
+
if (!attr2 && ancestor1 === node2) {
|
|
1473
|
+
return DocumentPosition.DOCUMENT_POSITION_CONTAINED_BY + DocumentPosition.DOCUMENT_POSITION_FOLLOWING;
|
|
1474
|
+
}
|
|
1475
|
+
chain1.push(ancestor1);
|
|
1476
|
+
ancestor1 = ancestor1.parentNode;
|
|
1477
|
+
}
|
|
1478
|
+
chain1.reverse();
|
|
1479
|
+
|
|
1480
|
+
var chain2 = [];
|
|
1481
|
+
var ancestor2 = node2.parentNode;
|
|
1482
|
+
while (ancestor2) {
|
|
1483
|
+
if (!attr1 && ancestor2 === node1) {
|
|
1484
|
+
return DocumentPosition.DOCUMENT_POSITION_CONTAINS + DocumentPosition.DOCUMENT_POSITION_PRECEDING;
|
|
1485
|
+
}
|
|
1486
|
+
chain2.push(ancestor2);
|
|
1487
|
+
ancestor2 = ancestor2.parentNode;
|
|
1488
|
+
}
|
|
1489
|
+
chain2.reverse();
|
|
1490
|
+
|
|
1491
|
+
var ca = commonAncestor(chain1, chain2);
|
|
1488
1492
|
for (var n in ca.childNodes) {
|
|
1489
1493
|
var child = ca.childNodes[n];
|
|
1490
1494
|
if (child === node2) return DocumentPosition.DOCUMENT_POSITION_FOLLOWING;
|
|
@@ -2353,6 +2357,16 @@ Element.prototype = {
|
|
|
2353
2357
|
_isInHTMLDocumentAndNamespace: function () {
|
|
2354
2358
|
return this.ownerDocument.type === 'html' && this.namespaceURI === NAMESPACE.HTML;
|
|
2355
2359
|
},
|
|
2360
|
+
/**
|
|
2361
|
+
* Implementaton of Level2 Core function hasAttributes.
|
|
2362
|
+
*
|
|
2363
|
+
* @returns {boolean}
|
|
2364
|
+
* True if attribute list is not empty.
|
|
2365
|
+
* @see https://www.w3.org/TR/DOM-Level-2-Core/#core-ID-NodeHasAttrs
|
|
2366
|
+
*/
|
|
2367
|
+
hasAttributes: function () {
|
|
2368
|
+
return !!(this.attributes && this.attributes.length);
|
|
2369
|
+
},
|
|
2356
2370
|
hasAttribute: function (name) {
|
|
2357
2371
|
return !!this.getAttributeNode(name);
|
|
2358
2372
|
},
|
package/lib/grammar.js
CHANGED
|
@@ -381,6 +381,9 @@ var ATTLIST_DECL_START = '<!ATTLIST';
|
|
|
381
381
|
// to support XML without namespaces in DTD we can not restrict it to QName
|
|
382
382
|
var AttlistDecl = reg(ATTLIST_DECL_START, S, Name, AttDef, '*', S_OPT, '>');
|
|
383
383
|
|
|
384
|
+
// https://html.spec.whatwg.org/multipage/urls-and-fetching.html#about:legacy-compat
|
|
385
|
+
var ABOUT_LEGACY_COMPAT = 'about:legacy-compat';
|
|
386
|
+
var ABOUT_LEGACY_COMPAT_SystemLiteral = regg('"' + ABOUT_LEGACY_COMPAT + '"', '|', "'" + ABOUT_LEGACY_COMPAT + "'");
|
|
384
387
|
var SYSTEM = 'SYSTEM';
|
|
385
388
|
var PUBLIC = 'PUBLIC';
|
|
386
389
|
// https://www.w3.org/TR/xml11/#NT-ExternalID
|
|
@@ -494,6 +497,8 @@ exports.chars_without = chars_without;
|
|
|
494
497
|
exports.detectUnicodeSupport = detectUnicodeSupport;
|
|
495
498
|
exports.reg = reg;
|
|
496
499
|
exports.regg = regg;
|
|
500
|
+
exports.ABOUT_LEGACY_COMPAT = ABOUT_LEGACY_COMPAT;
|
|
501
|
+
exports.ABOUT_LEGACY_COMPAT_SystemLiteral = ABOUT_LEGACY_COMPAT_SystemLiteral;
|
|
497
502
|
exports.AttlistDecl = AttlistDecl;
|
|
498
503
|
exports.CDATA_START = CDATA_START;
|
|
499
504
|
exports.CDATA_END = CDATA_END;
|
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
|
}
|
|
@@ -587,8 +587,10 @@ function _copy(source, target) {
|
|
|
587
587
|
* @property {function(): string} substringFromIndex
|
|
588
588
|
* creates a substring from the current index to the end of `source`
|
|
589
589
|
* @property {function(compareWith: string): boolean} substringStartsWith
|
|
590
|
-
* Checks if source contains `compareWith`,
|
|
591
|
-
*
|
|
590
|
+
* Checks if `source` contains `compareWith`, starting from the current index.
|
|
591
|
+
* @property {function(compareWith: string): boolean} substringStartsWithCaseInsensitive
|
|
592
|
+
* Checks if `source` contains `compareWith`, starting from the current index,
|
|
593
|
+
* comparing the upper case of both sides.
|
|
592
594
|
* @see {@link parseUtils}
|
|
593
595
|
*/
|
|
594
596
|
|
|
@@ -634,6 +636,9 @@ function parseUtils(source, start) {
|
|
|
634
636
|
function substringStartsWith(text) {
|
|
635
637
|
return source.substring(index, index + text.length) === text;
|
|
636
638
|
}
|
|
639
|
+
function substringStartsWithCaseInsensitive(text) {
|
|
640
|
+
return source.substring(index, index + text.length).toUpperCase() === text.toUpperCase();
|
|
641
|
+
}
|
|
637
642
|
|
|
638
643
|
function getMatch(args) {
|
|
639
644
|
var expr = g.reg('^', args);
|
|
@@ -657,6 +662,7 @@ function parseUtils(source, start) {
|
|
|
657
662
|
skipBlanks: skipBlanks,
|
|
658
663
|
substringFromIndex: substringFromIndex,
|
|
659
664
|
substringStartsWith: substringStartsWith,
|
|
665
|
+
substringStartsWithCaseInsensitive: substringStartsWithCaseInsensitive,
|
|
660
666
|
};
|
|
661
667
|
}
|
|
662
668
|
|
|
@@ -753,7 +759,7 @@ function parseDoctypeInternalSubset(p, errorHandler) {
|
|
|
753
759
|
function parseDoctypeCommentOrCData(source, start, domBuilder, errorHandler, isHTML) {
|
|
754
760
|
var p = parseUtils(source, start);
|
|
755
761
|
|
|
756
|
-
switch (p.char(2)) {
|
|
762
|
+
switch (isHTML ? p.char(2).toUpperCase() : p.char(2)) {
|
|
757
763
|
case '-':
|
|
758
764
|
// should be a comment
|
|
759
765
|
var comment = p.getMatch(g.Comment);
|
|
@@ -782,7 +788,7 @@ function parseDoctypeCommentOrCData(source, start, domBuilder, errorHandler, isH
|
|
|
782
788
|
if (domBuilder.doc && domBuilder.doc.documentElement) {
|
|
783
789
|
return errorHandler.fatalError('Doctype not allowed inside or after documentElement at position ' + p.getIndex());
|
|
784
790
|
}
|
|
785
|
-
if (!p.substringStartsWith(g.DOCTYPE_DECL_START)) {
|
|
791
|
+
if (isHTML ? !p.substringStartsWithCaseInsensitive(g.DOCTYPE_DECL_START) : !p.substringStartsWith(g.DOCTYPE_DECL_START)) {
|
|
786
792
|
return errorHandler.fatalError('Expected ' + g.DOCTYPE_DECL_START + ' at position ' + p.getIndex());
|
|
787
793
|
}
|
|
788
794
|
p.skip(g.DOCTYPE_DECL_START.length);
|
|
@@ -800,6 +806,10 @@ function parseDoctypeCommentOrCData(source, start, domBuilder, errorHandler, isH
|
|
|
800
806
|
doctype.name = p.getMatch(g.Name);
|
|
801
807
|
if (!doctype.name)
|
|
802
808
|
return errorHandler.fatalError('doctype name missing or contains unexpected characters at position ' + p.getIndex());
|
|
809
|
+
|
|
810
|
+
if (isHTML && doctype.name.toLowerCase() !== 'html') {
|
|
811
|
+
errorHandler.warning('Unexpected DOCTYPE in HTML document at position ' + p.getIndex());
|
|
812
|
+
}
|
|
803
813
|
p.skipBlanks();
|
|
804
814
|
|
|
805
815
|
// Check for ExternalID
|
|
@@ -815,10 +825,26 @@ function parseDoctypeCommentOrCData(source, start, domBuilder, errorHandler, isH
|
|
|
815
825
|
doctype.publicId = match.groups.PubidLiteral;
|
|
816
826
|
}
|
|
817
827
|
p.skip(match[0].length);
|
|
828
|
+
} else if (isHTML && p.substringStartsWithCaseInsensitive(g.SYSTEM)) {
|
|
829
|
+
// https://html.spec.whatwg.org/multipage/syntax.html#doctype-legacy-string
|
|
830
|
+
p.skip(g.SYSTEM.length);
|
|
831
|
+
if (p.skipBlanks() < 1) {
|
|
832
|
+
return errorHandler.fatalError('Expected whitespace after ' + g.SYSTEM + ' at position ' + p.getIndex());
|
|
833
|
+
}
|
|
834
|
+
doctype.systemId = p.getMatch(g.ABOUT_LEGACY_COMPAT_SystemLiteral);
|
|
835
|
+
if (!doctype.systemId) {
|
|
836
|
+
return errorHandler.fatalError(
|
|
837
|
+
'Expected ' + g.ABOUT_LEGACY_COMPAT + ' in single or double quotes after ' + g.SYSTEM + ' at position ' + p.getIndex()
|
|
838
|
+
);
|
|
839
|
+
}
|
|
840
|
+
}
|
|
841
|
+
if (isHTML && doctype.systemId && !g.ABOUT_LEGACY_COMPAT_SystemLiteral.test(doctype.systemId)) {
|
|
842
|
+
errorHandler.warning('Unexpected doctype.systemId in HTML document at position ' + p.getIndex());
|
|
843
|
+
}
|
|
844
|
+
if (!isHTML) {
|
|
845
|
+
p.skipBlanks();
|
|
846
|
+
doctype.internalSubset = parseDoctypeInternalSubset(p, errorHandler);
|
|
818
847
|
}
|
|
819
|
-
|
|
820
|
-
p.skipBlanks();
|
|
821
|
-
doctype.internalSubset = parseDoctypeInternalSubset(p, errorHandler);
|
|
822
848
|
p.skipBlanks();
|
|
823
849
|
if (p.char() !== '>') {
|
|
824
850
|
return errorHandler.fatalError('doctype not terminated with > at position ' + p.getIndex());
|
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
|
-
"eslint-config-prettier": "
|
|
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
|
-
"eslint-plugin-n": "17.
|
|
55
|
-
"eslint-plugin-prettier": "5.2.
|
|
52
|
+
"eslint-plugin-n": "17.15.1",
|
|
53
|
+
"eslint-plugin-prettier": "5.2.3",
|
|
56
54
|
"get-stream": "6.0.1",
|
|
57
55
|
"jest": "29.7.0",
|
|
58
|
-
"nodemon": "3.1.
|
|
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
|
}
|