sabredav replace utf8_encode

This commit is contained in:
Sebijk 2023-02-01 20:21:21 +01:00
parent db1d099341
commit be0a2c84bf
3 changed files with 6 additions and 13 deletions

View file

@ -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;
}

View file

@ -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;

View file

@ -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;