Skip to content

Commit 15d1f75

Browse files
Merge branch '7.4' into 8.0
* 7.4: [Messenger] Fix unreachable catch [DependencyInjection] Fix PHPDoc syntax for InstantiatorInterface [DomCrawler] Handle malformed tags in HTML5 parser [MonologBundle] Accept HttpExceptionInterface in HttpCodeActivationStrategy Add the proper type declarations for the messenger SerializerInterface [HttpKernel] Make Kernel::getShareDir() nullable
2 parents d284ac0 + 8f3e746 commit 15d1f75

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

Crawler.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1177,7 +1177,11 @@ private function copyFromHtml5ToDom(\Dom\Node $source, \DOMDocument $target): vo
11771177
continue;
11781178
}
11791179

1180-
$element = $target->createElement($source->tagName);
1180+
try {
1181+
$element = $target->createElement($source->tagName);
1182+
} catch (\DOMException) {
1183+
continue;
1184+
}
11811185

11821186
foreach ($source->attributes as $attr) {
11831187
try {

Tests/CrawlerTest.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1360,6 +1360,13 @@ public static function html5Provider(): iterable
13601360
yield 'All together' => [$BOM.' <!--c-->'.$html];
13611361
}
13621362

1363+
public function testHtml5MalformedContent()
1364+
{
1365+
$crawler = $this->createCrawler();
1366+
$crawler->addHtmlContent('<script&>');
1367+
self::assertEquals('<head></head><body></body>', $crawler->html());
1368+
}
1369+
13631370
public function testAlpineJs()
13641371
{
13651372
$crawler = $this->createCrawler();

0 commit comments

Comments
 (0)