diff --git a/lib/IMAP/MessageMapper.php b/lib/IMAP/MessageMapper.php index 8503ed2738..f9a989b066 100644 --- a/lib/IMAP/MessageMapper.php +++ b/lib/IMAP/MessageMapper.php @@ -40,6 +40,7 @@ use OCA\Mail\Attachment; use OCA\Mail\Db\Mailbox; use OCA\Mail\Exception\ServiceException; +use OCA\Mail\IMAP\Charset\Converter; use OCA\Mail\Model\IMAPMessage; use OCA\Mail\Service\SmimeService; use OCA\Mail\Support\PerformanceLoggerTask; @@ -950,7 +951,7 @@ public function getBodyStructureData(Horde_Imap_Client_Socket $client, if ($enc = $mimeHeaders->getValue('content-transfer-encoding')) { $structure->setTransferEncoding($enc); $structure->setContents($htmlBody); - $htmlBody = $structure->getContents(); + $htmlBody = $this->converter->convert($structure); } $html = new Html2Text($htmlBody, ['do_links' => 'none','alt_image' => 'hide']); return new MessageStructureData( @@ -967,7 +968,7 @@ public function getBodyStructureData(Horde_Imap_Client_Socket $client, if ($enc = $mimeHeaders->getValue('content-transfer-encoding')) { $structure->setTransferEncoding($enc); $structure->setContents($textBody); - $textBody = $structure->getContents(); + $textBody = $this->converter->convert($structure); } return new MessageStructureData( $hasAttachments, diff --git a/tests/Unit/IMAP/MessageMapperTest.php b/tests/Unit/IMAP/MessageMapperTest.php index 057d96ca56..86fd318884 100644 --- a/tests/Unit/IMAP/MessageMapperTest.php +++ b/tests/Unit/IMAP/MessageMapperTest.php @@ -32,6 +32,7 @@ use Horde_Imap_Client_Ids; use Horde_Imap_Client_Socket; use OCA\Mail\Db\Mailbox; +use OCA\Mail\IMAP\Charset\Converter; use OCA\Mail\IMAP\ImapMessageFetcher; use OCA\Mail\IMAP\ImapMessageFetcherFactory; use OCA\Mail\IMAP\MessageMapper; @@ -55,17 +56,21 @@ class MessageMapperTest extends TestCase { /** @var ImapMessageFetcherFactory|MockObject */ private $imapMessageFactory; + private Converter|MockObject $converter; + protected function setUp(): void { parent::setUp(); $this->logger = $this->createMock(LoggerInterface::class); $this->sMimeService = $this->createMock(SmimeService::class); $this->imapMessageFactory = $this->createMock(ImapMessageFetcherFactory::class); + $this->converter = $this->createMock(Converter::class); $this->mapper = new MessageMapper( $this->logger, $this->sMimeService, $this->imapMessageFactory, + $this->converter, ); }