Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[stable3.7] fix(imap): Consider charset for preview text decoding #10443

Draft
wants to merge 1 commit into
base: stable3.7
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions lib/IMAP/MessageMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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(
Expand All @@ -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,
Expand Down
5 changes: 5 additions & 0 deletions tests/Unit/IMAP/MessageMapperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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,
);
}

Expand Down