From 0fe61e6fb0df2289a26ae7f7c52061da5c28319b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Kr=C3=A4tzig?= Date: Sat, 1 Jun 2019 16:41:56 +0200 Subject: [PATCH] Issue #339: Fixed decoding issue with mailbox folder names --- src/PhpImap/Mailbox.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/PhpImap/Mailbox.php b/src/PhpImap/Mailbox.php index 6443a3cb..97c02e72 100644 --- a/src/PhpImap/Mailbox.php +++ b/src/PhpImap/Mailbox.php @@ -1061,11 +1061,13 @@ public function getMailboxes($search = "*") { $arr = []; if($t = imap_getmailboxes($this->getImapStream(), $this->imapPath, $search)) { foreach($t as $item) { + // https://github.com/barbushin/php-imap/issues/339 + $name = $this->decodeStringFromUtf7ImapToUtf8($item->name); $arr[] = [ - "fullpath" => $item->name, + "fullpath" => $name, "attributes" => $item->attributes, "delimiter" => $item->delimiter, - "shortpath" => substr($item->name, strpos($item->name, '}') + 1), + "shortpath" => substr($name, strpos($name, '}') + 1), ]; } } @@ -1080,11 +1082,13 @@ public function getSubscribedMailboxes($search = "*") { $arr = []; if($t = imap_getsubscribed($this->getImapStream(), $this->imapPath, $search)) { foreach($t as $item) { + // https://github.com/barbushin/php-imap/issues/339 + $name = $this->decodeStringFromUtf7ImapToUtf8($item->name); $arr[] = [ - "fullpath" => $item->name, + "fullpath" => $name, "attributes" => $item->attributes, "delimiter" => $item->delimiter, - "shortpath" => substr($item->name, strpos($item->name, '}') + 1), + "shortpath" => substr($name, strpos($name, '}') + 1), ]; } }