Skip to content

Commit 82ac31e

Browse files
authored
Merge pull request #1404 from come-nc/patch-2
Fix encoding detection on PHP 8.1
2 parents 7cbc315 + 68a1309 commit 82ac31e

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

lib/DAV/StringUtil.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,8 @@ public static function textMatch($haystack, $needle, $collation, $matchType = 'c
7777
*/
7878
public static function ensureUTF8($input)
7979
{
80-
$encoding = mb_detect_encoding($input, ['UTF-8', 'ISO-8859-1'], true);
81-
82-
if ('ISO-8859-1' === $encoding) {
83-
return utf8_encode($input);
80+
if (!mb_check_encoding($input, 'UTF-8') && mb_check_encoding($input, 'ISO-8859-1')) {
81+
return mb_convert_encoding($input, 'UTF-8', 'ISO-8859-1');
8482
} else {
8583
return $input;
8684
}

0 commit comments

Comments
 (0)