Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorStefan Giehl <stefan@matomo.org>2021-01-28 08:05:44 +0300
committerGitHub <noreply@github.com>2021-01-28 08:05:44 +0300
commitd2de026e46c4ea06b6e52cc7d1c92a353b7a0c2c (patch)
treef8dd8970faefa53a825b2f5b2279366f6d46df97 /core
parent2638ea37f5f05149ca0ff9baa6f7edbc80e97c95 (diff)
Catch error on PHP8 if invalid encodings are given (#17153)
Diffstat (limited to 'core')
-rw-r--r--core/Tracker/PageUrl.php11
1 files changed, 8 insertions, 3 deletions
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
}
}