From d1344ee6282fbb53927c45cf7fdbbdce2bd69a0d Mon Sep 17 00:00:00 2001 From: Ralf Lang Date: Mon, 13 Apr 2026 00:12:09 +0200 Subject: [PATCH] fix: backport community fixes from bytestream fork Original-Author: Kieran Brahney (empty charset warning in PHP 8, 1472003) Original-Author: David Dreschner (PHP 8.5 strtolower deprecation, 45a9c3c) Co-authored-by: Kieran Brahney --- lib/Horde/String.php | 12 +++++++----- src/HordeString.php | 4 ++++ 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/lib/Horde/String.php b/lib/Horde/String.php index a2e74db..d65f189 100644 --- a/lib/Horde/String.php +++ b/lib/Horde/String.php @@ -258,14 +258,12 @@ public static function lower($string, $locale = false, $charset = null) return strtolower($string); } + $string = $string ?? ''; + if (!isset(self::$_lowers[$string])) { $language = setlocale(LC_CTYPE, 0); setlocale(LC_CTYPE, 'C'); - if ($string === null) { - self::$_lowers[$string] = ''; - } else { - self::$_lowers[$string] = strtolower($string); - } + self::$_lowers[$string] = strtolower($string); setlocale(LC_CTYPE, $language); } @@ -1052,6 +1050,10 @@ public static function validUtf8($text) */ protected static function _mbstringCharset($charset) { + if ($charset === "") { + return null; + } + /* mbstring functions do not handle the 'ks_c_5601-1987' & * 'ks_c_5601-1989' charsets. However, these charsets are used, for * example, by various versions of Outlook to send Korean characters. diff --git a/src/HordeString.php b/src/HordeString.php index af227b8..225eae9 100644 --- a/src/HordeString.php +++ b/src/HordeString.php @@ -1063,6 +1063,10 @@ public static function validUtf8($text) */ protected static function _mbstringCharset($charset) { + if ($charset === "") { + return null; + } + /* mbstring functions do not handle the 'ks_c_5601-1987' & * 'ks_c_5601-1989' charsets. However, these charsets are used, for * example, by various versions of Outlook to send Korean characters.