You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
XMLValidator accepts references, CDATA, and DOCTYPE after the root element #899
Have you checked the docs for helpful APIs and examples?
Description
On 5.11.2 (current master at cf66a96), XMLValidator accepts character references, CDATA, and a DOCTYPE after a completed root element. With validation enabled, XMLParser.parse then either drops that content or returns it as top-level text. XML 1.0 permits only whitespace, comments, and processing instructions in the epilog: document grammar and Misc grammar.
Each validation returns true. The final parse returns { a: '', '#text': 'x' }. Parsing <a></a>& with validation returns { a: '' }, dropping the trailing reference. The official online validator also reports "Valid XML" for all four inputs.
As a control, <a></a>tail returns InvalidXml: Extra text at the end. An epilog comment or processing instruction passes validation, as expected.
Expected data
All four inputs should fail validation because those constructs occur after the document element. XMLParser.parse(xml, true) should then reject them too. The reachedRoot check appears to be bypassed while scanning references and '<!...>' markup after the root.
We're glad you find this project helpful. We'll try to address this issue ASAP. You can join Discord channel(https://discord.gg/X4Qp9u6Vz) for anonucements and pre release discussions. Don't forget to star this repo.
I checked fast-xml-validator's SyntaxValidator.validate on main at 335fcaf (package.json 1.4.2, Node 24.22.1). It returns true for <a></a>&, <a></a>A, and <a></a><![CDATA[x]]>, so those three epilog cases reproduce in the separate validator. It rejects <a></a><!DOCTYPE x> with InvalidDocType: DOCTYPE must appear before the root element. Valid epilog comment and PI controls both pass.
Activity
github-actions commentedon Nov 1, 2026
We're glad you find this project helpful. We'll try to address this issue ASAP. You can join Discord channel(https://discord.gg/X4Qp9u6Vz) for anonucements and pre release discussions. Don't forget to star this repo.
amitguptagwl commentedon Nov 3, 2026
plz check fast-xml-validator once
agammann commentedon Nov 4, 2026
I checked
fast-xml-validator'sSyntaxValidator.validateon main at335fcaf(package.json1.4.2, Node 24.22.1). It returnstruefor<a></a>&,<a></a>A, and<a></a><![CDATA[x]]>, so those three epilog cases reproduce in the separate validator. It rejects<a></a><!DOCTYPE x>withInvalidDocType: DOCTYPE must appear before the root element.Valid epilog comment and PI controls both pass.