Skip to content

Commit 4eb13be

Browse files
committed
[DomCrawler] Catch expected ValueError.
1 parent 52abcbe commit 4eb13be

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@
3131
"symfony/polyfill-intl-icu": "~1.0",
3232
"symfony/polyfill-mbstring": "~1.0",
3333
"symfony/polyfill-php56": "~1.0",
34-
"symfony/polyfill-php70": "~1.6"
34+
"symfony/polyfill-php70": "~1.6",
35+
"symfony/polyfill-php80": "~1.17"
3536
},
3637
"replace": {
3738
"symfony/asset": "self.version",

src/Symfony/Component/DomCrawler/Crawler.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,10 +193,11 @@ public function addHtmlContent($content, $charset = 'UTF-8')
193193
// Convert charset to HTML-entities to work around bugs in DOMDocument::loadHTML()
194194
$content = mb_convert_encoding($content, 'HTML-ENTITIES', $charset);
195195
} catch (\Exception $e) {
196+
} catch (\ValueError $e) {
197+
} finally {
198+
restore_error_handler();
196199
}
197200

198-
restore_error_handler();
199-
200201
if ('' !== trim($content)) {
201202
@$dom->loadHTML($content);
202203
}

src/Symfony/Component/DomCrawler/composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@
1818
"require": {
1919
"php": "^5.5.9|>=7.0.8",
2020
"symfony/polyfill-ctype": "~1.8",
21-
"symfony/polyfill-mbstring": "~1.0"
21+
"symfony/polyfill-mbstring": "~1.0",
22+
"symfony/polyfill-php80": "~1.17"
2223
},
2324
"require-dev": {
2425
"symfony/css-selector": "~2.8|~3.0|~4.0"

0 commit comments

Comments
 (0)