mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-09-07 16:37:02 +03:00
Fix folder names parser
This commit is contained in:
parent
46c3e305d7
commit
9bcb8ae02c
2 changed files with 52 additions and 29 deletions
|
|
@ -3,7 +3,7 @@
|
||||||
"title": "RainLoop Webmail",
|
"title": "RainLoop Webmail",
|
||||||
"description": "Simple, modern & fast web-based email client",
|
"description": "Simple, modern & fast web-based email client",
|
||||||
"private": true,
|
"private": true,
|
||||||
"version": "1.15.0",
|
"version": "1.16.0",
|
||||||
"ownCloudVersion": "5.4.0",
|
"ownCloudVersion": "5.4.0",
|
||||||
"homepage": "https://www.rainloop.net",
|
"homepage": "https://www.rainloop.net",
|
||||||
"author": {
|
"author": {
|
||||||
|
|
|
||||||
|
|
@ -2028,22 +2028,37 @@ class ImapClient extends \MailSo\Net\NetClient
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
private function skipBracketParse($oImapResponse)
|
||||||
|
{
|
||||||
|
return $oImapResponse &&
|
||||||
|
$oImapResponse->ResponseType === \MailSo\Imap\Enumerations\ResponseType::UNTAGGED &&
|
||||||
|
(
|
||||||
|
($oImapResponse->StatusOrIndex === 'STATUS' && 2 === \count($oImapResponse->ResponseList)) ||
|
||||||
|
($oImapResponse->StatusOrIndex === 'LIST' && 4 === \count($oImapResponse->ResponseList)) ||
|
||||||
|
($oImapResponse->StatusOrIndex === 'LSUB' && 4 === \count($oImapResponse->ResponseList))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return array|string
|
* @return array|string
|
||||||
*
|
*
|
||||||
* @throws \MailSo\Net\Exceptions\Exception
|
* @throws \MailSo\Net\Exceptions\Exception
|
||||||
*/
|
*/
|
||||||
private function partialParseResponseBranch(&$oImapResponse, $iStackIndex = -1,
|
private function partialParseResponseBranch(&$oImapResponse,
|
||||||
$bTreatAsAtom = false, $sParentToken = '', $sOpenBracket = '')
|
$bTreatAsAtom = false, $sParentToken = '', $sOpenBracket = '')
|
||||||
{
|
{
|
||||||
$mNull = null;
|
$mNull = null;
|
||||||
|
|
||||||
$iStackIndex++;
|
|
||||||
$iPos = $this->iResponseBufParsedPos;
|
$iPos = $this->iResponseBufParsedPos;
|
||||||
|
$sClosingBracket = '';
|
||||||
|
|
||||||
$sPreviousAtomUpperCase = null;
|
$sPreviousAtomUpperCase = null;
|
||||||
$bIsEndOfList = false;
|
$bIsEndOfList = false;
|
||||||
$bIsClosingBracketSquare = false;
|
|
||||||
$iLiteralLen = 0;
|
$iLiteralLen = 0;
|
||||||
$iBufferEndIndex = 0;
|
$iBufferEndIndex = 0;
|
||||||
$iDebugCount = 0;
|
$iDebugCount = 0;
|
||||||
|
|
@ -2164,12 +2179,12 @@ class ImapClient extends \MailSo\Net\NetClient
|
||||||
{
|
{
|
||||||
if ($bTreatAsAtom)
|
if ($bTreatAsAtom)
|
||||||
{
|
{
|
||||||
$sAtomBlock = $this->partialParseResponseBranch($mNull, $iStackIndex, true,
|
$sAtomBlock = $this->partialParseResponseBranch($mNull, true,
|
||||||
null === $sPreviousAtomUpperCase ? '' : \strtoupper($sPreviousAtomUpperCase), $sOpenBracket);
|
null === $sPreviousAtomUpperCase ? '' : \strtoupper($sPreviousAtomUpperCase), $sOpenBracket);
|
||||||
|
|
||||||
$sAtomBuilder .= $sAtomBlock;
|
$sAtomBuilder .= $sAtomBlock;
|
||||||
$iPos = $this->iResponseBufParsedPos;
|
$iPos = $this->iResponseBufParsedPos;
|
||||||
$sAtomBuilder .= ($bIsClosingBracketSquare) ? ']' : ')';
|
$sAtomBuilder .= $sClosingBracket;
|
||||||
}
|
}
|
||||||
|
|
||||||
$sPreviousAtomUpperCase = null;
|
$sPreviousAtomUpperCase = null;
|
||||||
|
|
@ -2179,7 +2194,7 @@ class ImapClient extends \MailSo\Net\NetClient
|
||||||
}
|
}
|
||||||
else if ($bIsGotoNotAtomBracket)
|
else if ($bIsGotoNotAtomBracket)
|
||||||
{
|
{
|
||||||
$aSubItems = $this->partialParseResponseBranch($mNull, $iStackIndex, false,
|
$aSubItems = $this->partialParseResponseBranch($mNull, false,
|
||||||
null === $sPreviousAtomUpperCase ? '' : \strtoupper($sPreviousAtomUpperCase), $sOpenBracket);
|
null === $sPreviousAtomUpperCase ? '' : \strtoupper($sPreviousAtomUpperCase), $sOpenBracket);
|
||||||
|
|
||||||
$aList[] = $aSubItems;
|
$aList[] = $aSubItems;
|
||||||
|
|
@ -2213,14 +2228,18 @@ class ImapClient extends \MailSo\Net\NetClient
|
||||||
switch (true)
|
switch (true)
|
||||||
{
|
{
|
||||||
case ']' === $sChar:
|
case ']' === $sChar:
|
||||||
$iPos++;
|
|
||||||
$sPreviousAtomUpperCase = null;
|
|
||||||
$bIsEndOfList = true;
|
|
||||||
break;
|
|
||||||
case ')' === $sChar:
|
case ')' === $sChar:
|
||||||
$iPos++;
|
if ($this->skipBracketParse($oImapResponse))
|
||||||
$sPreviousAtomUpperCase = null;
|
{
|
||||||
$bIsEndOfList = true;
|
$bIsGotoDefault = true;
|
||||||
|
$bIsGotoNotAtomBracket = false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$iPos++;
|
||||||
|
$sPreviousAtomUpperCase = null;
|
||||||
|
$bIsEndOfList = true;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case ' ' === $sChar:
|
case ' ' === $sChar:
|
||||||
if ($bTreatAsAtom)
|
if ($bTreatAsAtom)
|
||||||
|
|
@ -2230,29 +2249,27 @@ class ImapClient extends \MailSo\Net\NetClient
|
||||||
$iPos++;
|
$iPos++;
|
||||||
break;
|
break;
|
||||||
case '[' === $sChar:
|
case '[' === $sChar:
|
||||||
$bIsClosingBracketSquare = true;
|
|
||||||
case '(' === $sChar:
|
case '(' === $sChar:
|
||||||
if ('(' === $sChar)
|
$sClosingBracket = '[' === $sChar ? ']' : ')';
|
||||||
{
|
$sOpenBracket = $sChar;
|
||||||
$bIsClosingBracketSquare = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($bTreatAsAtom)
|
if ($bTreatAsAtom)
|
||||||
{
|
{
|
||||||
$sAtomBuilder .= $bIsClosingBracketSquare ? '[' : '(';
|
$sAtomBuilder .= $sChar;
|
||||||
}
|
|
||||||
$iPos++;
|
|
||||||
|
|
||||||
$this->iResponseBufParsedPos = $iPos;
|
|
||||||
if ($bTreatAsAtom)
|
|
||||||
{
|
|
||||||
$bIsGotoAtomBracket = true;
|
$bIsGotoAtomBracket = true;
|
||||||
$sOpenBracket = $bIsClosingBracketSquare ? '[' : '(';
|
$this->iResponseBufParsedPos = ++$iPos;
|
||||||
|
}
|
||||||
|
else if ($this->skipBracketParse($oImapResponse))
|
||||||
|
{
|
||||||
|
$sOpenBracket = '';
|
||||||
|
$sClosingBracket = '';
|
||||||
|
$bIsGotoDefault = true;
|
||||||
|
$bIsGotoNotAtomBracket = false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$bIsGotoNotAtomBracket = true;
|
$bIsGotoNotAtomBracket = true;
|
||||||
$sOpenBracket = $bIsClosingBracketSquare ? '[' : '(';
|
$this->iResponseBufParsedPos = ++$iPos;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case '{' === $sChar:
|
case '{' === $sChar:
|
||||||
|
|
@ -2382,6 +2399,10 @@ class ImapClient extends \MailSo\Net\NetClient
|
||||||
$sCharDef = $this->sResponseBuffer[$iPos];
|
$sCharDef = $this->sResponseBuffer[$iPos];
|
||||||
switch (true)
|
switch (true)
|
||||||
{
|
{
|
||||||
|
case ('[' === $sCharDef || ']' === $sCharDef || '(' === $sCharDef || ')' === $sCharDef) &&
|
||||||
|
$this->skipBracketParse($oImapResponse):
|
||||||
|
$iPos++;
|
||||||
|
break;
|
||||||
case '[' === $sCharDef:
|
case '[' === $sCharDef:
|
||||||
if (null === $sAtomBuilder)
|
if (null === $sAtomBuilder)
|
||||||
{
|
{
|
||||||
|
|
@ -2393,7 +2414,7 @@ class ImapClient extends \MailSo\Net\NetClient
|
||||||
$iPos++;
|
$iPos++;
|
||||||
$this->iResponseBufParsedPos = $iPos;
|
$this->iResponseBufParsedPos = $iPos;
|
||||||
|
|
||||||
$sListBlock = $this->partialParseResponseBranch($mNull, $iStackIndex, true,
|
$sListBlock = $this->partialParseResponseBranch($mNull, true,
|
||||||
null === $sPreviousAtomUpperCase ? '' : \strtoupper($sPreviousAtomUpperCase), '[');
|
null === $sPreviousAtomUpperCase ? '' : \strtoupper($sPreviousAtomUpperCase), '[');
|
||||||
|
|
||||||
if (null !== $sListBlock)
|
if (null !== $sListBlock)
|
||||||
|
|
@ -2401,6 +2422,8 @@ class ImapClient extends \MailSo\Net\NetClient
|
||||||
$sAtomBuilder .= $sListBlock.']';
|
$sAtomBuilder .= $sListBlock.']';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$this->Logger()->Write('$sAtomBuilder='.$sAtomBuilder);
|
||||||
|
|
||||||
$iPos = $this->iResponseBufParsedPos;
|
$iPos = $this->iResponseBufParsedPos;
|
||||||
$iCharBlockStartPos = $iPos;
|
$iCharBlockStartPos = $iPos;
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue