Improved support RFC 6855 / RFC 5738 (UTF8)

This commit is contained in:
djmaze 2021-11-23 09:45:03 +01:00
parent 769ac33bcd
commit 361e991aea
8 changed files with 106 additions and 164 deletions

View file

@ -204,34 +204,22 @@ END;
return $sInputString;
}
if ($sFromEncoding === Enumerations\Charset::ISO_8859_1
&& $sToEncoding === Enumerations\Charset::UTF_8) {
return \utf8_encode($sInputString);
if ($sToEncoding === Enumerations\Charset::UTF_8) {
if ($sFromEncoding === Enumerations\Charset::ISO_8859_1) {
return \utf8_encode($sInputString);
}
if ($sFromEncoding === Enumerations\Charset::UTF_7_IMAP) {
return static::Utf7ModifiedToUtf8($sInputString);
}
}
if ($sFromEncoding === Enumerations\Charset::UTF_8
&& $sToEncoding === Enumerations\Charset::ISO_8859_1) {
return \utf8_decode($sInputString);
}
if ($sFromEncoding === Enumerations\Charset::UTF_7_IMAP
&& $sToEncoding === Enumerations\Charset::UTF_8) {
$sResult = static::Utf7ModifiedToUtf8($sInputString);
return (false !== $sResult) ? $sResult : $sInputString;
}
if ($sFromEncoding === Enumerations\Charset::UTF_8
&& $sToEncoding === Enumerations\Charset::UTF_7_IMAP) {
$sResult = static::Utf8ToUtf7Modified($sInputString);
return (false !== $sResult) ? $sResult : $sInputString;
}
if ($sFromEncoding === Enumerations\Charset::UTF_7_IMAP) {
return static::ConvertEncoding(
static::ModifiedToPlainUtf7($sInputString),
Enumerations\Charset::UTF_7,
$sToEncoding
);
if ($sFromEncoding === Enumerations\Charset::UTF_8) {
if ($sToEncoding === Enumerations\Charset::ISO_8859_1) {
return \utf8_decode($sInputString);
}
if ($sToEncoding === Enumerations\Charset::UTF_7_IMAP) {
return static::Utf8ToUtf7Modified($sInputString);
}
}
return static::MbConvertEncoding($sInputString, $sFromEncoding, $sToEncoding);
@ -780,10 +768,12 @@ END;
case 'application/x-rar-compressed':
case 'application/x-msdownload':
case 'application/vnd.ms-cab-compressed':
case 'application/gzip':
case 'application/x-gzip':
case 'application/x-bzip':
case 'application/x-bzip2':
case 'application/x-debian-package':
case 'application/x-tar':
return 'archive';
case 'application/msword':
@ -808,6 +798,8 @@ END;
case 'zip':
case '7z':
case 'rar':
case 'tar':
case 'tgz':
return 'archive';
case 'pdf':
@ -1328,62 +1320,22 @@ END;
return $mResult;
}
public static function ModifiedToPlainUtf7(string $sUtfModifiedString) : string
{
$sUtf = '';
$bBase = false;
for ($iIndex = 0, $iLen = \strlen($sUtfModifiedString); $iIndex < $iLen; $iIndex++)
{
if ('&' === $sUtfModifiedString[$iIndex])
{
if (isset($sUtfModifiedString[$iIndex+1]) && '-' === $sUtfModifiedString[$iIndex + 1])
{
$sUtf .= '&';
$iIndex++;
}
else
{
$sUtf .= '+';
$bBase = true;
}
}
else if ($sUtfModifiedString[$iIndex] == '-' && $bBase)
{
$bBase = false;
}
else
{
if ($bBase && ',' === $sUtfModifiedString[$iIndex])
{
$sUtf .= '/';
}
else if (!$bBase && '+' === $sUtfModifiedString[$iIndex])
{
$sUtf .= '+-';
}
else
{
$sUtf .= $sUtfModifiedString[$iIndex];
}
}
}
return $sUtf;
}
public static function Utf7ModifiedToUtf8(string $sStr) : string
{
return \is_callable('imap_mutf7_to_utf8')
$sResult = \is_callable('imap_mutf7_to_utf8')
? \imap_mutf7_to_utf8($sStr)
: \mb_convert_encoding($sStr, 'UTF-8', 'UTF7-IMAP');
// static::MbConvertEncoding($sStr, 'UTF7-IMAP', 'UTF-8');
return (false === $sResult) ? $sStr : $sResult;
}
public static function Utf8ToUtf7Modified(string $sStr) : string
{
return \is_callable('imap_utf8_to_mutf7')
$sResult = \is_callable('imap_utf8_to_mutf7')
? \imap_utf8_to_mutf7($sStr)
: \mb_convert_encoding($sStr, 'UTF7-IMAP', 'UTF-8');
// static::MbConvertEncoding($sStr, 'UTF-8', 'UTF7-IMAP');
return (false === $sResult) ? $sStr : $sResult;
}
public static function FunctionExistsAndEnabled($mFunctionNameOrNames) : bool

View file

@ -84,16 +84,16 @@ class ResponseCollection extends \MailSo\Base\Collection
continue;
}
if ('STATUS' === $oResponse->StatusOrIndex && isset($oResponse->ResponseList[2])) {
$sFullNameRaw = $oImapClient->toUTF8($oResponse->ResponseList[2]);
if (!isset($aReturn[$sFullNameRaw])) {
$aReturn[$sFullNameRaw] = new Folder($sFullNameRaw);
$sFullName = $oImapClient->toUTF8($oResponse->ResponseList[2]);
if (!isset($aReturn[$sFullName])) {
$aReturn[$sFullName] = new Folder($sFullName);
}
$aReturn[$sFullNameRaw]->setStatusFromResponse($oResponse);
$aReturn[$sFullName]->setStatusFromResponse($oResponse);
}
else if ($sStatus === $oResponse->StatusOrIndex && 5 == \count($oResponse->ResponseList)) {
try
{
$sFullNameRaw = $oImapClient->toUTF8($oResponse->ResponseList[4]);
$sFullName = $oImapClient->toUTF8($oResponse->ResponseList[4]);
/**
* $oResponse->ResponseList[0] = *
@ -102,12 +102,12 @@ class ResponseCollection extends \MailSo\Base\Collection
* $oResponse->ResponseList[3] = Delimiter
* $oResponse->ResponseList[4] = FullName
*/
if (!isset($aReturn[$sFullNameRaw])) {
$oFolder = new Folder($sFullNameRaw,
if (!isset($aReturn[$sFullName])) {
$oFolder = new Folder($sFullName,
$oResponse->ResponseList[3], $oResponse->ResponseList[2]);
$aReturn[$sFullNameRaw] = $oFolder;
$aReturn[$sFullName] = $oFolder;
} else {
$oFolder = $aReturn[$sFullNameRaw];
$oFolder = $aReturn[$sFullName];
$oFolder->setDelimiter($oResponse->ResponseList[3]);
$oFolder->setFlags($oResponse->ResponseList[2]);
}
@ -120,7 +120,7 @@ class ResponseCollection extends \MailSo\Base\Collection
$sDelimiter = $oFolder->Delimiter();
}
$aReturn[$sFullNameRaw] = $oFolder;
$aReturn[$sFullName] = $oFolder;
}
catch (\MailSo\Base\Exceptions\InvalidArgumentException $oException)
{

View file

@ -54,10 +54,10 @@ class Folder implements \JsonSerializable
* @throws \MailSo\Base\Exceptions\InvalidArgumentException
* @throws \MailSo\Base\Exceptions\InvalidArgumentException
*/
public static function NewNonExistentInstance(string $sFullNameRaw, string $sDelimiter) : self
public static function NewNonExistentInstance(string $sFullName, string $sDelimiter) : self
{
return new self(
new \MailSo\Imap\Folder($sFullNameRaw, $sDelimiter, array('\\Noselect')), false, false);
new \MailSo\Imap\Folder($sFullName, $sDelimiter, array('\\Noselect')), false, false);
}
public function Name() : string

View file

@ -52,19 +52,19 @@ class FolderCollection extends \MailSo\Base\Collection
parent::append($oFolder, $bToTop);
}
public function GetByFullNameRaw(string $sFullNameRaw) : ?Folder
public function GetByFullName(string $sFullName) : ?Folder
{
$mResult = null;
foreach ($this as $oFolder)
{
if ($oFolder->FullName() === $sFullNameRaw)
if ($oFolder->FullName() === $sFullName)
{
$mResult = $oFolder;
break;
}
else if ($oFolder->HasSubFolders())
{
$mResult = $oFolder->SubFolders(true)->GetByFullNameRaw($sFullNameRaw);
$mResult = $oFolder->SubFolders(true)->GetByFullName($sFullName);
if ($mResult)
{
break;
@ -99,7 +99,7 @@ class FolderCollection extends \MailSo\Base\Collection
{
$sDelimiter = '/';
$oFolder = $this->GetByFullNameRaw('INBOX');
$oFolder = $this->GetByFullName('INBOX');
if (!$oFolder && isset($this[0]))
{
$oFolder = $this[0];

View file

@ -1273,18 +1273,18 @@ class MailClient
{
\array_pop($aFolderExplode);
$sNonExistentFolderFullNameRaw = '';
$sNonExistentFolderFullName = '';
foreach ($aFolderExplode as $sFolderExplodeItem)
{
$sNonExistentFolderFullNameRaw .= \strlen($sNonExistentFolderFullNameRaw)
$sNonExistentFolderFullName .= \strlen($sNonExistentFolderFullName)
? $sDelimiter.$sFolderExplodeItem : $sFolderExplodeItem;
if (!isset($aSortedByLenImapFolders[$sNonExistentFolderFullNameRaw]))
if (!isset($aSortedByLenImapFolders[$sNonExistentFolderFullName]))
{
try
{
$aAddedFolders[$sNonExistentFolderFullNameRaw] =
Folder::NewNonExistentInstance($sNonExistentFolderFullNameRaw, $sDelimiter);
$aAddedFolders[$sNonExistentFolderFullName] =
Folder::NewNonExistentInstance($sNonExistentFolderFullName, $sDelimiter);
}
catch (\Throwable $oExc)
{
@ -1325,52 +1325,48 @@ class MailClient
/**
* @throws \MailSo\Base\Exceptions\InvalidArgumentException
*/
public function FolderCreate(string $sFolderNameInUtf8, string $sFolderParentFullNameRaw = '', bool $bSubscribeOnCreation = true, string $sDelimiter = '') : self
public function FolderCreate(string $sFolderNameInUtf8, string $sFolderParentFullName = '', bool $bSubscribeOnCreation = true, string $sDelimiter = '') : self
{
$sFolderNameInUtf8 = \trim($sFolderNameInUtf8);
$sFolderParentFullNameRaw = \trim($sFolderParentFullNameRaw);
$sFolderParentFullName = \trim($sFolderParentFullName);
if (!\strlen($sFolderNameInUtf8))
{
throw new \MailSo\Base\Exceptions\InvalidArgumentException;
}
if (!\strlen($sDelimiter) || \strlen($sFolderParentFullNameRaw))
if (!\strlen($sDelimiter) || \strlen($sFolderParentFullName))
{
$sDelimiter = $this->oImapClient->FolderHierarchyDelimiter($sFolderParentFullNameRaw);
$sDelimiter = $this->oImapClient->FolderHierarchyDelimiter($sFolderParentFullName);
if (null === $sDelimiter)
{
// TODO: Translate
throw new Exceptions\RuntimeException(
\strlen($sFolderParentFullNameRaw)
\strlen($sFolderParentFullName)
? 'Cannot create folder in non-existent parent folder.'
: 'Cannot get folder delimiter.');
}
if (\strlen($sDelimiter) && \strlen($sFolderParentFullNameRaw))
if (\strlen($sDelimiter) && \strlen($sFolderParentFullName))
{
$sFolderParentFullNameRaw .= $sDelimiter;
$sFolderParentFullName .= $sDelimiter;
}
}
$sFullNameRawToCreate = \MailSo\Base\Utils::ConvertEncoding($sFolderNameInUtf8,
\MailSo\Base\Enumerations\Charset::UTF_8,
\MailSo\Base\Enumerations\Charset::UTF_7_IMAP);
if (\strlen($sDelimiter) && false !== \strpos($sFullNameRawToCreate, $sDelimiter))
if (\strlen($sDelimiter) && false !== \strpos($sFolderNameInUtf8, $sDelimiter))
{
// TODO: Translate
throw new Exceptions\RuntimeException(
'New folder name contains delimiter.');
}
$sFullNameRawToCreate = $sFolderParentFullNameRaw.$sFullNameRawToCreate;
$sFullNameToCreate = $sFolderParentFullName.$sFolderNameInUtf8;
$this->oImapClient->FolderCreate($sFullNameRawToCreate);
$this->oImapClient->FolderCreate($sFullNameToCreate);
if ($bSubscribeOnCreation)
{
$this->oImapClient->FolderSubscribe($sFullNameRawToCreate);
$this->oImapClient->FolderSubscribe($sFullNameToCreate);
}
return $this;
@ -1379,76 +1375,72 @@ class MailClient
/**
* @throws \MailSo\Base\Exceptions\InvalidArgumentException
*/
public function FolderMove(string $sPrevFolderFullNameRaw, string $sNextFolderFullNameInUtf, bool $bSubscribeOnMove = true) : self
public function FolderMove(string $sPrevFolderFullName, string $sNextFolderFullNameInUtf, bool $bSubscribeOnMove = true) : self
{
return $this->folderModify($sPrevFolderFullNameRaw, $sNextFolderFullNameInUtf, false, $bSubscribeOnMove);
return $this->folderModify($sPrevFolderFullName, $sNextFolderFullNameInUtf, false, $bSubscribeOnMove);
}
/**
* @throws \MailSo\Base\Exceptions\InvalidArgumentException
*/
public function FolderRename(string $sPrevFolderFullNameRaw, string $sNewTopFolderNameInUtf, bool $bSubscribeOnRename = true) : self
public function FolderRename(string $sPrevFolderFullName, string $sNewTopFolderNameInUtf, bool $bSubscribeOnRename = true) : self
{
return $this->folderModify($sPrevFolderFullNameRaw, $sNewTopFolderNameInUtf, true, $bSubscribeOnRename);
return $this->folderModify($sPrevFolderFullName, $sNewTopFolderNameInUtf, true, $bSubscribeOnRename);
}
/**
* @throws \MailSo\Base\Exceptions\InvalidArgumentException
* @throws \MailSo\Base\Exceptions\RuntimeException
*/
protected function folderModify(string $sPrevFolderFullNameRaw, string $sNextFolderNameInUtf, bool $bRename, bool $bSubscribeOnModify) : self
protected function folderModify(string $sPrevFolderFullName, string $sNextFolderNameInUtf, bool $bRename, bool $bSubscribeOnModify) : self
{
if (!\strlen($sPrevFolderFullNameRaw) || !\strlen($sNextFolderNameInUtf))
if (!\strlen($sPrevFolderFullName) || !\strlen($sNextFolderNameInUtf))
{
throw new \MailSo\Base\Exceptions\InvalidArgumentException;
}
$sDelimiter = $this->oImapClient->FolderHierarchyDelimiter($sPrevFolderFullNameRaw);
$sDelimiter = $this->oImapClient->FolderHierarchyDelimiter($sPrevFolderFullName);
if (!$sDelimiter)
{
// TODO: Translate
throw new Exceptions\RuntimeException('Cannot '.($bRename?'rename':'move').' non-existent folder.');
}
$iLast = \strrpos($sPrevFolderFullNameRaw, $sDelimiter);
$iLast = \strrpos($sPrevFolderFullName, $sDelimiter);
$aSubscribeFolders = array();
if ($bSubscribeOnModify)
{
$aSubscribeFolders = $this->oImapClient->FolderSubscribeList($sPrevFolderFullNameRaw, '*');
$aSubscribeFolders = $this->oImapClient->FolderSubscribeList($sPrevFolderFullName, '*');
foreach ($aSubscribeFolders as /* @var $oFolder \MailSo\Imap\Folder */ $oFolder)
{
$this->oImapClient->FolderUnSubscribe($oFolder->FullName());
}
}
$sNewFolderFullNameRaw = \MailSo\Base\Utils::ConvertEncoding($sNextFolderNameInUtf,
\MailSo\Base\Enumerations\Charset::UTF_8,
\MailSo\Base\Enumerations\Charset::UTF_7_IMAP);
if ($bRename)
{
if (\strlen($sDelimiter) && false !== \strpos($sNewFolderFullNameRaw, $sDelimiter))
if (\strlen($sDelimiter) && false !== \strpos($sNewFolderFullName, $sDelimiter))
{
// TODO: Translate
throw new Exceptions\RuntimeException('New folder name contains delimiter.');
}
$sFolderParentFullNameRaw = false === $iLast ? '' : \substr($sPrevFolderFullNameRaw, 0, $iLast + 1);
$sNewFolderFullNameRaw = $sFolderParentFullNameRaw.$sNewFolderFullNameRaw;
$sFolderParentFullName = false === $iLast ? '' : \substr($sPrevFolderFullName, 0, $iLast + 1);
$sNewFolderFullName = $sFolderParentFullName.$sNewFolderFullName;
}
$this->oImapClient->FolderRename($sPrevFolderFullNameRaw, $sNewFolderFullNameRaw);
$this->oImapClient->FolderRename($sPrevFolderFullName, $sNewFolderFullName);
foreach ($aSubscribeFolders as /* @var $oFolder \MailSo\Imap\Folder */ $oFolder)
{
$sFolderFullNameRawForResubscrine = $oFolder->FullName();
if (0 === \strpos($sFolderFullNameRawForResubscrine, $sPrevFolderFullNameRaw))
$sFolderFullNameForResubscrine = $oFolder->FullName();
if (0 === \strpos($sFolderFullNameForResubscrine, $sPrevFolderFullName))
{
$sNewFolderFullNameRawForResubscrine = $sNewFolderFullNameRaw.
\substr($sFolderFullNameRawForResubscrine, \strlen($sPrevFolderFullNameRaw));
$sNewFolderFullNameForResubscrine = $sNewFolderFullName.
\substr($sFolderFullNameForResubscrine, \strlen($sPrevFolderFullName));
$this->oImapClient->FolderSubscribe($sNewFolderFullNameRawForResubscrine);
$this->oImapClient->FolderSubscribe($sNewFolderFullNameForResubscrine);
}
}
@ -1459,14 +1451,14 @@ class MailClient
* @throws \MailSo\Base\Exceptions\InvalidArgumentException
* @throws \MailSo\Mail\Exceptions\RuntimeException
*/
public function FolderDelete(string $sFolderFullNameRaw, bool $bUnsubscribeOnDeletion = true) : self
public function FolderDelete(string $sFolderFullName, bool $bUnsubscribeOnDeletion = true) : self
{
if (!\strlen($sFolderFullNameRaw) || 'INBOX' === $sFolderFullNameRaw)
if (!\strlen($sFolderFullName) || 'INBOX' === $sFolderFullName)
{
throw new \MailSo\Base\Exceptions\InvalidArgumentException;
}
$this->oImapClient->FolderExamine($sFolderFullNameRaw);
$this->oImapClient->FolderExamine($sFolderFullName);
$aIndexOrUids = $this->oImapClient->MessageSimpleSearch('ALL');
if (\count($aIndexOrUids))
@ -1478,10 +1470,10 @@ class MailClient
if ($bUnsubscribeOnDeletion)
{
$this->oImapClient->FolderUnSubscribe($sFolderFullNameRaw);
$this->oImapClient->FolderUnSubscribe($sFolderFullName);
}
$this->oImapClient->FolderDelete($sFolderFullNameRaw);
$this->oImapClient->FolderDelete($sFolderFullName);
return $this;
}
@ -1489,9 +1481,9 @@ class MailClient
/**
* @throws \MailSo\Base\Exceptions\InvalidArgumentException
*/
public function FolderClear(string $sFolderFullNameRaw) : self
public function FolderClear(string $sFolderFullName) : self
{
$this->oImapClient->FolderSelect($sFolderFullNameRaw);
$this->oImapClient->FolderSelect($sFolderFullName);
$oFolderInformation = $this->oImapClient->FolderCurrentInformation();
if ($oFolderInformation && 0 < $oFolderInformation->MESSAGES)
@ -1510,14 +1502,14 @@ class MailClient
/**
* @throws \MailSo\Base\Exceptions\InvalidArgumentException
*/
public function FolderSubscribe(string $sFolderFullNameRaw, bool $bSubscribe) : self
public function FolderSubscribe(string $sFolderFullName, bool $bSubscribe) : self
{
if (!\strlen($sFolderFullNameRaw))
if (!\strlen($sFolderFullName))
{
throw new \MailSo\Base\Exceptions\InvalidArgumentException;
}
$this->oImapClient->{($bSubscribe) ? 'FolderSubscribe' : 'FolderUnSubscribe'}($sFolderFullNameRaw);
$this->oImapClient->{$bSubscribe ? 'FolderSubscribe' : 'FolderUnSubscribe'}($sFolderFullName);
return $this;
}

View file

@ -340,7 +340,7 @@ class Message implements \JsonSerializable
$oHeaders->SetParentCharset($sCharset);
}
$bCharsetAutoDetect = 0 === \strlen($sCharset);
$bCharsetAutoDetect = !\strlen($sCharset);
$this->sSubject = $oHeaders->ValueByName(\MailSo\Mime\Enumerations\Header::SUBJECT, $bCharsetAutoDetect);
$this->sMessageId = $oHeaders->ValueByName(\MailSo\Mime\Enumerations\Header::MESSAGE_ID);
@ -386,11 +386,11 @@ class Message implements \JsonSerializable
// Priority
$this->iPriority = \MailSo\Mime\Enumerations\MessagePriority::NORMAL;
$sPriority = $oHeaders->ValueByName(\MailSo\Mime\Enumerations\Header::X_MSMAIL_PRIORITY);
if (0 === \strlen($sPriority))
if (!\strlen($sPriority))
{
$sPriority = $oHeaders->ValueByName(\MailSo\Mime\Enumerations\Header::IMPORTANCE);
}
if (0 === \strlen($sPriority))
if (!\strlen($sPriority))
{
$sPriority = $oHeaders->ValueByName(\MailSo\Mime\Enumerations\Header::X_PRIORITY);
}
@ -514,13 +514,13 @@ class Message implements \JsonSerializable
}
else if ($oFetchResponse->GetEnvelope())
{
if (0 === \strlen($sCharset) && $oBodyStructure)
if (!\strlen($sCharset) && $oBodyStructure)
{
$sCharset = $oBodyStructure->SearchCharset();
$sCharset = \MailSo\Base\Utils::NormalizeCharset($sCharset);
}
if (0 === \strlen($sCharset))
if (!\strlen($sCharset))
{
$sCharset = \MailSo\Base\Enumerations\Charset::ISO_8859_1;
}
@ -559,7 +559,7 @@ class Message implements \JsonSerializable
$aTextParts = $oBodyStructure ? $oBodyStructure->SearchHtmlOrPlainParts() : null;
if ($aTextParts)
{
if (0 === \strlen($sCharset))
if (!\strlen($sCharset))
{
$sCharset = \MailSo\Base\Enumerations\Charset::UTF_8;
}

View file

@ -1370,7 +1370,7 @@ class Actions
{
$oAccount = $this->initMailClientConnection();
$sFolderFullNameRaw = $this->GetActionParam('Folder', '');
$sFolderFullName = $this->GetActionParam('Folder', '');
$_FILES = isset($_FILES) ? $_FILES : null;
if ($oAccount &&
@ -1378,15 +1378,15 @@ class Actions
isset($_FILES, $_FILES['AppendFile'], $_FILES['AppendFile']['name'],
$_FILES['AppendFile']['tmp_name'], $_FILES['AppendFile']['size'])) {
if (is_string($_FILES['AppendFile']['tmp_name']) && \strlen($_FILES['AppendFile']['tmp_name'])) {
if (\UPLOAD_ERR_OK === (int)$_FILES['AppendFile']['error'] && !empty($sFolderFullNameRaw)) {
$sSavedName = 'append-post-' . md5($sFolderFullNameRaw . $_FILES['AppendFile']['name'] . $_FILES['AppendFile']['tmp_name']);
if (\UPLOAD_ERR_OK === (int)$_FILES['AppendFile']['error'] && !empty($sFolderFullName)) {
$sSavedName = 'append-post-' . md5($sFolderFullName . $_FILES['AppendFile']['name'] . $_FILES['AppendFile']['tmp_name']);
if ($this->FilesProvider()->MoveUploadedFile($oAccount,
$sSavedName, $_FILES['AppendFile']['tmp_name'])) {
$iMessageStreamSize = $this->FilesProvider()->FileSize($oAccount, $sSavedName);
$rMessageStream = $this->FilesProvider()->GetFile($oAccount, $sSavedName);
$this->MailClient()->MessageAppendStream($rMessageStream, $iMessageStreamSize, $sFolderFullNameRaw);
$this->MailClient()->MessageAppendStream($rMessageStream, $iMessageStreamSize, $sFolderFullName);
$this->FilesProvider()->Clear($oAccount, $sSavedName);
}

View file

@ -125,15 +125,13 @@ trait Folders
}
}
$sFullNameToCheck = \MailSo\Base\Utils::ConvertEncoding($mFolderNameToCreate,
\MailSo\Base\Enumerations\Charset::UTF_8, \MailSo\Base\Enumerations\Charset::UTF_7_IMAP);
$sFullNameToCheck = $mFolderNameToCreate;
if (\strlen(\trim($sParent)))
{
$sFullNameToCheck = $sParent.$sDelimiter.$sFullNameToCheck;
}
if (!$oFolderCollection->GetByFullNameRaw($sFullNameToCheck))
if (!$oFolderCollection->GetByFullName($sFullNameToCheck))
{
try
{
@ -182,9 +180,9 @@ trait Folders
try
{
$sFolderNameInUtf = $this->GetActionParam('Folder', '');
$sFolderParentFullNameRaw = $this->GetActionParam('Parent', '');
$sFolderParentFullName = $this->GetActionParam('Parent', '');
$this->MailClient()->FolderCreate($sFolderNameInUtf, $sFolderParentFullNameRaw,
$this->MailClient()->FolderCreate($sFolderNameInUtf, $sFolderParentFullName,
!!$this->Config()->Get('labs', 'use_imap_list_subscribe', true));
}
catch (\Throwable $oException)
@ -198,10 +196,10 @@ trait Folders
public function DoFolderSetMetadata() : array
{
$this->initMailClientConnection();
$sFolderFullNameRaw = $this->GetActionParam('Folder');
$sFolderFullName = $this->GetActionParam('Folder');
$sMetadataKey = $this->GetActionParam('Key');
if ($sFolderFullNameRaw && $sMetadataKey) {
$this->MailClient()->FolderSetMetadata($sFolderFullNameRaw, [
if ($sFolderFullName && $sMetadataKey) {
$this->MailClient()->FolderSetMetadata($sFolderFullName, [
$sMetadataKey => $this->GetActionParam('Value') ?: null
]);
}
@ -212,12 +210,12 @@ trait Folders
{
$this->initMailClientConnection();
$sFolderFullNameRaw = $this->GetActionParam('Folder', '');
$sFolderFullName = $this->GetActionParam('Folder', '');
$bSubscribe = '1' === (string) $this->GetActionParam('Subscribe', '0');
try
{
$this->MailClient()->FolderSubscribe($sFolderFullNameRaw, $bSubscribe);
$this->MailClient()->FolderSubscribe($sFolderFullName, $bSubscribe);
}
catch (\Throwable $oException)
{
@ -238,7 +236,7 @@ trait Folders
{
$oAccount = $this->getAccountFromToken();
$sFolderFullNameRaw = $this->GetActionParam('Folder', '');
$sFolderFullName = $this->GetActionParam('Folder', '');
$bCheckable = '1' === (string) $this->GetActionParam('Checkable', '0');
$oSettingsLocal = $this->SettingsProvider(true)->Load($oAccount);
@ -253,14 +251,14 @@ trait Folders
if ($bCheckable)
{
$aCheckableFolder[] = $sFolderFullNameRaw;
$aCheckableFolder[] = $sFolderFullName;
}
else
{
$aCheckableFolderNew = array();
foreach ($aCheckableFolder as $sFolder)
{
if ($sFolder !== $sFolderFullNameRaw)
if ($sFolder !== $sFolderFullName)
{
$aCheckableFolderNew[] = $sFolder;
}