mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-07-13 03:27:39 +03:00
IMAP LOGIN returns CAPABILITY, use that.
And bugfix broken XOAUTH2
This commit is contained in:
parent
55c41c16b1
commit
2eac280508
2 changed files with 32 additions and 38 deletions
|
|
@ -19,10 +19,8 @@ class ImapClient extends \MailSo\Net\NetClient
|
||||||
{
|
{
|
||||||
use Traits\ResponseParser;
|
use Traits\ResponseParser;
|
||||||
|
|
||||||
/**
|
const
|
||||||
* @var string
|
TAG_PREFIX = 'TAG';
|
||||||
*/
|
|
||||||
const TAG_PREFIX = 'TAG';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var int
|
* @var int
|
||||||
|
|
@ -166,7 +164,8 @@ class ImapClient extends \MailSo\Net\NetClient
|
||||||
$this->oLogger->AddSecret($sChallenge);
|
$this->oLogger->AddSecret($sChallenge);
|
||||||
}
|
}
|
||||||
$this->sendRaw($sChallenge, true, '*******');
|
$this->sendRaw($sChallenge, true, '*******');
|
||||||
$sSignature = $this->getResponseValue($this->getResponse());
|
$oResponse = $this->getResponse();
|
||||||
|
$sSignature = $this->getResponseValue($oResponse);
|
||||||
$SASL->verify($sSignature);
|
$SASL->verify($sSignature);
|
||||||
}
|
}
|
||||||
else if ('CRAM-MD5' === $type)
|
else if ('CRAM-MD5' === $type)
|
||||||
|
|
@ -178,7 +177,7 @@ class ImapClient extends \MailSo\Net\NetClient
|
||||||
$this->oLogger->AddSecret($sAuth);
|
$this->oLogger->AddSecret($sAuth);
|
||||||
}
|
}
|
||||||
$this->sendRaw($sAuth, true, '*******');
|
$this->sendRaw($sAuth, true, '*******');
|
||||||
$this->getResponse();
|
$oResponse = $this->getResponse();
|
||||||
}
|
}
|
||||||
else if ('PLAIN' === $type || 'OAUTHBEARER' === $type)
|
else if ('PLAIN' === $type || 'OAUTHBEARER' === $type)
|
||||||
{
|
{
|
||||||
|
|
@ -187,28 +186,26 @@ class ImapClient extends \MailSo\Net\NetClient
|
||||||
$this->oLogger->AddSecret($sAuth);
|
$this->oLogger->AddSecret($sAuth);
|
||||||
}
|
}
|
||||||
if ($this->IsSupported('SASL-IR')) {
|
if ($this->IsSupported('SASL-IR')) {
|
||||||
$this->SendRequestGetResponse('AUTHENTICATE', array($type, $sAuth));
|
$oResponse = $this->SendRequestGetResponse('AUTHENTICATE', array($type, $sAuth));
|
||||||
} else {
|
} else {
|
||||||
$this->SendRequestGetResponse('AUTHENTICATE', array($type));
|
$this->SendRequestGetResponse('AUTHENTICATE', array($type));
|
||||||
$this->sendRaw($sAuth, true, '*******');
|
$this->sendRaw($sAuth, true, '*******');
|
||||||
$this->getResponse();
|
$oResponse = $this->getResponse();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if ('XOAUTH2' === $type)
|
else if ('XOAUTH2' === $type)
|
||||||
{
|
{
|
||||||
$sAuth = $SASL->authenticate($sLogin, $sPassword);
|
$sAuth = $SASL->authenticate($sLogin, $sPassword);
|
||||||
$this->SendRequest('AUTHENTICATE', array($type, $sAuth));
|
$this->SendRequest('AUTHENTICATE', array($type, $sAuth));
|
||||||
$aR = $this->parseResponseWithValidation();
|
$oResponse = $this->getResponse();
|
||||||
if (\is_array($aR) && \count($aR) && isset($aR[\count($aR) - 1])) {
|
$oR = $oResponse->getLast();
|
||||||
$oR = $aR[\count($aR) - 1];
|
if ($oR && Enumerations\ResponseType::CONTINUATION === $oR->ResponseType) {
|
||||||
if (Enumerations\ResponseType::CONTINUATION === $oR->ResponseType) {
|
if (!empty($oR->ResponseList[1]) && preg_match('/^[a-zA-Z0-9=+\/]+$/', $oR->ResponseList[1])) {
|
||||||
if (!empty($oR->ResponseList[1]) && preg_match('/^[a-zA-Z0-9=+\/]+$/', $oR->ResponseList[1])) {
|
$this->Logger()->Write(\base64_decode($oR->ResponseList[1]),
|
||||||
$this->Logger()->Write(\base64_decode($oR->ResponseList[1]),
|
\MailSo\Log\Enumerations\Type::WARNING);
|
||||||
\MailSo\Log\Enumerations\Type::WARNING);
|
|
||||||
}
|
|
||||||
$this->sendRaw('');
|
|
||||||
$this->parseResponseWithValidation();
|
|
||||||
}
|
}
|
||||||
|
$this->sendRaw('');
|
||||||
|
$oResponse = $this->getResponse();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if ($this->IsSupported('LOGINDISABLED'))
|
else if ($this->IsSupported('LOGINDISABLED'))
|
||||||
|
|
@ -221,7 +218,7 @@ class ImapClient extends \MailSo\Net\NetClient
|
||||||
$this->oLogger->AddSecret($sPass);
|
$this->oLogger->AddSecret($sPass);
|
||||||
}
|
}
|
||||||
$this->sendRaw($sPass, true, '*******');
|
$this->sendRaw($sPass, true, '*******');
|
||||||
$this->getResponse();
|
$oResponse = $this->getResponse();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
@ -229,13 +226,15 @@ class ImapClient extends \MailSo\Net\NetClient
|
||||||
{
|
{
|
||||||
$this->oLogger->AddSecret($this->EscapeString($sPassword));
|
$this->oLogger->AddSecret($this->EscapeString($sPassword));
|
||||||
}
|
}
|
||||||
$this->SendRequestGetResponse('LOGIN',
|
$oResponse = $this->SendRequestGetResponse('LOGIN',
|
||||||
array(
|
array(
|
||||||
$this->EscapeString($sLogin),
|
$this->EscapeString($sLogin),
|
||||||
$this->EscapeString($sPassword)
|
$this->EscapeString($sPassword)
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$this->aCapabilityItems = $oResponse->getCapabilityResult();
|
||||||
|
|
||||||
if (\strlen($sProxyAuthUser))
|
if (\strlen($sProxyAuthUser))
|
||||||
{
|
{
|
||||||
$this->SendRequestGetResponse('PROXYAUTH', array($this->EscapeString($sProxyAuthUser)));
|
$this->SendRequestGetResponse('PROXYAUTH', array($this->EscapeString($sProxyAuthUser)));
|
||||||
|
|
@ -250,7 +249,6 @@ class ImapClient extends \MailSo\Net\NetClient
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->bIsLoggined = true;
|
$this->bIsLoggined = true;
|
||||||
$this->aCapabilityItems = null;
|
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -52,25 +52,21 @@ class ResponseCollection extends \MailSo\Base\Collection
|
||||||
public function getCapabilityResult() : ?array
|
public function getCapabilityResult() : ?array
|
||||||
{
|
{
|
||||||
foreach ($this as $oResponse) {
|
foreach ($this as $oResponse) {
|
||||||
if (Enumerations\ResponseType::UNTAGGED === $oResponse->ResponseType
|
$aList = null;
|
||||||
&& \is_array($oResponse->ResponseList))
|
if (isset($oResponse->ResponseList[1]) && \is_string($oResponse->ResponseList[1]) &&
|
||||||
|
'CAPABILITY' === \strtoupper($oResponse->ResponseList[1]))
|
||||||
{
|
{
|
||||||
$aList = null;
|
$aList = \array_slice($oResponse->ResponseList, 2);
|
||||||
if (isset($oResponse->ResponseList[1]) && \is_string($oResponse->ResponseList[1]) &&
|
}
|
||||||
'CAPABILITY' === \strtoupper($oResponse->ResponseList[1]))
|
else if ($oResponse->OptionalResponse && \is_array($oResponse->OptionalResponse) &&
|
||||||
{
|
1 < \count($oResponse->OptionalResponse) && \is_string($oResponse->OptionalResponse[0]) &&
|
||||||
$aList = \array_slice($oResponse->ResponseList, 2);
|
'CAPABILITY' === \strtoupper($oResponse->OptionalResponse[0]))
|
||||||
}
|
{
|
||||||
else if ($oResponse->OptionalResponse && \is_array($oResponse->OptionalResponse) &&
|
$aList = \array_slice($oResponse->OptionalResponse, 1);
|
||||||
1 < \count($oResponse->OptionalResponse) && \is_string($oResponse->OptionalResponse[0]) &&
|
}
|
||||||
'CAPABILITY' === \strtoupper($oResponse->OptionalResponse[0]))
|
|
||||||
{
|
|
||||||
$aList = \array_slice($oResponse->OptionalResponse, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (\is_array($aList) && 0 < \count($aList)) {
|
if (\is_array($aList) && \count($aList)) {
|
||||||
return \array_map('strtoupper', $aList);
|
return \array_map('strtoupper', $aList);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue