From d667f41d73aabed742a339c14f10871f78466e8e Mon Sep 17 00:00:00 2001 From: TheWitness Date: Sat, 23 Mar 2024 15:20:03 -0400 Subject: [PATCH] Fixing #5696 - Chinese encoding does not decode correctly When inputting Chinese to search for graphics, garbled characters appear. --- CHANGELOG | 1 + lib/html_utility.php | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index f6540ea26c..673b882c78 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -116,6 +116,7 @@ Cacti CHANGELOG -issue#5669: System Utilities show incorrect System Memory if memory is larger than 1k -issue#5677: Compatibility improvements for Spikekill under PHP 8.x -issue#5693: Fix Spikekill not following correct time in schedule, Improve PHP 8.3 in spikekill process +-issue#5696: When inputting Chinese to search for graphics, garbled characters appear. -issue#5701: Bad URL formating in the templates_import.php preview mode -feature#5692: Add a "device enabled/disabled" indicator next to the graphs diff --git a/lib/html_utility.php b/lib/html_utility.php index 24640b925b..0f899bc55d 100644 --- a/lib/html_utility.php +++ b/lib/html_utility.php @@ -477,7 +477,7 @@ function get_filter_request_var(string $name, int $filter = FILTER_VALIDATE_INT, $value = ''; } elseif ($filter == FILTER_VALIDATE_IS_REGEX) { if (is_base64_encoded($_REQUEST[$name])) { - $_REQUEST[$name] = base64_decode($_REQUEST[$name], true); + $_REQUEST[$name] = mb_convert_encoding(base64_decode($_REQUEST[$name]), 'UTF-8'); } $valid = validate_is_regex($_REQUEST[$name]); @@ -726,7 +726,7 @@ function validate_store_request_vars(array $filters, string $sess_prefix = ''):v $value = ''; } elseif ($options['filter'] == FILTER_VALIDATE_IS_REGEX) { if (is_base64_encoded($_REQUEST[$variable])) { - $_REQUEST[$variable] = base64_decode($_REQUEST[$variable], true); + $_REQUEST[$variable] = mb_convert_encoding(base64_decode($_REQUEST[$variable]), 'UTF-8'); } $valid = validate_is_regex($_REQUEST[$variable]);