Permalink
Browse files

Merge branch 'tsgautier-master'

Also added tsgautier to contributors.

Closes #113
Closes #51
  • Loading branch information...
2 parents cd80292 + 8d1a9a6 commit ad05a0233cca3fce20ef003dbdf603de59454a5c @Leonidas-from-XIV committed Jan 2, 2014
Showing with 15 additions and 6 deletions.
  1. +1 −1 lib/xml2js.js
  2. +2 −1 package.json
  3. +1 −1 src/xml2js.coffee
  4. +11 −3 test/parser.test.coffee
View
Oops, something went wrong.
View
@@ -27,7 +27,8 @@
"Guido D'Albore <guido@bitstorm.it> (http://www.bitstorm.it/)",
"Jack Senechal (http://jacksenechal.com/)",
"Matthias Hölzl <tc@xantira.com> (https://github.com/hoelzl)",
- "Camille Reynders <info@creynders.be> (http://www.creynders.be/)"
+ "Camille Reynders <info@creynders.be> (http://www.creynders.be/)",
+ "Taylor Gautier (https://github.com/tsgautier)"
],
"main" : "./lib/xml2js",
"directories" : {
View
@@ -315,7 +315,7 @@ class exports.Parser extends events.EventEmitter
@emit "end", null
return true
- @saxParser.write bom.stripBOM str.toString()
+ @saxParser.write(bom.stripBOM str.toString()).close()
exports.parseString = (str, a, b) ->
# let's determine what we got as arguments
@@ -291,8 +291,10 @@ module.exports =
throw new Error 'error throwing in callback'
throw new Error 'error throwing outside'
catch e
- # don't catch the exception that was thrown by callback
- equ e.message, 'error throwing outside'
+ # the stream is finished by the time the parseString method is called
+ # so the callback, which is synchronous, will bubble the inner error
+ # out to here, make sure that happens
+ equ e.message, 'error throwing in callback'
test.finish()
'test xmlns': skeleton(xmlns: true, (r) ->
@@ -345,7 +347,13 @@ module.exports =
withoutNew.parseString demo, (err, resWithoutNew) ->
equ err, null
assert.deepEqual resWithNew, resWithoutNew
- test.done()
+ test.finish()
+
+ 'test not closed but well formed xml': (test) ->
+ xml = "<test>"
+ xml2js.parseString xml, (err, parsed) ->
+ assert.equal err.message, 'Unclosed root tag\nLine: 0\nColumn: 6\nChar: '
+ test.finish()
'test single attrNameProcessors': skeleton(attrNameProcessors: [nameToUpperCase], (r)->
console.log 'Result object: ' + util.inspect r, false, 10

0 comments on commit ad05a02

Please sign in to comment.