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

Parsing an invalid XML element #618

Open
bendrissou opened this issue Oct 3, 2023 · 1 comment
Open

Parsing an invalid XML element #618

bendrissou opened this issue Oct 3, 2023 · 1 comment
Labels

Comments

@bendrissou
Copy link

Description

The parser accepts and parses a XML element that is syntactically invalid, without raising an error. This is despite enabling the validator option "-v".

Input

<?xml version="1.0" ?>  <a/> <! <!---->  	

In the above example, token <! is duplicated, which I expected to raise an error. The input is saved in a file named example.xml.

Code

./src/cli/cli.js -v example.xml

Output

{ '?xml': { '@_version': 1 }, a: '', '!': '' }

My question is: Why the XML validator doesn't throw an error in this case?
Please note that xmllint rejects the input example as invalid.

@bendrissou
Copy link
Author

Hi @amitguptagwl

I tried the above input from the code:

#!/usr/bin/env node
const {XMLValidator} = require("../fxp");
const result = XMLValidator.validate('<?xml version="1.0" ?>  <a/> <! <!---->', {
    allowBooleanAttributes: true
});
console.log(result);

Output is:

true

So, the XML input was accepted, despite being invalid.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants