NaturalIntelligence / fast-xml-parser

Validate XML, Parse XML and Build XML rapidly without C/C++ based libraries and no callback.
https://naturalintelligence.github.io/fast-xml-parser/
MIT License
2.53k stars 303 forks source link

TypeError: Cannot read properties of undefined (reading 'tagName') when parsing closing tag without an opening tag at the start of XML document #620

Closed lulunac27a closed 6 months ago

lulunac27a commented 11 months ago

Description

I got an error saying TypeError: Cannot read properties of undefined (reading 'tagName') when I put closing tag at the start of XML document ### Input

</a>

Code

new XMLParser().parse('</a>');
XMLValidator().validate('</a>');

Output

TypeError: Cannot read properties of undefined (reading 'tagName')

expected data

Error: closing tag found at start of XML document Would you like to work on this issue?

Bookmark this repository for further updates. Visit SoloThought to know about recent features.

github-actions[bot] commented 11 months ago

We're glad you find this project helpful. We'll try to address this issue ASAP. You can vist https://solothought.com to know recent features. Don't forget to star this repo.

airone01 commented 7 months ago

I can confirm the bug and reproduce.

MaelAbgrall commented 7 months ago

I came here after a bug in prod that had the trace stating the same thing.

However, using lulunac27a example, I can only reproduce it in the online editor, can't on my dev machine with package version 4.3.5 and 4.3.4.

The trace I got from logs in prod is:

TypeError: Cannot read properties of undefined (reading 'tagName')
    at OrderedObjParser.parseXml (/backend/node_modules/fast-xml-parser/src/xmlparser/OrderedObjParser.js:281:29)
    at XMLParser.parse (/backend/node_modules/fast-xml-parser/src/xmlparser/XMLParser.js:35:48)