From c1228d09f08397f2352f5a3ae929fb498b68993c Mon Sep 17 00:00:00 2001 From: djmaze Date: Thu, 2 Dec 2021 23:21:12 +0100 Subject: [PATCH] Bugfix: folder rename/move was broken --- .../app/libraries/MailSo/Mail/MailClient.php | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/snappymail/v/0.0.0/app/libraries/MailSo/Mail/MailClient.php b/snappymail/v/0.0.0/app/libraries/MailSo/Mail/MailClient.php index c233bdb70..b3644df23 100644 --- a/snappymail/v/0.0.0/app/libraries/MailSo/Mail/MailClient.php +++ b/snappymail/v/0.0.0/app/libraries/MailSo/Mail/MailClient.php @@ -1385,22 +1385,13 @@ class MailClient * @throws \MailSo\Base\Exceptions\InvalidArgumentException * @throws \MailSo\Base\Exceptions\RuntimeException */ - protected function folderModify(string $sPrevFolderFullName, string $sNextFolderNameInUtf, bool $bRename, bool $bSubscribeOnModify) : self + protected function folderModify(string $sPrevFolderFullName, string $sNewFolderFullName, bool $bRename, bool $bSubscribeOnModify) : self { - if (!\strlen($sPrevFolderFullName) || !\strlen($sNextFolderNameInUtf)) + if (!\strlen($sPrevFolderFullName) || !\strlen($sNewFolderFullName)) { throw new \MailSo\Base\Exceptions\InvalidArgumentException; } - $sDelimiter = $this->oImapClient->FolderHierarchyDelimiter($sPrevFolderFullName); - if (!$sDelimiter) - { - // TODO: Translate - throw new Exceptions\RuntimeException('Cannot '.($bRename?'rename':'move').' non-existent folder.'); - } - - $iLast = \strrpos($sPrevFolderFullName, $sDelimiter); - $aSubscribeFolders = array(); if ($bSubscribeOnModify) { @@ -1413,14 +1404,23 @@ class MailClient if ($bRename) { + $sDelimiter = $this->oImapClient->FolderHierarchyDelimiter($sPrevFolderFullName); + if (!$sDelimiter) + { + // TODO: Translate + throw new Exceptions\RuntimeException('Cannot '.($bRename?'rename':'move').' non-existent folder.'); + } + + $iLast = \strrpos($sPrevFolderFullName, $sDelimiter); + if (\strlen($sDelimiter) && false !== \strpos($sNewFolderFullName, $sDelimiter)) { // TODO: Translate throw new Exceptions\RuntimeException('New folder name contains delimiter.'); } - $sFolderParentFullName = false === $iLast ? '' : \substr($sPrevFolderFullName, 0, $iLast + 1); - $sNewFolderFullName = $sFolderParentFullName.$sNewFolderFullName; + $sNewFolderFullName = (false === $iLast ? '' : \substr($sPrevFolderFullName, 0, $iLast + 1)) + . $sNewFolderFullName; } $this->oImapClient->FolderRename($sPrevFolderFullName, $sNewFolderFullName);