From d2ed7fc025e77ff5173d8c67a01a32296a138b27 Mon Sep 17 00:00:00 2001 From: ccheng Date: Thu, 27 Feb 2025 13:23:58 +0100 Subject: [PATCH] fix(Felamimail/Message): detech strict encoding from msg message --- tests/tine20/Felamimail/Frontend/JsonTest.php | 4 +--- tine20/Felamimail/Controller/Message.php | 4 ++-- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/tests/tine20/Felamimail/Frontend/JsonTest.php b/tests/tine20/Felamimail/Frontend/JsonTest.php index 32fdd205fd..60f3d7dd54 100644 --- a/tests/tine20/Felamimail/Frontend/JsonTest.php +++ b/tests/tine20/Felamimail/Frontend/JsonTest.php @@ -2867,9 +2867,7 @@ public function testGetMessageFromNodeMsg() dirname(__FILE__) . '/../files/multipart_related_recipients.msg' ); - // TODO make encodingCheck work again (in PHP 8.3+) - $encodingCheck = PHP_VERSION_ID < 80300; - $message = $this->_assertMessageFromNode($result[0]['id'], $encodingCheck); + $message = $this->_assertMessageFromNode($result[0]['id'], true); self::assertEquals(2, count($message['cc'])); self::assertEquals('c.weiss@metaways.de', $message['cc'][0]['email']); self::assertEquals('name@example.com', $message['cc'][1]['email']); diff --git a/tine20/Felamimail/Controller/Message.php b/tine20/Felamimail/Controller/Message.php index a58d70d74e..c19b3d1a26 100644 --- a/tine20/Felamimail/Controller/Message.php +++ b/tine20/Felamimail/Controller/Message.php @@ -1502,8 +1502,8 @@ public function getMessageFromNode($nodeId, $mimeType = null): Felamimail_Model_ } if ($message['body_content_type'] === 'text/html') { - $encoding = mb_detect_encoding($message['body']); - if (! $encoding) { + $encoding = mb_detect_encoding($message['body'], 'UTF-8', true); + if (!$encoding) { $message['body'] = mb_convert_encoding($message['body'], 'UTF-8', 'ISO-8859-1'); } $message->body = str_replace("\r", '', $message['body']);