Skip to content

Commit

Permalink
Merge pull request #1404 from come-nc/patch-2
Browse files Browse the repository at this point in the history
Fix encoding detection on PHP 8.1
  • Loading branch information
phil-davis authored Jun 27, 2022
2 parents 7cbc315 + 68a1309 commit 82ac31e
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions lib/DAV/StringUtil.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 82ac31e

Please sign in to comment.