Skip to content

Commit

Permalink
Revert "Empty strings now returns error cause its not valid XML"
Browse files Browse the repository at this point in the history
This reverts commit b9b44e0.
  • Loading branch information
Leonidas-from-XIV committed Aug 22, 2017
1 parent 51ce146 commit 1ab44ea
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 10 deletions.
4 changes: 2 additions & 2 deletions lib/parser.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"json"
],
"homepage": "https://github.com/Leonidas-from-XIV/node-xml2js",
"version": "0.4.18",
"version": "0.4.19",
"author": "Marek Kubica <[email protected]> (https://xivilization.net)",
"contributors": [
"maqr <[email protected]> (https://github.com/maqr)",
Expand Down
4 changes: 2 additions & 2 deletions src/parser.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -237,8 +237,8 @@ class exports.Parser extends events.EventEmitter
try
str = str.toString()
if str.trim() is ''
@emit 'error', new Error "Empty string is not valid XML"
return
@emit "end", null
return true

str = bom.stripBOM str
if @options.async
Expand Down
7 changes: 2 additions & 5 deletions test/parser.test.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -254,11 +254,8 @@ module.exports =
'test empty tag result specified null': skeleton(emptyTag: null, (r) ->
equ r.sample.emptytest[0], null)

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

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

0 comments on commit 1ab44ea

Please sign in to comment.