-
-
Notifications
You must be signed in to change notification settings - Fork 9.8k
Closed
Description
Symfony version(s) affected
7.4.0-BETA1
Description
Trying to parse an HTML comment that contains a double hyphen results in a PHP warning from DOMDocument::loadXML().
As far as I can tell from the HTML5 spec, double hyphens are allowed inside HTML comments (but not in XML comments).
This only affects PHP 8.4 where the native HTML5 parser is used.
This issue was found via Drupal's test suite where we embed filenames that contain double hyphens in Twig debug comments.
How to reproduce
> new \Symfony\Component\DomCrawler\Crawler('<!-- page--theme-test -->');
WARNING DOMDocument::loadXML(): Double hyphen within comment: <!-- page in Entity, line: 2 in vendor/symfony/dom-crawler/Crawler.php on line 1116.
Possible Solution
Silence the warning from DOMDocument::loadXML():
- $dom->loadXML($htmlContent);
+ @$dom->loadXML($htmlContent);
Additional Context
No response