Leonidas-from-XIV / node-xml2js

XML to JavaScript object converter.
MIT License
4.88k stars 604 forks source link

Bug - builder.buildObject(rootObj) fails if rootObj is an array of length 1 #630

Open camu-aca1 opened 3 years ago

camu-aca1 commented 3 years ago

v0.4.23 - Calling builder.buildObject(rootObj) with an array of length 1 wrongly interprets the index 0 as root element name, resulting in a 'Invalid character in name' exception. The following test in builder.coffee line 36 should check for array argument first: if ( Object.keys(rootObj).length is 1 ) and ( @options.rootName == defaults['0.2'].rootName )...