Merge pull request #2081 from the-djmaze/rainloop-issue2037

Resolve issue #2037
This commit is contained in:
RainLoop Team 2021-04-22 20:21:54 +03:00 committed by GitHub
commit e5659da4e8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -664,11 +664,28 @@ class ImapClient extends \MailSo\Net\NetClient
foreach ($aResult as /* @var $oImapResponse \MailSo\Imap\Response */ $oImapResponse) foreach ($aResult as /* @var $oImapResponse \MailSo\Imap\Response */ $oImapResponse)
{ {
if (\MailSo\Imap\Enumerations\ResponseType::UNTAGGED === $oImapResponse->ResponseType && if (\MailSo\Imap\Enumerations\ResponseType::UNTAGGED === $oImapResponse->ResponseType &&
$sStatus === $oImapResponse->StatusOrIndex && 5 === count($oImapResponse->ResponseList)) $sStatus === $oImapResponse->StatusOrIndex && 5 <= count($oImapResponse->ResponseList))
{ {
try try
{ {
$oFolder = Folder::NewInstance($oImapResponse->ResponseList[4], /**
* 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
* https://github.com/RainLoop/rainloop-webmail/issues/2037
*/
$sFullNameRaw = \array_slice($oResponse->ResponseList, 4);
foreach ($sFullNameRaw as &$name) {
if (\is_array($name)) {
$name = "[{$name[0]}]";
} else if (!\is_string($name)) {
$name = '';
}
}
$sFullNameRaw = \implode('', $sFullNameRaw);
$oFolder = Folder::NewInstance($sFullNameRaw,
$oImapResponse->ResponseList[3], $oImapResponse->ResponseList[2]); $oImapResponse->ResponseList[3], $oImapResponse->ResponseList[2]);
if ($oFolder->IsInbox()) if ($oFolder->IsInbox())