Skip to content

Commit

Permalink
bug #36915 [DomCrawler] Catch expected ValueError (derrabus)
Browse files Browse the repository at this point in the history
This PR was merged into the 4.4 branch.

Discussion
----------

[DomCrawler] Catch expected ValueError

| Q             | A
| ------------- | ---
| Branch?       | 4.4
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Tickets       | #36872
| License       | MIT
| Doc PR        | N/A

This is #36906 ported to the 4.4 branch.

Commits
-------

32691e5 [DomCrawler] Catch expected ValueError.
  • Loading branch information
nicolas-grekas committed May 23, 2020
2 parents a25e88b + 32691e5 commit 5d7b7e9
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Symfony/Component/DomCrawler/Crawler.php
Expand Up @@ -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;
Expand Down

0 comments on commit 5d7b7e9

Please sign in to comment.