Skip to content

Commit 4c9e619

Browse files
committed
v1.2.6: [fix] convert xml to string before calling .trim
fixes segmentio#20
1 parent 32b6dde commit 4c9e619

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

index.js

+8-4
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ module.exports = parse;
2020
*/
2121

2222
function parse(xml) {
23-
xml = xml.trim();
23+
xml = String(xml).trim();
2424

2525
// strip comments
2626
xml = xml.replace(/<!--[\s\S]*?-->/g, '');
@@ -32,10 +32,14 @@ function parse(xml) {
3232
*/
3333

3434
function document() {
35-
return {
36-
declaration: declaration(),
37-
root: tag()
35+
var doc = { declaration: declaration() }, moreDecl;
36+
while (true) {
37+
moreDecl = declaration();
38+
if (!moreDecl) { break; }
39+
doc.declaration += moreDecl;
3840
}
41+
doc.root = tag();
42+
return doc;
3943
}
4044

4145
/**

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{ "name": "xml-parser-fix-pmb",
2-
"version": "1.2.5",
2+
"version": "1.2.6",
33
"description": "A fork of segmentio's simple non-compliant XML parser for nodejs, forked in order to maintain it.",
44
"keywords": [
55
"non-compliant",

0 commit comments

Comments
 (0)