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
A processing instruction with no target passes validation, then the builder prints invalid XML #927
Have you checked the docs for helpful APIs and examples?
Description
Hello,
While fuzzing fast-xml-parser@5.12.1 (the latest version) with Termo, a fuzzer I'm developing, I found that XMLValidator accepts a processing instruction with no target name (<?>x?>). XMLParser then returns a node with an empty tag name, and XMLBuilder turns it into <></>, which is not XML:
Without a target (<?>) validation already fails as it should. With a body (<?>x?>) it passes. The XML spec requires a name right after <? (PI ::= '<?' PITarget (S ...)? '?>').
<? ?><r/> is similar: it validates, and parses into a node named "?", which the builder prints as <??>.
Expected: the validator rejects a processing instruction with no target (or else the parser skips it), so the builder never prints an element with an empty name.
Happy to test a fix against these inputs if it helps.
If you'd like me to keep fuzzing fast-xml-parser (other parts of the API, or re-checking after a fix), feel free to reach out. I'd be glad to keep working on it with you.
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'd like to take this one. The validator's readPI never checks the target name, and inside an element it's called one character late (readPI(xmlData, ++i) starts at the ?), so <r><?xml ...?></r> also slips through. An unclosed <?pi at the end is accepted too. I have a fix with tests and will open a PR shortly.
Activity
github-actions commentedon Nov 16, 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.
bardrop commentedon Nov 17, 2026
I'd like to take this one. The validator's
readPInever checks the target name, and inside an element it's called one character late (readPI(xmlData, ++i)starts at the?), so<r><?xml ...?></r>also slips through. An unclosed<?piat the end is accepted too. I have a fix with tests and will open a PR shortly.