Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

XMLValidator does not give error if XML declaration is not at the starting of XML #601

Open
5 of 6 tasks
asthaaaaaa opened this issue Aug 3, 2023 · 1 comment
Open
5 of 6 tasks
Labels
Pending Pending to be confirmed by user/author for some check/update/implementation

Comments

@asthaaaaaa
Copy link

asthaaaaaa commented Aug 3, 2023

  • Are you running the latest version?
  • Have you included sample input, output, error, and expected output?
  • Have you checked if you are using correct configuration?
  • Did you try online tool?

Description

Input

Try to validate this XML<note><?xml version="1.0" encoding="utf-8"?>test</note>

Code

XMLValidator.validate(`<note><?xml version="1.0" encoding="utf-8"?>test</note>`)

Output

XMLValidator returns true

expected data

XMLValidator.validate should return error with message XML declaration allowed only at the start of the document.
https://github.com/NaturalIntelligence/fast-xml-parser/blob/3c9e9fe4346a3c9924d4db45e60a7a29c565caac/src/validator.js#L206C46-L206C104

Additional Notes:

const tagname = xmlData.substr(start, i - start);
is the Root cause of the issue, as start = i in our case and tagname become ""

Would you like to work on this issue?

  • Yes
  • No

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

@github-actions
Copy link

github-actions bot commented Aug 3, 2023

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.

@amitguptagwl amitguptagwl added the Pending Pending to be confirmed by user/author for some check/update/implementation label Aug 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Pending Pending to be confirmed by user/author for some check/update/implementation
Projects
None yet
Development

No branches or pull requests

2 participants