Leonidas-from-XIV / node-xml2js

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

Ignore invalid entity name #485

Closed swwind closed 5 years ago

swwind commented 5 years ago

I found it throw errors while parsing this invalid example:

<x>GL&HF</x>
Error: Invalid character in entity name

I know it's an invalid format, but in some time we should accept this mistake and parse it as blow:

{ x: "GL&HF" }

Hope to enhance it.

Leonidas-from-XIV commented 5 years ago

I think it is a mistake to try to parse faulty XML because it adds all kinds of unspecified semantics to the parser, like what does it do when X is wrong, what when Y is wrong? What if changing the implementation changes these semantics.

I think if you want to parse these entities, you should clean up the data before, then you'll know what is going on exactly.