XMLValidator accepts double hyphens inside comments

Open Beginner friendly
#903 3 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 4 days

@Sskift is already working on this.

Since Nov 2, 2026.

  • #909 by @Sskift — open

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
74/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
javascript
Domain
tooling

Research direction

Start by running the reproduction from the issue against lib/fxp.cjs, which exposes XMLValidator.validate. The payload does not name the file that scans comments, so search the validator source for comment handling. Done when <a><!--foo--bar--></a> returns false, <a><!--ok--></a> still returns true, and a test covers both cases.

Written by the indexing model from the issue text.

Description

  • Are you running the latest version? (5.11.2, master at cf66a9658004553bc740616e6c7a4912e7e9aab6)
  • Have you included sample input, output, error, and expected output?
  • Have you checked if you are using correct configuration? (default options)
  • Did you try online tool? (it reports Valid XML for the 22-byte sample)
  • Have you checked the docs for helpful APIs and examples?
Description

XMLValidator.validate accepts a comment containing -- before the closing delimiter. XML 1.0 comments cannot contain a double hyphen within the comment text. Python xml.etree.ElementTree rejects the same input as not well-formed at column 12.

Input

<a><!--foo--bar--></a>

Code
const { XMLValidator, XMLParser } = require("./lib/fxp.cjs");
for (const xml of ["<a><!--foo--bar--></a>", "<a><!--ok--></a>"]) {
  console.log(xml, XMLValidator.validate(xml), new XMLParser().parse(xml, true));
}
Output

Both inputs return true from XMLValidator.validate and parse as { a: "" }. The online tool also reports Valid XML for the malformed sample.

Expected data

The malformed comment should be rejected; <a><!--ok--></a> should remain valid.

Would you like to work on this issue?

  • Yes
  • No
Dominant language
JavaScript
Stars
3.1k
Forks
410
Avg merge
4d 15h
Merged PRs (30d)
8

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from NaturalIntelligence/fast-xml-parser

All issues in NaturalIntelligence/fast-xml-parser

Similar issues

More JavaScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.