Repository navigation
Conversation
|
can you please check if the changes needed in validator needed on fast-xml-validator? |
|
Checked There is still a gap with the option enabled: So the basic interior- |
yxshee
left a comment
There was a problem hiding this comment.
Checked the branch locally against libxml2 (xmllint --noout). <r><!-- a--b --></r>, <r><!--a---></r> and <?xml version="1.0"?><!-- a--b --><r/> are now rejected, and <!---->, <!---leading--> and <!--foo- bar--> stay valid, all matching libxml2. Merged with current master (the branch is 15 commits behind) it merges cleanly and the validator spec runs 79 specs with 0 failures.
One path is not covered: a DOCTYPE goes through the DOCTYPE branch of readCommentAndCDATA, which only counts < and > until the declaration closes, so a comment in the internal subset is skipped without the new check: <!DOCTYPE r [<!-- a--b -->]><r/> still validates on the branch, while libxml2 rejects it ("Double hyphen within comment"). If the goal is to reject -- in every comment, that path needs the same check; otherwise it may be worth saying in the description that the internal subset is out of scope.
Purpose / Goal
Fixes #903.
XMLValidator.validate("<a><!--foo--bar--></a>")currently succeeds, although XML 1.0 section 2.5 disallows double hyphens inside comments. Parsing the same input with validation enabled also succeeds.Reject double hyphens unless they begin the closing
-->, and return the existing error shape from both comment-scanning paths. Tests cover comments before, inside and after the root; invalid trailing hyphens; valid single hyphens; error location; and CDATA controls.Type
Validation
git diff --checkpass.import.metasyntax in the configured parser, and an extra semicolon at the end of the validator function.Performance
Ran the requested
node benchmark/XmlParser.mjsbefore and after. Requests/sec (before → after): fxp v3 115769 → 136077; fxp 55594 → 48564; fxp preserve-order 69419 → 47493; xmlbuilder2 28148 → 20534; xml2js 28694 → 28303. These shared-host Windows runs were noisy and this benchmark does not enable validation.An interleaved validator comparison (7 rounds, 3,000 validations per round) measured median times of 33.75 → 34.51 ms without comments and 40.32 → 39.94 ms with comments. These are local observations.
Prepared with Codex assistance, automated tests, and independent agent review.