diff --git a/lib/DAV/StringUtil.php b/lib/DAV/StringUtil.php index 13a4399e30..edfb7fa5c2 100644 --- a/lib/DAV/StringUtil.php +++ b/lib/DAV/StringUtil.php @@ -77,10 +77,8 @@ public static function textMatch($haystack, $needle, $collation, $matchType = 'c */ public static function ensureUTF8($input) { - $encoding = mb_detect_encoding($input, ['UTF-8', 'ISO-8859-1'], true); - - if ('ISO-8859-1' === $encoding) { - return utf8_encode($input); + if (!mb_check_encoding($input, 'UTF-8') && mb_check_encoding($input, 'ISO-8859-1')) { + return mb_convert_encoding($input, 'UTF-8', 'ISO-8859-1'); } else { return $input; }