Skip to content

Commit

Permalink
[DomCrawler] Catch expected ValueError.
Browse files Browse the repository at this point in the history
  • Loading branch information
derrabus committed May 22, 2020
1 parent 52abcbe commit 4eb13be
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
3 changes: 2 additions & 1 deletion composer.json
Expand Up @@ -31,7 +31,8 @@
"symfony/polyfill-intl-icu": "~1.0",
"symfony/polyfill-mbstring": "~1.0",
"symfony/polyfill-php56": "~1.0",
"symfony/polyfill-php70": "~1.6"
"symfony/polyfill-php70": "~1.6",
"symfony/polyfill-php80": "~1.17"
},
"replace": {
"symfony/asset": "self.version",
Expand Down
5 changes: 3 additions & 2 deletions src/Symfony/Component/DomCrawler/Crawler.php
Expand Up @@ -193,10 +193,11 @@ public function addHtmlContent($content, $charset = 'UTF-8')
// Convert charset to HTML-entities to work around bugs in DOMDocument::loadHTML()
$content = mb_convert_encoding($content, 'HTML-ENTITIES', $charset);
} catch (\Exception $e) {
} catch (\ValueError $e) {
} finally {
restore_error_handler();
}

restore_error_handler();

if ('' !== trim($content)) {
@$dom->loadHTML($content);
}
Expand Down
3 changes: 2 additions & 1 deletion src/Symfony/Component/DomCrawler/composer.json
Expand Up @@ -18,7 +18,8 @@
"require": {
"php": "^5.5.9|>=7.0.8",
"symfony/polyfill-ctype": "~1.8",
"symfony/polyfill-mbstring": "~1.0"
"symfony/polyfill-mbstring": "~1.0",
"symfony/polyfill-php80": "~1.17"
},
"require-dev": {
"symfony/css-selector": "~2.8|~3.0|~4.0"
Expand Down

0 comments on commit 4eb13be

Please sign in to comment.