From 457195447eaa61da012df02ca677af0f0a6d524b Mon Sep 17 00:00:00 2001 From: joshuaruesweg Date: Tue, 15 Mar 2022 19:00:53 +0100 Subject: [PATCH] Catch `ValueError` while convert encoding Since PHP 8.0 the function `mb_convert_encoding` throws an `ValueError` if the given charset is unknown. Prior to this, a PHP notice is thrown. Fixes #4697 --- .../files/lib/system/message/unfurl/UnfurlResponse.class.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/wcfsetup/install/files/lib/system/message/unfurl/UnfurlResponse.class.php b/wcfsetup/install/files/lib/system/message/unfurl/UnfurlResponse.class.php index 211c9e2b53..f8496e021e 100644 --- a/wcfsetup/install/files/lib/system/message/unfurl/UnfurlResponse.class.php +++ b/wcfsetup/install/files/lib/system/message/unfurl/UnfurlResponse.class.php @@ -10,6 +10,7 @@ use GuzzleHttp\Psr7\Request; use GuzzleHttp\Psr7\Response; use GuzzleHttp\RequestOptions; use Psr\Http\Client\ClientExceptionInterface; +use ValueError; use wcf\system\io\http\RedirectGuard; use wcf\system\io\HttpFactory; use wcf\system\message\unfurl\exception\DownloadFailed; @@ -152,7 +153,7 @@ final class UnfurlResponse if ($this->responseCharset !== 'UTF-8') { try { $this->body = StringUtil::convertEncoding($this->responseCharset, 'UTF-8', $this->body); - } catch (Exception $e) { + } catch (Exception | ValueError $e) { throw new ParsingFailed( "Could not parse body, due an invalid charset.", 0, -- 2.20.1