diff --git a/src/Symfony/Component/DomCrawler/Crawler.php b/src/Symfony/Component/DomCrawler/Crawler.php index e89476f1229d..b8329ed2cf8c 100644 --- a/src/Symfony/Component/DomCrawler/Crawler.php +++ b/src/Symfony/Component/DomCrawler/Crawler.php @@ -1204,11 +1204,11 @@ private function convertToHtmlEntities(string $htmlContent, string $charset = 'U try { return mb_convert_encoding($htmlContent, 'HTML-ENTITIES', $charset); - } catch (\Exception $e) { + } catch (\Exception | \ValueError $e) { try { $htmlContent = iconv($charset, 'UTF-8', $htmlContent); $htmlContent = mb_convert_encoding($htmlContent, 'HTML-ENTITIES', 'UTF-8'); - } catch (\Exception $e) { + } catch (\Exception | \ValueError $e) { } return $htmlContent;