Skip to content

Commit 1ab44ea

Browse files
Revert "Empty strings now returns error cause its not valid XML"
This reverts commit b9b44e0.
1 parent 51ce146 commit 1ab44ea

4 files changed

Lines changed: 7 additions & 10 deletions

File tree

lib/parser.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"json"
77
],
88
"homepage": "https://github.com/Leonidas-from-XIV/node-xml2js",
9-
"version": "0.4.18",
9+
"version": "0.4.19",
1010
"author": "Marek Kubica <[email protected]> (https://xivilization.net)",
1111
"contributors": [
1212
"maqr <[email protected]> (https://github.com/maqr)",

src/parser.coffee

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -237,8 +237,8 @@ class exports.Parser extends events.EventEmitter
237237
try
238238
str = str.toString()
239239
if str.trim() is ''
240-
@emit 'error', new Error "Empty string is not valid XML"
241-
return
240+
@emit "end", null
241+
return true
242242

243243
str = bom.stripBOM str
244244
if @options.async

test/parser.test.coffee

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -254,11 +254,8 @@ module.exports =
254254
'test empty tag result specified null': skeleton(emptyTag: null, (r) ->
255255
equ r.sample.emptytest[0], null)
256256

257-
'test invalid empty XML file': (test) ->
258-
x2js = new xml2js.Parser()
259-
x2js.parseString '', (err, r) ->
260-
assert.notEqual err, null
261-
test.finish()
257+
'test invalid empty XML file': skeleton(__xmlString: ' ', (r) ->
258+
equ r, null)
262259

263260
'test enabled normalizeTags': skeleton(normalizeTags: true, (r) ->
264261
console.log 'Result object: ' + util.inspect r, false, 10

0 commit comments

Comments
 (0)