From be0a2c84bf749f66d1b5f5172d33d616cadd32db Mon Sep 17 00:00:00 2001 From: Sebijk Date: Wed, 1 Feb 2023 20:21:21 +0100 Subject: [PATCH] sabredav replace utf8_encode --- .../SabreDAV/vendor/sabre/dav/lib/DAV/StringUtil.php | 2 +- .../SabreDAV/vendor/sabre/http/lib/functions.php | 9 ++------- .../SabreDAV/vendor/sabre/vobject/lib/StringUtil.php | 8 +++----- 3 files changed, 6 insertions(+), 13 deletions(-) diff --git a/src/serverlib/3rdparty/SabreDAV/vendor/sabre/dav/lib/DAV/StringUtil.php b/src/serverlib/3rdparty/SabreDAV/vendor/sabre/dav/lib/DAV/StringUtil.php index 10eeceb..e6699b7 100644 --- a/src/serverlib/3rdparty/SabreDAV/vendor/sabre/dav/lib/DAV/StringUtil.php +++ b/src/serverlib/3rdparty/SabreDAV/vendor/sabre/dav/lib/DAV/StringUtil.php @@ -81,7 +81,7 @@ class StringUtil { $encoding = mb_detect_encoding($input, ['UTF-8', 'ISO-8859-1'], true); if ($encoding === 'ISO-8859-1') { - return utf8_encode($input); + return mb_convert_encoding($input, 'UTF-8', 'ISO-8859-1'); } else { return $input; } diff --git a/src/serverlib/3rdparty/SabreDAV/vendor/sabre/http/lib/functions.php b/src/serverlib/3rdparty/SabreDAV/vendor/sabre/http/lib/functions.php index 1ec123f..520d7ee 100644 --- a/src/serverlib/3rdparty/SabreDAV/vendor/sabre/http/lib/functions.php +++ b/src/serverlib/3rdparty/SabreDAV/vendor/sabre/http/lib/functions.php @@ -431,13 +431,8 @@ function decodePath($path) { function decodePathSegment($path) { $path = rawurldecode($path); - $encoding = mb_detect_encoding($path, ['UTF-8', 'ISO-8859-1']); - - switch ($encoding) { - - case 'ISO-8859-1' : - $path = utf8_encode($path); - + if (!mb_check_encoding($path, 'UTF-8') && mb_check_encoding($path, 'ISO-8859-1')) { + $path = mb_convert_encoding($path, 'UTF-8', 'ISO-8859-1'); } return $path; diff --git a/src/serverlib/3rdparty/SabreDAV/vendor/sabre/vobject/lib/StringUtil.php b/src/serverlib/3rdparty/SabreDAV/vendor/sabre/vobject/lib/StringUtil.php index 1ecb6d1..5d52cd9 100644 --- a/src/serverlib/3rdparty/SabreDAV/vendor/sabre/vobject/lib/StringUtil.php +++ b/src/serverlib/3rdparty/SabreDAV/vendor/sabre/vobject/lib/StringUtil.php @@ -43,14 +43,12 @@ class StringUtil { switch($encoding) { case 'ISO-8859-1' : - $newStr = utf8_encode($str); + //$newStr = utf8_encode($str); + $newStr = mb_convert_encoding($str, 'UTF-8', 'ISO-8859-1'); break; - /* Unreachable code. Not sure yet how we can improve this - * situation. case 'WINDOWS-1252' : - $newStr = iconv('cp1252', 'UTF-8', $str); + $newStr = mb_convert_encoding($str, 'UTF-8', 'WINDOWS-1252'); break; - */ default : $newStr = $str;