Improved handling of Internationalized Domain Names in punycode

This commit is contained in:
the-djmaze 2024-03-12 16:06:17 +01:00
parent fd54796710
commit 696a2bbd3c
45 changed files with 661 additions and 236 deletions

View file

@ -154,26 +154,23 @@ trait UserAuth
$oMainAccount = $this->getMainAccountFromToken(false);
if ($sEmail && $oMainAccount && $this->GetCapa(Capa::ADDITIONAL_ACCOUNTS)) {
$oAccount = null;
if ($oMainAccount->Email() === $sEmail) {
$this->SetAdditionalAuthToken($oAccount);
return true;
}
$sEmail = \MailSo\Base\Utils::IdnToAscii($sEmail);
$aAccounts = $this->GetAccounts($oMainAccount);
if (!isset($aAccounts[$sEmail])) {
throw new ClientException(Notifications::AccountDoesNotExist);
}
$oAccount = AdditionalAccount::NewInstanceFromTokenArray(
$this, $aAccounts[$sEmail]
);
if (!$oAccount) {
throw new ClientException(Notifications::AccountSwitchFailed);
}
// Test the login
$oImapClient = new \MailSo\Imap\ImapClient;
$this->imapConnect($oAccount, false, $oImapClient);
if ($oMainAccount->Email() !== $sEmail) {
$sEmail = \SnappyMail\IDN::emailToAscii($sEmail);
$aAccounts = $this->GetAccounts($oMainAccount);
if (!isset($aAccounts[$sEmail])) {
throw new ClientException(Notifications::AccountDoesNotExist);
}
$oAccount = AdditionalAccount::NewInstanceFromTokenArray(
$this, $aAccounts[$sEmail]
);
if (!$oAccount) {
throw new ClientException(Notifications::AccountSwitchFailed);
}
// Test the login
$oImapClient = new \MailSo\Imap\ImapClient;
$this->imapConnect($oAccount, false, $oImapClient);
}
$this->SetAdditionalAuthToken($oAccount);
return true;
}