mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-07-08 22:18:28 +03:00
Improved handling of Internationalized Domain Names in punycode
This commit is contained in:
parent
fd54796710
commit
696a2bbd3c
45 changed files with 661 additions and 236 deletions
|
|
@ -10,8 +10,8 @@ class AvatarsPlugin extends \RainLoop\Plugins\AbstractPlugin
|
|||
NAME = 'Avatars',
|
||||
AUTHOR = 'SnappyMail',
|
||||
URL = 'https://snappymail.eu/',
|
||||
VERSION = '1.15',
|
||||
RELEASE = '2024-01-22',
|
||||
VERSION = '1.16',
|
||||
RELEASE = '2024-03-12',
|
||||
REQUIRED = '2.25.0',
|
||||
CATEGORY = 'Contacts',
|
||||
LICENSE = 'MIT',
|
||||
|
|
@ -208,7 +208,7 @@ class AvatarsPlugin extends \RainLoop\Plugins\AbstractPlugin
|
|||
return null;
|
||||
}
|
||||
|
||||
$sAsciiEmail = \mb_strtolower(\MailSo\Base\Utils::IdnToAscii($sEmail, true));
|
||||
$sAsciiEmail = \mb_strtolower(\SnappyMail\IDN::emailToAscii($sEmail));
|
||||
$sEmailId = \sha1($sAsciiEmail);
|
||||
|
||||
\MailSo\Base\Http::setETag($sEmailId);
|
||||
|
|
@ -310,7 +310,7 @@ class AvatarsPlugin extends \RainLoop\Plugins\AbstractPlugin
|
|||
|
||||
private static function cacheImage(string $sEmail, array $aResult) : void
|
||||
{
|
||||
$sEmailId = \sha1(\mb_strtolower(\MailSo\Base\Utils::IdnToAscii($sEmail, true)));
|
||||
$sEmailId = \sha1(\mb_strtolower(\SnappyMail\IDN::emailToAscii($sEmail)));
|
||||
if (!\is_dir(\APP_PRIVATE_DATA . 'avatars')) {
|
||||
\mkdir(\APP_PRIVATE_DATA . 'avatars', 0700);
|
||||
}
|
||||
|
|
@ -323,7 +323,7 @@ class AvatarsPlugin extends \RainLoop\Plugins\AbstractPlugin
|
|||
|
||||
private static function getCachedImage(string $sEmail) : ?array
|
||||
{
|
||||
$sEmail = \mb_strtolower(\MailSo\Base\Utils::IdnToAscii($sEmail, true));
|
||||
$sEmail = \mb_strtolower(\SnappyMail\IDN::emailToAscii($sEmail));
|
||||
$aFiles = \glob(\APP_PRIVATE_DATA . "avatars/{$sEmail}.*");
|
||||
if ($aFiles) {
|
||||
\MailSo\Base\Http::setLastModified(\filemtime($aFiles[0]));
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ class ChangePasswordHMailServerDriver
|
|||
$this->oConfig->Get('plugin', 'hmailserver_password', '')
|
||||
)) {
|
||||
$sEmail = $oAccount->Email();
|
||||
$sDomain = \MailSo\Base\Utils::GetDomainFromEmail($sEmail);
|
||||
$sDomain = \MailSo\Base\Utils::getEmailAddressDomain($sEmail);
|
||||
$oHmailDomain = $oHmailApp->Domains->ItemByName($sDomain);
|
||||
if ($oHmailDomain) {
|
||||
$oHmailAccount = $oHmailDomain->Accounts->ItemByAddress($sEmail);
|
||||
|
|
|
|||
|
|
@ -6,9 +6,9 @@ class ChangePasswordHMailServerPlugin extends \RainLoop\Plugins\AbstractPlugin
|
|||
{
|
||||
const
|
||||
NAME = 'Change Password hMailServer',
|
||||
VERSION = '2.0',
|
||||
RELEASE = '2022-10-14',
|
||||
REQUIRED = '2.15.3',
|
||||
VERSION = '2.1',
|
||||
RELEASE = '2024-03-12',
|
||||
REQUIRED = '2.35.3',
|
||||
CATEGORY = 'Security',
|
||||
DESCRIPTION = 'Extension to allow users to change their passwords through hMailServer';
|
||||
|
||||
|
|
|
|||
|
|
@ -57,12 +57,12 @@ class ChangePasswordDriverLDAP
|
|||
|
||||
public function ChangePassword(\RainLoop\Model\Account $oAccount, string $sPrevPassword, string $sNewPassword) : bool
|
||||
{
|
||||
$sDomain = \MailSo\Base\Utils::GetDomainFromEmail($oAccount->Email());
|
||||
$sDomain = \MailSo\Base\Utils::getEmailAddressDomain($oAccount->Email());
|
||||
$sUserDn = \strtr($this->sUserDnFormat, array(
|
||||
'{domain}' => $sDomain,
|
||||
'{domain:dc}' => 'dc='.\strtr($sDomain, array('.' => ',dc=')),
|
||||
'{email}' => $oAccount->Email(),
|
||||
'{email:user}' => \MailSo\Base\Utils::GetAccountNameFromEmail($oAccount->Email()),
|
||||
'{email:user}' => \MailSo\Base\Utils::getEmailAddressLocalPart($oAccount->Email()),
|
||||
'{email:domain}' => $sDomain,
|
||||
'{login}' => $oAccount->IncLogin(),
|
||||
'{imap:login}' => $oAccount->IncLogin(),
|
||||
|
|
|
|||
|
|
@ -87,8 +87,8 @@ class ChangePasswordDriverPDO
|
|||
':email' => $sEmail,
|
||||
':oldpass' => $encrypt_prefix . \ChangePasswordPlugin::encrypt($encrypt, $sPrevPassword),
|
||||
':newpass' => $encrypt_prefix . \ChangePasswordPlugin::encrypt($encrypt, $sNewPassword),
|
||||
':domain' => \MailSo\Base\Utils::GetDomainFromEmail($sEmail),
|
||||
':username' => \MailSo\Base\Utils::GetAccountNameFromEmail($sEmail),
|
||||
':domain' => \MailSo\Base\Utils::getEmailAddressDomain($sEmail),
|
||||
':username' => \MailSo\Base\Utils::getEmailAddressLocalPart($sEmail),
|
||||
':login_name' => $oAccount->IncLogin()
|
||||
);
|
||||
|
||||
|
|
|
|||
|
|
@ -7,8 +7,8 @@ class ChangePasswordPlugin extends \RainLoop\Plugins\AbstractPlugin
|
|||
const
|
||||
NAME = 'Change Password',
|
||||
VERSION = '2.20',
|
||||
RELEASE = '2024-03-10',
|
||||
REQUIRED = '2.23.0',
|
||||
RELEASE = '2024-03-12',
|
||||
REQUIRED = '2.35.3',
|
||||
CATEGORY = 'Security',
|
||||
DESCRIPTION = 'Extension to allow users to change their passwords';
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
<?php
|
||||
getEmailAddressDomain<?php
|
||||
|
||||
class LdapContactsSuggestions implements \RainLoop\Providers\Suggestions\ISuggestions
|
||||
{
|
||||
|
|
@ -93,12 +93,12 @@ class LdapContactsSuggestions implements \RainLoop\Providers\Suggestions\ISugges
|
|||
return $aResult;
|
||||
}
|
||||
|
||||
$sDomain = \MailSo\Base\Utils::GetDomainFromEmail($oAccount->Email());
|
||||
$sDomain = \MailSo\Base\Utils::getEmailAddressDomain($oAccount->Email());
|
||||
$sBaseDn = \strtr($this->sBaseDn, array(
|
||||
'{domain}' => $sDomain,
|
||||
'{domain:dc}' => 'dc='.\strtr($sDomain, array('.' => ',dc=')),
|
||||
'{email}' => $oAccount->Email(),
|
||||
'{email:user}' => \MailSo\Base\Utils::GetAccountNameFromEmail($oAccount->Email()),
|
||||
'{email:user}' => \MailSo\Base\Utils::getEmailAddressLocalPart($oAccount->Email()),
|
||||
'{email:domain}' => $sDomain,
|
||||
'{login}' => $oAccount->IncLogin(),
|
||||
'{imap:login}' => $oAccount->IncLogin(),
|
||||
|
|
|
|||
|
|
@ -5,8 +5,8 @@ class LdapContactsSuggestionsPlugin extends \RainLoop\Plugins\AbstractPlugin
|
|||
const
|
||||
NAME = 'Contacts suggestions (LDAP)',
|
||||
VERSION = '2.14',
|
||||
RELEASE = '2024-03-10',
|
||||
REQUIRED = '2.23.0',
|
||||
RELEASE = '2024-03-12',
|
||||
REQUIRED = '2.35.3',
|
||||
CATEGORY = 'Contacts',
|
||||
DESCRIPTION = 'Get contacts suggestions from LDAP.';
|
||||
|
||||
|
|
|
|||
|
|
@ -8,10 +8,10 @@ class LDAPLoginMappingPlugin extends AbstractPlugin
|
|||
{
|
||||
const
|
||||
NAME = 'LDAP login mapping',
|
||||
VERSION = '2.1',
|
||||
VERSION = '2.2',
|
||||
AUTHOR = 'RainLoop Team, Ludovic Pouzenc<ludovic@pouzenc.fr>, ZephOne<zephone@protonmail.com>',
|
||||
RELEASE = '2023-01-19',
|
||||
REQUIRED = '2.19.2',
|
||||
RELEASE = '2024-03-12',
|
||||
REQUIRED = '2.35.3',
|
||||
CATEGORY = 'Login',
|
||||
DESCRIPTION = 'Enable custom mapping using ldap field';
|
||||
/**
|
||||
|
|
@ -175,7 +175,7 @@ class LDAPLoginMappingPlugin extends AbstractPlugin
|
|||
'LDAP');
|
||||
return FALSE;
|
||||
}
|
||||
$sLogin = \MailSo\Base\Utils::GetAccountNameFromEmail($sEmail);
|
||||
$sLogin = \MailSo\Base\Utils::getEmailAddressLocalPart($sEmail);
|
||||
|
||||
$this->oLogger->Write('ldap_connect: trying...', \LOG_INFO, 'LDAP');
|
||||
|
||||
|
|
|
|||
|
|
@ -69,7 +69,7 @@ class LdapMailAccounts
|
|||
// and removes the domainname if this was configured inside the domain config.
|
||||
$username = $sEmail;
|
||||
$oActions = \RainLoop\Api::Actions();
|
||||
$oDomain = $oActions->DomainProvider()->Load(\MailSo\Base\Utils::GetDomainFromEmail($sEmail), true);
|
||||
$oDomain = $oActions->DomainProvider()->Load(\MailSo\Base\Utils::getEmailAddressDomain($sEmail), true);
|
||||
if ($oDomain->ImapSettings()->shortLogin){
|
||||
$username = @ldap_escape($this->RemoveEventualDomainPart($sEmail), "", LDAP_ESCAPE_FILTER);
|
||||
}
|
||||
|
|
@ -415,8 +415,8 @@ class LdapMailAccounts
|
|||
*/
|
||||
public static function RemoveEventualDomainPart(string $sInput) : string
|
||||
{
|
||||
// Copy of \MailSo\Base\Utils::GetAccountNameFromEmail to make sure that also after eventual future
|
||||
// updates the input string gets returned when no '@' is found (GetDomainFromEmail already doesn't do this)
|
||||
// Copy of \MailSo\Base\Utils::getEmailAddressLocalPart to make sure that also after eventual future
|
||||
// updates the input string gets returned when no '@' is found (getEmailAddressDomain already doesn't do this)
|
||||
$sResult = '';
|
||||
if (\strlen($sInput))
|
||||
{
|
||||
|
|
|
|||
|
|
@ -15,8 +15,8 @@ class LdapMailAccountsPlugin extends AbstractPlugin
|
|||
VERSION = '2.1.0',
|
||||
AUTHOR = 'cm-schl',
|
||||
URL = 'https://github.com/cm-sch',
|
||||
RELEASE = '2024-03-10',
|
||||
REQUIRED = '2.25.4',
|
||||
RELEASE = '2024-03-12',
|
||||
REQUIRED = '2.35.3',
|
||||
CATEGORY = 'Accounts',
|
||||
DESCRIPTION = 'Add additional mail accounts the SnappyMail user has access to by a LDAP query. Basing on the work of FWest98 (https://github.com/FWest98).';
|
||||
|
||||
|
|
|
|||
|
|
@ -12,8 +12,8 @@ class LoginAutoconfigPlugin extends \RainLoop\Plugins\AbstractPlugin
|
|||
AUTHOR = 'SnappyMail',
|
||||
URL = 'https://snappymail.eu/',
|
||||
VERSION = '1.1',
|
||||
RELEASE = '2024-03-10',
|
||||
REQUIRED = '2.34.0',
|
||||
RELEASE = '2024-03-12',
|
||||
REQUIRED = '2.35.3',
|
||||
CATEGORY = 'Login',
|
||||
LICENSE = 'MIT',
|
||||
DESCRIPTION = 'Tries to login using the domain autoconfig';
|
||||
|
|
@ -27,7 +27,7 @@ class LoginAutoconfigPlugin extends \RainLoop\Plugins\AbstractPlugin
|
|||
{
|
||||
if (\str_contains($sEmail, '@')) {
|
||||
$oProvider = $this->Manager()->Actions()->DomainProvider();
|
||||
$sDomain = \MailSo\Base\Utils::GetDomainFromEmail($sEmail);
|
||||
$sDomain = \MailSo\Base\Utils::getEmailAddressDomain($sEmail);
|
||||
$oDomain = $oProvider->Load($sDomain, false);
|
||||
if (!$oDomain) {
|
||||
$result = \RainLoop\Providers\Domain\Autoconfig::discover($sEmail);
|
||||
|
|
|
|||
|
|
@ -4,9 +4,9 @@ class LoginOAuth2Plugin extends \RainLoop\Plugins\AbstractPlugin
|
|||
{
|
||||
const
|
||||
NAME = 'OAuth2',
|
||||
VERSION = '1.1',
|
||||
RELEASE = '2022-11-11',
|
||||
REQUIRED = '2.21.0',
|
||||
VERSION = '1.2',
|
||||
RELEASE = '2024-03-12',
|
||||
REQUIRED = '2.35.3',
|
||||
CATEGORY = 'Login',
|
||||
DESCRIPTION = 'IMAP, Sieve & SMTP login using RFC 7628 OAuth2';
|
||||
|
||||
|
|
@ -55,7 +55,7 @@ class LoginOAuth2Plugin extends \RainLoop\Plugins\AbstractPlugin
|
|||
|
||||
public function clientLogin(\RainLoop\Model\Account $oAccount, \MailSo\Net\NetClient $oClient, \MailSo\Net\ConnectSettings $oSettings) : void
|
||||
{
|
||||
$sPassword = $oSettings->Password;
|
||||
$sPassword = $oSettings->passphrase;
|
||||
$iGatLen = \strlen(static::GMAIL_TOKENS_PREFIX);
|
||||
if ($sPassword && static::GMAIL_TOKENS_PREFIX === \substr($sPassword, 0, $iGatLen)) {
|
||||
$aTokens = \json_decode(\substr($sPassword, $iGatLen));
|
||||
|
|
@ -63,7 +63,7 @@ class LoginOAuth2Plugin extends \RainLoop\Plugins\AbstractPlugin
|
|||
$sRefreshToken = !empty($aTokens[1]) ? $aTokens[1] : '';
|
||||
}
|
||||
if ($sAccessToken && $sRefreshToken) {
|
||||
$oSettings->Password = $this->gmailRefreshToken($sAccessToken, $sRefreshToken);
|
||||
$oSettings->passphrase = $this->gmailRefreshToken($sAccessToken, $sRefreshToken);
|
||||
\array_unshift($oSettings->SASLMechanisms, 'OAUTHBEARER', 'XOAUTH2');
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,9 +4,9 @@ class LoginOverridePlugin extends \RainLoop\Plugins\AbstractPlugin
|
|||
{
|
||||
const
|
||||
NAME = 'Login Override',
|
||||
VERSION = '2.2',
|
||||
RELEASE = '2023-02-08',
|
||||
REQUIRED = '2.25.3',
|
||||
VERSION = '2.3',
|
||||
RELEASE = '2024-03-12',
|
||||
REQUIRED = '2.35.3',
|
||||
CATEGORY = 'Filters',
|
||||
DESCRIPTION = 'Override IMAP/SMTP login credentials for specific users.';
|
||||
|
||||
|
|
@ -50,10 +50,10 @@ class LoginOverridePlugin extends \RainLoop\Plugins\AbstractPlugin
|
|||
$line = \explode(':', $line, 3);
|
||||
if (!empty($line[0]) && $line[0] === $sEmail) {
|
||||
if (!empty($line[1])) {
|
||||
$oSettings->Login = $line[1];
|
||||
$oSettings->username = $line[1];
|
||||
}
|
||||
if (!empty($line[2])) {
|
||||
$oSettings->Password = $line[2];
|
||||
$oSettings->passphrase = $line[2];
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,11 +4,11 @@ class NextcloudPlugin extends \RainLoop\Plugins\AbstractPlugin
|
|||
{
|
||||
const
|
||||
NAME = 'Nextcloud',
|
||||
VERSION = '2.31',
|
||||
RELEASE = '2024-02-18',
|
||||
VERSION = '2.32',
|
||||
RELEASE = '2024-03-12',
|
||||
CATEGORY = 'Integrations',
|
||||
DESCRIPTION = 'Integrate with Nextcloud v20+',
|
||||
REQUIRED = '2.34.0';
|
||||
REQUIRED = '2.35.3';
|
||||
|
||||
public function Init() : void
|
||||
{
|
||||
|
|
@ -80,7 +80,7 @@ class NextcloudPlugin extends \RainLoop\Plugins\AbstractPlugin
|
|||
) {
|
||||
$sAccessToken = \OC::$server->getSession()->get('oidc_access_token');
|
||||
if ($sAccessToken) {
|
||||
$oSettings->Password = $sAccessToken;
|
||||
$oSettings->passphrase = $sAccessToken;
|
||||
\array_unshift($oSettings->SASLMechanisms, 'OAUTHBEARER');
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,9 +4,9 @@ class OverrideSmtpCredentialsPlugin extends \RainLoop\Plugins\AbstractPlugin
|
|||
{
|
||||
const
|
||||
NAME = 'Override SMTP Credentials',
|
||||
VERSION = '2.4',
|
||||
RELEASE = '2023-01-19',
|
||||
REQUIRED = '2.23.0',
|
||||
VERSION = '2.5',
|
||||
RELEASE = '2024-03-12',
|
||||
REQUIRED = '2.35.3',
|
||||
CATEGORY = 'Filters',
|
||||
DESCRIPTION = 'Override SMTP credentials for specific users.';
|
||||
|
||||
|
|
@ -67,8 +67,8 @@ class OverrideSmtpCredentialsPlugin extends \RainLoop\Plugins\AbstractPlugin
|
|||
$sFoundValue = '';
|
||||
if (\strlen($sWhiteList) && \RainLoop\Plugins\Helper::ValidateWildcardValues($oAccount->Email(), $sWhiteList, $sFoundValue)) {
|
||||
$oSettings->useAuth = (bool) $this->Config()->Get('plugin', 'smtp_auth', true);
|
||||
$oSettings->Login = \trim($this->Config()->Get('plugin', 'smtp_user', ''));
|
||||
$oSettings->Password = (string) $this->Config()->Get('plugin', 'smtp_password', '');
|
||||
$oSettings->username = \trim($this->Config()->Get('plugin', 'smtp_user', ''));
|
||||
$oSettings->passphrase = (string) $this->Config()->Get('plugin', 'smtp_password', '');
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -7,8 +7,8 @@ class RecaptchaPlugin extends \RainLoop\Plugins\AbstractPlugin
|
|||
AUTHOR = 'SnappyMail',
|
||||
URL = 'https://snappymail.eu/',
|
||||
VERSION = '2.16',
|
||||
RELEASE = '2024-03-11',
|
||||
REQUIRED = '2.26.4',
|
||||
RELEASE = '2024-03-12',
|
||||
REQUIRED = '2.35.3',
|
||||
CATEGORY = 'General',
|
||||
LICENSE = 'MIT',
|
||||
DESCRIPTION = 'A CAPTCHA (v2) is a program that can generate and grade tests that humans can pass but current computer programs cannot. For example, humans can read distorted text as the one shown below, but current computer programs can\'t. More info at https://developers.google.com/recaptcha';
|
||||
|
|
|
|||
|
|
@ -7,9 +7,9 @@ class SmtpUseFromAdrAccountPlugin extends \RainLoop\Plugins\AbstractPlugin
|
|||
NAME = 'Use From-Address-Account for smtp',
|
||||
AUTHOR = 'attike',
|
||||
URL = 'https://github.com/attike',
|
||||
VERSION = '1.1',
|
||||
RELEASE = '2024-03-10',
|
||||
REQUIRED = '2.23.0',
|
||||
VERSION = '1.1',
|
||||
RELEASE = '2024-03-12',
|
||||
REQUIRED = '2.35.3',
|
||||
CATEGORY = 'Filters',
|
||||
DESCRIPTION = 'Set smpt-config and -credentials based on selected from-address-account';
|
||||
|
||||
|
|
@ -88,9 +88,9 @@ class SmtpUseFromAdrAccountPlugin extends \RainLoop\Plugins\AbstractPlugin
|
|||
if ( isset($this->aFromAccount[$oAccount->Email()]) ) {
|
||||
$oFromAccount = $this->aFromAccount[$oAccount->Email()];
|
||||
unset($this->aFromAccount[$oAccount->Email()]);
|
||||
$oSettings->Login = $oFromAccount->OutLogin();
|
||||
$oSettings->useAuth = $oFromAccount->Domain()->SmtpSettings()->useAuth;
|
||||
$oSettings->Password = $oFromAccount->IncPassword();
|
||||
$oSettings->username = $oFromAccount->OutLogin();
|
||||
$oSettings->passphrase = $oFromAccount->IncPassword();
|
||||
\SnappyMail\LOG::info(get_class($this),'user/pwd rewrite: '. $oFromAccount->Email());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue