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.45k stars 296 forks source link

Exception thrown by validator if unopened tag closes #573

Open guillermoheras-bjss opened 1 year ago

guillermoheras-bjss commented 1 year ago

Description

A closing tag that hasn't been opened causes an exception to be thrown, instead of returning a validation error (as would be expected)

Code

import { XMLValidator } from "fast-xml-parser";

// This throws an exception
XMLValidator.validate("<Document>some text</Document></badTag>");

Output

Exception thrown:

TypeError: Cannot read properties of undefined (reading 'tagName') at exports.validate (/home/guillermoheras/lhv/banking-services/apps/portal/node_modules/fast-xml-parser/src/validator.js:108:33)

expected data

a ValidationError object should be returned

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 1 year 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.

PCOffline commented 1 year ago

Hey I'm facing the same issue and would love a fix