Bugfix: imap_mutf7_to_utf8 is broken for U+10000 and up

This commit is contained in:
the-djmaze 2022-10-17 09:26:00 +02:00
parent 13492a9d0b
commit fc2958538c

View file

@ -1063,10 +1063,9 @@ abstract class Utils
public static function Utf7ModifiedToUtf8(string $sStr) : string public static function Utf7ModifiedToUtf8(string $sStr) : string
{ {
$sResult = \is_callable('imap_mutf7_to_utf8') // imap_mutf7_to_utf8() is broken and doesn't support U+10000 and up,
? \imap_mutf7_to_utf8($sStr) // thats why mmb_convert_encoding is used
// : \mb_convert_encoding($sStr, 'UTF-8', 'UTF7-IMAP'); $sResult = static::MbConvertEncoding($sStr, 'UTF7-IMAP', 'UTF-8');
: static::MbConvertEncoding($sStr, 'UTF7-IMAP', 'UTF-8');
// ucnv U_FILE_ACCESS_ERROR // ucnv U_FILE_ACCESS_ERROR
// $sResult = \UConverter::transcode($sStr, \UConverter::UTF8, \UConverter::IMAP_MAILBOX, ['to_subst' => '<27>']); // $sResult = \UConverter::transcode($sStr, \UConverter::UTF8, \UConverter::IMAP_MAILBOX, ['to_subst' => '<27>']);
return (false === $sResult) ? $sStr : $sResult; return (false === $sResult) ? $sStr : $sResult;