diff --git a/snappymail/v/0.0.0/app/libraries/MailSo/Imap/ResponseCollection.php b/snappymail/v/0.0.0/app/libraries/MailSo/Imap/ResponseCollection.php index 43e46c489..372d0bea5 100644 --- a/snappymail/v/0.0.0/app/libraries/MailSo/Imap/ResponseCollection.php +++ b/snappymail/v/0.0.0/app/libraries/MailSo/Imap/ResponseCollection.php @@ -100,16 +100,27 @@ class ResponseCollection extends \MailSo\Base\Collection foreach ($this as $oResponse) { if (\MailSo\Imap\Enumerations\ResponseType::UNTAGGED === $oResponse->ResponseType && - $sStatus === $oResponse->StatusOrIndex && 5 === count($oResponse->ResponseList)) + $sStatus === $oResponse->StatusOrIndex && 5 <= count($oResponse->ResponseList)) { try { - $sFullNameRaw = $oResponse->ResponseList[4]; - if (\is_array($sFullNameRaw)) { - $sFullNameRaw = "[{$sFullNameRaw[0]}]"; + /** + * A bug in the parser converts folder names that start with '[' into arrays, + * and subfolders are in $oResponse->ResponseList[5+] + * https://github.com/the-djmaze/snappymail/issues/1 + * https://github.com/the-djmaze/snappymail/issues/70 + */ + $sFullNameRaw = \array_slice($oResponse->ResponseList, 4); + foreach ($sFullNameRaw as &$name) { + if (\is_array($name)) { + $name = "[{$name[0]}]"; + } else if (!\is_string($name)) { + $name = ''; + } } - if (!\is_string($sFullNameRaw)) { - \error_log('ResponseCollection::getFoldersResult: invalid string ' . \var_export($sFullNameRaw, true)); + $sFullNameRaw = \implode('', $sFullNameRaw); + if (!\strlen($sFullNameRaw)) { + \error_log('ResponseCollection::getFoldersResult: invalid string ' . \var_export($oResponse->ResponseList[4], true)); continue; } $oFolder = new Folder($sFullNameRaw,