Skip to content

Treat <!---> as an empty comment - #290

Open
samipuro wants to merge 1 commit into
Masterminds:masterfrom
samipuro:fix/abrupt-empty-comment
Open

samipuro wants to merge 1 commit into
Masterminds:masterfrom
samipuro:fix/abrupt-empty-comment

Conversation

@samipuro

@samipuro samipuro commented Dec 2, 2026

Copy link
Copy Markdown

<!---> is an abruptly closed empty comment, the same as <!-->. The tokenizer only handled <!-->, so for <!---> it kept looking for --> and put the rest of the document inside the comment:

$html5 = new \Masterminds\HTML5();
echo $html5->saveHTML($html5->loadHTMLFragment('<!--->x'));
// before: <!--->x-->
// after:  <!---->x

This adds the -> case next to the existing > case in Tokenizer::comment(): it reports a parse error and emits an empty comment, as in the comment start dash state of the spec. Added tokenizer tests for <!---> and for the text that follows it.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant