From d2de026e46c4ea06b6e52cc7d1c92a353b7a0c2c Mon Sep 17 00:00:00 2001 From: Stefan Giehl Date: Thu, 28 Jan 2021 06:05:44 +0100 Subject: Catch error on PHP8 if invalid encodings are given (#17153) --- core/Tracker/PageUrl.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'core') diff --git a/core/Tracker/PageUrl.php b/core/Tracker/PageUrl.php index 7bf7b9bb92..a28d66f579 100644 --- a/core/Tracker/PageUrl.php +++ b/core/Tracker/PageUrl.php @@ -237,9 +237,14 @@ class PageUrl { if (is_string($value)) { $decoded = urldecode($value); - if (function_exists('mb_check_encoding') - && @mb_check_encoding($decoded, $encoding)) { - $value = urlencode(mb_convert_encoding($decoded, 'UTF-8', $encoding)); + try { + if (function_exists('mb_check_encoding') + && @mb_check_encoding($decoded, $encoding)) { + $value = urlencode(mb_convert_encoding($decoded, 'UTF-8', $encoding)); + } + } catch (\Error $e) { + // mb_check_encoding might throw an ValueError on PHP 8 if the given encoding does not exist + // we can't simply catch ValueError as it was introduced in PHP 8 } } -- cgit v1.2.3