Skip to content

Commit

Permalink
fix: Remove incorrect UTF-8 chars from attachments names
Browse files Browse the repository at this point in the history
  • Loading branch information
marien-probesys committed Dec 1, 2023
1 parent 0f1699f commit 8d59c95
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/MessageHandler/CreateTicketsFromMailboxEmailsHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,11 @@ private function storeAttachments(MailboxEmail $mailboxEmail): array
foreach ($mailboxEmail->getAttachments() as $attachment) {
$id = $attachment->getId();
$filename = $attachment->getName();
// PHP-IMAP can return invalid UTF-8 characters in some circumstances.
// mb_convert_encoding will replace these characters with the
// character "?".
// Bug issue: https://github.com/Webklex/php-imap/issues/459
$filename = mb_convert_encoding($filename, 'UTF-8', 'UTF-8');
$status = $attachment->save($tmpPath, $filename);

if (!$status) {
Expand Down

0 comments on commit 8d59c95

Please sign in to comment.