mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-07-13 03:27:39 +03:00
IDNA support (beta)
This commit is contained in:
parent
0ca00dec40
commit
e82108ac85
31 changed files with 3839 additions and 308 deletions
|
|
@ -1883,4 +1883,62 @@ class Utils
|
|||
'.aero .asia .biz .cat .com .coop .edu .gov .info .int .jobs .mil .mobi .museum .name .net .org .pro .tel .travel .xxx .ac .ad .ae .af .ag .ai .al .am .an .ao .aq .ar .as .at .au .aw .ax .az .ba .bb .bd .be .bf .bg .bh .bi .bj .bm .bn .bo .br .bs .bt .bv .bw .by .bz .ca .cc .cd .cf .cg .ch .ci .ck .cl .cm .cn .co .cr .cs .cu .cv .cx .cy .cz .dd .de .dj .dk .dm .do .dz .ec .ee .eg .er .es .et .eu .fi .fj .fk .fm .fo .fr .ga .gb .gd .ge .gf .gg .gh .gi .gl .gm .gn .gp .gq .gr .gs .gt .gu .gw .gy .hk .hm .hn .hr .ht .hu .id .ie .il .im .in .io .iq .ir .is .it .je .jm .jo .jp .ke .kg .kh .ki .km .kn .kp .kr .kw .ky .kz .la .lb .lc .li .lk .lr .ls .lt .lu .lv .ly .ma .mc .md .me .mg .mh .mk .ml .mm .mn .mo .mp .mq .mr .ms .mt .mu .mv .mw .mx .my .mz .na .nc .ne .nf .ng .ni .nl .no .np .nr .nu .nz .om .pa .pe .pf .pg .ph .pk .pl .pm .pn .pr .ps .pt .pw .py .qa .re .ro .rs .ru . .rw .sa .sb .sc .sd .se .sg .sh .si .sj .sk .sl .sm .sn .so .sr .st .su .sv .sy .sz .tc .td .tf .tg .th .tj .tk .tl .tm .tn .to .tp .tr .tt .tv .tw .tz .ua .ug .uk .us .uy .uz .va .vc .ve .vg .vi .vn .vu .wf .ws .ye .yt .za .zm .zw'
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Net_IDNA2
|
||||
*/
|
||||
private static function idn()
|
||||
{
|
||||
static $oIdn = null;
|
||||
if (null === $oIdn)
|
||||
{
|
||||
include_once MAILSO_LIBRARY_ROOT_PATH.'Vendors/NET/IDNA2.php';
|
||||
$oIdn = new \Net_IDNA2();
|
||||
}
|
||||
|
||||
return $oIdn;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $sDomain
|
||||
* @param bool $bLowerIfAscii = false
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function IdnToUtf8($sDomain, $bLowerIfAscii = false)
|
||||
{
|
||||
if ($sDomain && \preg_match('/(^|\.)xn--/i', $sDomain))
|
||||
{
|
||||
try
|
||||
{
|
||||
$sDomain = self::idn()->decode($sDomain);
|
||||
}
|
||||
catch (\Exception $oException) {}
|
||||
}
|
||||
|
||||
$sDomain = $bLowerIfAscii ? \MailSo\Base\Utils::StrToLowerIfAscii($sDomain) : $sDomain;
|
||||
return $sDomain;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $sDomain
|
||||
* @param bool $bLowerIfAscii = false
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function IdnToAscii($sDomain, $bLowerIfAscii = false)
|
||||
{
|
||||
$sDomain = $bLowerIfAscii ? \MailSo\Base\Utils::StrToLowerIfAscii($sDomain) : $sDomain;
|
||||
|
||||
if ($sDomain && \preg_match('/[^\x20-\x7E]/', $sDomain))
|
||||
{
|
||||
try
|
||||
{
|
||||
$sDomain = self::idn()->encode($sDomain);
|
||||
}
|
||||
catch (\Exception $oException) {}
|
||||
}
|
||||
|
||||
return $sDomain;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -188,6 +188,7 @@ class ImapClient extends \MailSo\Net\NetClient
|
|||
}
|
||||
|
||||
$sLogin = \trim($sLogin);
|
||||
$sLogin = \MailSo\Base\Utils::IdnToAscii($sLogin);
|
||||
$sPassword = $sPassword;
|
||||
|
||||
$this->sLogginedUser = $sLogin;
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ class Email
|
|||
throw new \MailSo\Base\Exceptions\InvalidArgumentException();
|
||||
}
|
||||
|
||||
$this->sEmail = \trim($sEmail);
|
||||
$this->sEmail = \MailSo\Base\Utils::IdnToAscii(\trim($sEmail), true);
|
||||
$this->sDisplayName = \trim($sDisplayName);
|
||||
$this->sRemark = \trim($sRemark);
|
||||
}
|
||||
|
|
@ -176,6 +176,7 @@ class Email
|
|||
}
|
||||
|
||||
$sEmail = \trim(\trim($sEmail), '<>');
|
||||
|
||||
$sName = \trim(\trim($sName), '"');
|
||||
$sName = \trim($sName, '\'');
|
||||
$sComment = \trim(\trim($sComment), '()');
|
||||
|
|
@ -188,11 +189,13 @@ class Email
|
|||
}
|
||||
|
||||
/**
|
||||
* @param bool $bIdn = false
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function GetEmail()
|
||||
public function GetEmail($bIdn = false)
|
||||
{
|
||||
return $this->sEmail;
|
||||
return $bIdn ? \MailSo\Base\Utils::IdnToUtf8($this->sEmail) : $this->sEmail;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -216,31 +219,36 @@ class Email
|
|||
*/
|
||||
public function GetAccountName()
|
||||
{
|
||||
return \MailSo\Base\Utils::GetAccountNameFromEmail($this->sEmail);
|
||||
return \MailSo\Base\Utils::GetAccountNameFromEmail($this->GetEmail(false));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $bIdn = false
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function GetDomain()
|
||||
public function GetDomain($bIdn = false)
|
||||
{
|
||||
return \MailSo\Base\Utils::GetDomainFromEmail($this->sEmail);
|
||||
return \MailSo\Base\Utils::GetDomainFromEmail($this->GetEmail($bIdn));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $bIdn = false
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function ToArray()
|
||||
public function ToArray($bIdn = false)
|
||||
{
|
||||
return array($this->sDisplayName, $this->sEmail, $this->sRemark);
|
||||
return array($this->sDisplayName, $this->GetEmail($bIdn), $this->sRemark);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $bConvertSpecialsName = false
|
||||
* @param bool $bIdn = false
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function ToString($bConvertSpecialsName = false)
|
||||
public function ToString($bConvertSpecialsName = false, $bIdn = false)
|
||||
{
|
||||
$sReturn = '';
|
||||
|
||||
|
|
@ -263,8 +271,7 @@ class Email
|
|||
|
||||
if (0 < \strlen($this->sEmail))
|
||||
{
|
||||
$sReturn = $this->sEmail;
|
||||
|
||||
$sReturn = $this->GetEmail($bIdn);
|
||||
if (0 < \strlen($sDisplayName.$sRemark))
|
||||
{
|
||||
$sReturn = $sDisplayName.' <'.$sReturn.'> '.$sRemark;
|
||||
|
|
|
|||
|
|
@ -100,16 +100,17 @@ class EmailCollection extends \MailSo\Base\Collection
|
|||
|
||||
/**
|
||||
* @param bool $bConvertSpecialsName = false
|
||||
* @param bool $bIdn = false
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function ToString($bConvertSpecialsName = false)
|
||||
public function ToString($bConvertSpecialsName = false, $bIdn = false)
|
||||
{
|
||||
$aReturn = $aEmails = array();
|
||||
$aEmails =& $this->GetAsArray();
|
||||
foreach ($aEmails as /* @var $oEmail \MailSo\Mime\Email */ $oEmail)
|
||||
{
|
||||
$aReturn[] = $oEmail->ToString($bConvertSpecialsName);
|
||||
$aReturn[] = $oEmail->ToString($bConvertSpecialsName, $bIdn);
|
||||
}
|
||||
|
||||
return \implode(', ', $aReturn);
|
||||
|
|
|
|||
|
|
@ -228,7 +228,7 @@ class Header
|
|||
$oEmailCollection = \MailSo\Mime\EmailCollection::NewInstance($this->sFullValue);
|
||||
if ($oEmailCollection && 0 < $oEmailCollection->Count())
|
||||
{
|
||||
$sResult = $oEmailCollection->ToString(true);
|
||||
$sResult = $oEmailCollection->ToString(true, false);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -191,7 +191,7 @@ class Message
|
|||
}
|
||||
|
||||
/**
|
||||
* @param string $sHeader
|
||||
* @param string $sHeaderName
|
||||
* @param string $sValue
|
||||
*
|
||||
* @return \MailSo\Mime\Message
|
||||
|
|
|
|||
|
|
@ -173,6 +173,8 @@ class SmtpClient extends \MailSo\Net\NetClient
|
|||
*/
|
||||
public function Login($sLogin, $sPassword)
|
||||
{
|
||||
$sLogin = \MailSo\Base\Utils::IdnToAscii($sLogin);
|
||||
|
||||
if ($this->IsAuthSupported('LOGIN'))
|
||||
{
|
||||
try
|
||||
|
|
@ -299,6 +301,7 @@ class SmtpClient extends \MailSo\Net\NetClient
|
|||
*/
|
||||
public function MailFrom($sFrom, $sSizeIfSupported = '')
|
||||
{
|
||||
$sFrom = \MailSo\Base\Utils::IdnToAscii($sFrom, true);
|
||||
$sCmd = 'FROM:<'.$sFrom.'>';
|
||||
|
||||
$sSizeIfSupported = (string) $sSizeIfSupported;
|
||||
|
|
@ -333,6 +336,7 @@ class SmtpClient extends \MailSo\Net\NetClient
|
|||
\MailSo\Log\Enumerations\Type::ERROR, true);
|
||||
}
|
||||
|
||||
$sTo = \MailSo\Base\Utils::IdnToAscii($sTo, true);
|
||||
$this->sendRequestWithCheck('RCPT', array(250, 251), 'TO:<'.$sTo.'>');
|
||||
|
||||
$this->bRcpt = true;
|
||||
|
|
|
|||
3405
rainloop/v/0.0.0/app/libraries/MailSo/Vendors/Net/IDNA2.php
Normal file
3405
rainloop/v/0.0.0/app/libraries/MailSo/Vendors/Net/IDNA2.php
Normal file
File diff suppressed because it is too large
Load diff
|
|
@ -0,0 +1,5 @@
|
|||
<?php
|
||||
|
||||
class Net_IDNA2_Exception extends Exception
|
||||
{
|
||||
}
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
<?php
|
||||
|
||||
//require_once 'Net/IDNA2/Exception.php';
|
||||
|
||||
defined('MAILSO_LIBRARY_ROOT_PATH') || die();
|
||||
require_once MAILSO_LIBRARY_ROOT_PATH.'Vendors/Net/IDNA2/Exception.php';
|
||||
|
||||
class Net_IDNA2_Exception_Nameprep extends Net_IDNA2_Exception
|
||||
{
|
||||
}
|
||||
|
|
@ -46,12 +46,12 @@ class Account
|
|||
*/
|
||||
protected function __construct($sEmail, $sLogin, $sPassword, \RainLoop\Domain $oDomain, $sSignMeToken = '', $sParentEmail = '')
|
||||
{
|
||||
$this->sEmail = \strtolower($sEmail);
|
||||
$this->sLogin = $sLogin;
|
||||
$this->sEmail = \MailSo\Base\Utils::IdnToAscii($sEmail, true);
|
||||
$this->sLogin = \MailSo\Base\Utils::IdnToAscii($sLogin);
|
||||
$this->sPassword = $sPassword;
|
||||
$this->oDomain = $oDomain;
|
||||
$this->sSignMeToken = $sSignMeToken;
|
||||
$this->sParentEmail = \strtolower($sParentEmail);
|
||||
$this->sParentEmail = \MailSo\Base\Utils::IdnToAscii($sParentEmail, true);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -166,7 +166,6 @@ class Account
|
|||
*/
|
||||
public function Hash()
|
||||
{
|
||||
|
||||
return md5(APP_SALT.$this->Email().APP_SALT.$this->oDomain->IncHost(\MailSo\Base\Utils::GetDomainFromEmail($this->Email())).
|
||||
APP_SALT.$this->oDomain->IncPort().APP_SALT.$this->Password().APP_SALT.'0'.APP_SALT.$this->ParentEmail().APP_SALT);
|
||||
}
|
||||
|
|
@ -188,7 +187,7 @@ class Account
|
|||
*/
|
||||
public function SetParentEmail($sParentEmail)
|
||||
{
|
||||
$this->sParentEmail = \strtolower($sParentEmail);
|
||||
$this->sParentEmail = \MailSo\Base\Utils::IdnToAscii($sParentEmail, true);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -330,7 +330,7 @@ class Actions
|
|||
$oAccount = $this->getAccountFromToken(false);
|
||||
if ($oAccount)
|
||||
{
|
||||
$sEmail = \strtolower($oAccount->Email());
|
||||
$sEmail = $oAccount->Email();
|
||||
$sFileName = \str_replace('{user:email}', $sEmail, $sFileName);
|
||||
$sFileName = \str_replace('{user:login}', \MailSo\Base\Utils::GetAccountNameFromEmail($sEmail), $sFileName);
|
||||
$sFileName = \str_replace('{user:domain}', \MailSo\Base\Utils::GetDomainFromEmail($sEmail), $sFileName);
|
||||
|
|
@ -972,6 +972,9 @@ class Actions
|
|||
'AuthAccountHash' => '',
|
||||
'MailToEmail' => '',
|
||||
'Email' => '',
|
||||
'DevEmail' => '',
|
||||
'DevLogin' => '',
|
||||
'DevPassword' => '',
|
||||
'Title' => $oConfig->Get('webmail', 'title', ''),
|
||||
'LoadingDescription' => $oConfig->Get('webmail', 'loading_description', ''),
|
||||
'LoginLogo' => $oConfig->Get('branding', 'login_logo', ''),
|
||||
|
|
@ -1267,6 +1270,12 @@ class Actions
|
|||
$aResult['PluginsLink'] = $sPluginsLink;
|
||||
$aResult['EditorDefaultType'] = 'Html' === $aResult['EditorDefaultType'] ? 'Html' : 'Plain';
|
||||
|
||||
$aResult['Email'] = \MailSo\Base\Utils::IdnToUtf8($aResult['Email']);
|
||||
$aResult['ParentEmail'] = \MailSo\Base\Utils::IdnToUtf8($aResult['ParentEmail']);
|
||||
$aResult['MailToEmail'] = \MailSo\Base\Utils::IdnToUtf8($aResult['MailToEmail']);
|
||||
$aResult['DevEmail'] = \MailSo\Base\Utils::IdnToUtf8($aResult['DevEmail']);
|
||||
$aResult['DevLogin'] = \MailSo\Base\Utils::IdnToUtf8($aResult['DevLogin']);
|
||||
|
||||
$this->Plugins()->InitAppData($bAdmin, $aResult);
|
||||
|
||||
return $aResult;
|
||||
|
|
@ -1619,7 +1628,7 @@ class Actions
|
|||
$aResult = array();
|
||||
foreach ($aIdentities as $oItem)
|
||||
{
|
||||
$aResult[] = $oItem->ToSimpleJSON();
|
||||
$aResult[] = $oItem->ToSimpleJSON(false);
|
||||
}
|
||||
|
||||
$oSettings->SetConf('Identities', @\json_encode($aResult));
|
||||
|
|
@ -1651,7 +1660,7 @@ class Actions
|
|||
|
||||
$sParentEmail = 0 < \strlen($oAccount->ParentEmail()) ? $oAccount->ParentEmail() : $oAccount->Email();
|
||||
|
||||
$sEmail = \strtolower($sEmail);
|
||||
$sEmail = \MailSo\Base\Utils::IdnToAscii($sEmail, true);
|
||||
if ($oAccount->Email() === $sEmail || $sParentEmail === $sEmail)
|
||||
{
|
||||
throw new \RainLoop\Exceptions\ClientException(\RainLoop\Notifications::AccountAlreadyExists);
|
||||
|
|
@ -1701,7 +1710,8 @@ class Actions
|
|||
$oAccount = $this->getAccountFromToken();
|
||||
|
||||
$sParentEmail = $oAccount->ParentEmailHelper();
|
||||
$sEmailToDelete = \strtolower(\trim($this->GetActionParam('EmailToDelete', '')));
|
||||
$sEmailToDelete = \trim($this->GetActionParam('EmailToDelete', ''));
|
||||
$sEmailToDelete = \MailSo\Base\Utils::IdnToAscii($sEmailToDelete, true);
|
||||
|
||||
$aAccounts = $this->GetAccounts($oAccount);
|
||||
|
||||
|
|
@ -1833,6 +1843,11 @@ class Actions
|
|||
{
|
||||
$mAccounts = $this->GetAccounts($oAccount);
|
||||
$mAccounts = \array_keys($mAccounts);
|
||||
|
||||
foreach ($mAccounts as $iIndex => $sName)
|
||||
{
|
||||
$mAccounts[$iIndex] = \MailSo\Base\Utils::IdnToUtf8($sName);
|
||||
}
|
||||
}
|
||||
|
||||
$mIdentities = false;
|
||||
|
|
@ -2366,7 +2381,7 @@ class Actions
|
|||
$this->IsAdminLoggined();
|
||||
|
||||
return $this->DefaultResponse(__FUNCTION__,
|
||||
$this->DomainProvider()->Load($this->GetActionParam('Name', '')));
|
||||
$this->DomainProvider()->Load($this->GetActionParam('Name', ''), false, false));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -4213,7 +4228,7 @@ class Actions
|
|||
{
|
||||
$sMessageId = $oMessage->MessageId();
|
||||
|
||||
rewind($rMessageStream);
|
||||
\rewind($rMessageStream);
|
||||
|
||||
$iNewUid = 0;
|
||||
$this->MailClient()->MessageAppendStream(
|
||||
|
|
@ -4407,7 +4422,7 @@ class Actions
|
|||
|
||||
try
|
||||
{
|
||||
switch (strtolower($sDraftInfoType))
|
||||
switch (\strtolower($sDraftInfoType))
|
||||
{
|
||||
case 'reply':
|
||||
case 'reply-all':
|
||||
|
|
@ -4430,7 +4445,7 @@ class Actions
|
|||
}
|
||||
}
|
||||
|
||||
if (0 < strlen($sSentFolder))
|
||||
if (0 < \strlen($sSentFolder))
|
||||
{
|
||||
try
|
||||
{
|
||||
|
|
@ -4514,7 +4529,7 @@ class Actions
|
|||
$aTo =& $oToCollection->GetAsArray();
|
||||
foreach ($aTo as /* @var $oEmail \MailSo\Mime\Email */ $oEmail)
|
||||
{
|
||||
$aArrayToFrec[$oEmail->GetEmail()] = $oEmail->ToString();
|
||||
$aArrayToFrec[$oEmail->GetEmail(true)] = $oEmail->ToString(false, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -6784,7 +6799,7 @@ class Actions
|
|||
|
||||
if ($bHasSimpleJsonFunc)
|
||||
{
|
||||
$mResult = \array_merge($this->objectData($mResponse, $sParent, $aParameters), $mResponse->ToSimpleJSON());
|
||||
$mResult = \array_merge($this->objectData($mResponse, $sParent, $aParameters), $mResponse->ToSimpleJSON(true));
|
||||
}
|
||||
else if ('MailSo\Mail\Message' === $sClassName)
|
||||
{
|
||||
|
|
@ -6934,7 +6949,7 @@ class Actions
|
|||
try
|
||||
{
|
||||
$oReadReceipt = \MailSo\Mime\Email::Parse($mResult['ReadReceipt']);
|
||||
if (!$oReadReceipt || ($oReadReceipt && \strtolower($oAccount->Email()) === \strtolower($oReadReceipt->GetEmail())))
|
||||
if (!$oReadReceipt || ($oReadReceipt && $oAccount->Email() === $oReadReceipt->GetEmail()))
|
||||
{
|
||||
$mResult['ReadReceipt'] = '';
|
||||
}
|
||||
|
|
@ -6954,7 +6969,7 @@ class Actions
|
|||
{
|
||||
$mResult = \array_merge($this->objectData($mResponse, $sParent, $aParameters), array(
|
||||
'Name' => \MailSo\Base\Utils::Utf8Clear($mResponse->GetDisplayName()),
|
||||
'Email' => \MailSo\Base\Utils::Utf8Clear($mResponse->GetEmail())
|
||||
'Email' => \MailSo\Base\Utils::Utf8Clear($mResponse->GetEmail(true))
|
||||
));
|
||||
}
|
||||
else if ('RainLoop\Providers\AddressBook\Classes\Contact' === $sClassName)
|
||||
|
|
|
|||
|
|
@ -249,7 +249,7 @@ abstract class PdoAbstract
|
|||
return $aCache[$sEmail];
|
||||
}
|
||||
|
||||
$sEmail = \strtolower(\trim($sEmail));
|
||||
$sEmail = \MailSo\Base\Utils::IdnToAscii(\trim($sEmail), true);
|
||||
if (empty($sEmail))
|
||||
{
|
||||
throw new \InvalidArgumentException('Empty Email argument');
|
||||
|
|
|
|||
|
|
@ -263,11 +263,11 @@ class Domain
|
|||
$sOutHost, $iOutPort, $iOutSecure, $bOutShortLogin, $bOutAuth,
|
||||
$sWhiteList = '')
|
||||
{
|
||||
$this->sIncHost = $sIncHost;
|
||||
$this->sIncHost = \MailSo\Base\Utils::IdnToAscii($sIncHost);
|
||||
$this->iIncPort = $iIncPort;
|
||||
$this->iIncSecure = $iIncSecure;
|
||||
$this->bIncShortLogin = $bIncShortLogin;
|
||||
$this->sOutHost = $sOutHost;
|
||||
$this->sOutHost = \MailSo\Base\Utils::IdnToAscii($sOutHost);
|
||||
$this->iOutPort = $iOutPort;
|
||||
$this->iOutSecure = $iOutSecure;
|
||||
$this->bOutShortLogin = $bOutShortLogin;
|
||||
|
|
@ -379,10 +379,13 @@ class Domain
|
|||
$sW = \trim($this->sWhiteList);
|
||||
if (0 < strlen($sW))
|
||||
{
|
||||
$sW = \preg_replace('/([^\s]+)@[^\s]*/', '$1', $sW);
|
||||
$sW = ' '.\strtolower(\trim(\preg_replace('/[\s;,\r\n\t]+/', ' ', $sW))).' ';
|
||||
$sEmail = \MailSo\Base\Utils::IdnToUtf8($sEmail, true);
|
||||
$sLogin = \MailSo\Base\Utils::IdnToUtf8($sLogin);
|
||||
|
||||
$sUserPart = \strtolower(\MailSo\Base\Utils::GetAccountNameFromEmail(0 < \strlen($sLogin) ? $sLogin : $sEmail));
|
||||
$sW = \preg_replace('/([^\s]+)@[^\s]*/', '$1', $sW);
|
||||
$sW = ' '.\trim(\preg_replace('/[\s;,\r\n\t]+/', ' ', $sW)).' ';
|
||||
|
||||
$sUserPart = \MailSo\Base\Utils::GetAccountNameFromEmail(0 < \strlen($sLogin) ? $sLogin : $sEmail);
|
||||
return false !== \strpos($sW, ' '.$sUserPart.' ');
|
||||
}
|
||||
|
||||
|
|
@ -390,17 +393,19 @@ class Domain
|
|||
}
|
||||
|
||||
/**
|
||||
* @param bool $bAjax = false
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function ToSimpleJSON()
|
||||
public function ToSimpleJSON($bAjax = false)
|
||||
{
|
||||
return array(
|
||||
'Name' => $this->Name(),
|
||||
'IncHost' => $this->IncHost(),
|
||||
'Name' => $bAjax ? \MailSo\Base\Utils::IdnToUtf8($this->Name()) : $this->Name(),
|
||||
'IncHost' => $bAjax ? \MailSo\Base\Utils::IdnToUtf8($this->IncHost()) : $this->IncHost(),
|
||||
'IncPort' => $this->IncPort(),
|
||||
'IncSecure' => $this->IncSecure(),
|
||||
'IncShortLogin' => $this->IncShortLogin(),
|
||||
'OutHost' => $this->OutHost(),
|
||||
'OutHost' => $bAjax ? \MailSo\Base\Utils::IdnToUtf8($this->OutHost()) : $this->OutHost(),
|
||||
'OutPort' => $this->OutPort(),
|
||||
'OutSecure' => $this->OutSecure(),
|
||||
'OutShortLogin' => $this->OutShortLogin(),
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ class Identity
|
|||
protected function __construct($sId, $sEmail, $sName, $sReplyTo, $sBcc)
|
||||
{
|
||||
$this->sId = $sId;
|
||||
$this->sEmail = \strtolower($sEmail);
|
||||
$this->sEmail = \MailSo\Base\Utils::IdnToAscii($sEmail, true);
|
||||
$this->sName = \trim($sName);
|
||||
$this->sReplyTo = \trim($sReplyTo);
|
||||
$this->sBcc = \trim($sBcc);
|
||||
|
|
@ -96,7 +96,7 @@ class Identity
|
|||
*/
|
||||
public function SetEmail($sEmail)
|
||||
{
|
||||
$this->sEmail = $sEmail;
|
||||
$this->sEmail = \MailSo\Base\Utils::IdnToAscii($sEmail, true);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
|
@ -162,13 +162,15 @@ class Identity
|
|||
}
|
||||
|
||||
/**
|
||||
* @param bool $bAjax = false
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function ToSimpleJSON()
|
||||
public function ToSimpleJSON($bAjax = false)
|
||||
{
|
||||
return array(
|
||||
'Id' => $this->Id(),
|
||||
'Email' => $this->Email(),
|
||||
'Email' => $bAjax ? \MailSo\Base\Utils::IdnToUtf8($this->Email()) : $this->Email(),
|
||||
'Name' => $this->Name(),
|
||||
'ReplyTo' => $this->ReplyTo(),
|
||||
'Bcc' => $this->Bcc()
|
||||
|
|
|
|||
|
|
@ -190,10 +190,10 @@ class Manager
|
|||
*/
|
||||
private function convertPluginFolderNameToClassName($sFolderName)
|
||||
{
|
||||
$aParts = array_map('ucfirst', array_map('strtolower',
|
||||
explode(' ', preg_replace('/[^a-z0-9]+/', ' ', $sFolderName))));
|
||||
$aParts = \array_map('ucfirst', \array_map('strtolower',
|
||||
\explode(' ', \preg_replace('/[^a-z0-9]+/', ' ', $sFolderName))));
|
||||
|
||||
return implode($aParts).'Plugin';
|
||||
return \implode($aParts).'Plugin';
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -425,9 +425,9 @@ class Manager
|
|||
*/
|
||||
public function AddAdditionalPartAction($sActionName, $mCallbak)
|
||||
{
|
||||
if ($this->bIsEnabled && is_callable($mCallbak))
|
||||
if ($this->bIsEnabled && \is_callable($mCallbak))
|
||||
{
|
||||
$sActionName = strtolower($sActionName);
|
||||
$sActionName = \strtolower($sActionName);
|
||||
if (!isset($this->aAdditionalParts[$sActionName]))
|
||||
{
|
||||
$this->aAdditionalParts[$sActionName] = array();
|
||||
|
|
@ -450,12 +450,12 @@ class Manager
|
|||
$bResult = false;
|
||||
if ($this->bIsEnabled)
|
||||
{
|
||||
$sActionName = strtolower($sActionName);
|
||||
$sActionName = \strtolower($sActionName);
|
||||
if (isset($this->aAdditionalParts[$sActionName]))
|
||||
{
|
||||
foreach ($this->aAdditionalParts[$sActionName] as $mCallbak)
|
||||
{
|
||||
$bCallResult = call_user_func_array($mCallbak, $aParts);
|
||||
$bCallResult = \call_user_func_array($mCallbak, $aParts);
|
||||
if ($bCallResult && !$bResult)
|
||||
{
|
||||
$bResult = true;
|
||||
|
|
|
|||
|
|
@ -117,7 +117,7 @@ class Property
|
|||
// lower
|
||||
if ($this->IsEmail())
|
||||
{
|
||||
$this->Value = \strtolower($this->Value);
|
||||
$this->Value = \MailSo\Base\Utils::StrToLowerIfAscii($this->Value);
|
||||
}
|
||||
|
||||
// phones clear value for searching
|
||||
|
|
|
|||
|
|
@ -620,7 +620,7 @@ class PdoAddressBook
|
|||
)
|
||||
);
|
||||
|
||||
$sLast = $this->lastInsertId('rainloop_ab_contacts', 'id_contact');
|
||||
$sLast = $this->lastInsertId('rainloop_ab_tags', 'id_tag');
|
||||
if (\is_numeric($sLast) && 0 < (int) $sLast)
|
||||
{
|
||||
$mResult = (int) $sLast;
|
||||
|
|
@ -1382,7 +1382,7 @@ class PdoAddressBook
|
|||
{
|
||||
if ($aItem && !empty($aItem['prop_value']))
|
||||
{
|
||||
$aExists[] = \strtolower(\trim($aItem['prop_value']));
|
||||
$aExists[] = \MailSo\Base\Utils::StrToLowerIfAscii(\trim($aItem['prop_value']));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1391,7 +1391,7 @@ class PdoAddressBook
|
|||
$aEmailsToCreate = \array_filter($aEmailsObjects, function ($oItem) use ($aExists, &$aEmailsToUpdate) {
|
||||
if ($oItem)
|
||||
{
|
||||
$sEmail = \strtolower(\trim($oItem->GetEmail()));
|
||||
$sEmail = \trim($oItem->GetEmail(true));
|
||||
if (0 < \strlen($sEmail))
|
||||
{
|
||||
$aEmailsToUpdate[] = $sEmail;
|
||||
|
|
@ -1408,7 +1408,7 @@ class PdoAddressBook
|
|||
{
|
||||
if ($oItem)
|
||||
{
|
||||
$sEmailUpdate = \strtolower(\trim($oItem->GetEmail()));
|
||||
$sEmailUpdate = \trim($oItem->GetEmail(true));
|
||||
if (0 < \strlen($sEmailUpdate))
|
||||
{
|
||||
$aEmailsToUpdate[] = $sEmailUpdate;
|
||||
|
|
@ -1428,7 +1428,7 @@ class PdoAddressBook
|
|||
{
|
||||
$oPropEmail = new \RainLoop\Providers\AddressBook\Classes\Property();
|
||||
$oPropEmail->Type = \RainLoop\Providers\AddressBook\Enumerations\PropertyType::EMAIl;
|
||||
$oPropEmail->Value = \strtolower(\trim($oEmail->GetEmail()));
|
||||
$oPropEmail->Value = \trim($oEmail->GetEmail(true));
|
||||
|
||||
$oContact->Properties[] = $oPropEmail;
|
||||
}
|
||||
|
|
@ -1439,7 +1439,7 @@ class PdoAddressBook
|
|||
$sFullName = $oEmail->GetDisplayName();
|
||||
if (false !== \strpos($sFullName, ' '))
|
||||
{
|
||||
$aNames = explode(' ', $sFullName, 2);
|
||||
$aNames = \explode(' ', $sFullName, 2);
|
||||
$sFirst = isset($aNames[0]) ? $aNames[0] : '';
|
||||
$sLast = isset($aNames[1]) ? $aNames[1] : '';
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,12 +36,13 @@ class Domain extends \RainLoop\Providers\AbstractProvider
|
|||
/**
|
||||
* @param string $sName
|
||||
* @param bool $bFindWithWildCard = false
|
||||
* @param bool $bCheckDisabled = true
|
||||
*
|
||||
* @return \RainLoop\Domain|null
|
||||
*/
|
||||
public function Load($sName, $bFindWithWildCard = false)
|
||||
public function Load($sName, $bFindWithWildCard = false, $bCheckDisabled = true)
|
||||
{
|
||||
return $this->oDriver->Load($sName, $bFindWithWildCard);
|
||||
return $this->oDriver->Load($sName, $bFindWithWildCard, $bCheckDisabled);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -43,7 +43,15 @@ class DefaultDomain implements \RainLoop\Providers\Domain\DomainAdminInterface
|
|||
return 'default';
|
||||
}
|
||||
|
||||
$sName = \strtolower($sName);
|
||||
if ($bBack)
|
||||
{
|
||||
$sName = \MailSo\Base\Utils::IdnToUtf8($sName, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
$sName = \MailSo\Base\Utils::IdnToAscii($sName, true);
|
||||
}
|
||||
|
||||
return $bBack ? \str_replace('_wildcard_', '*', $sName) : \str_replace('*', '_wildcard_', $sName);
|
||||
}
|
||||
|
||||
|
|
@ -55,6 +63,8 @@ class DefaultDomain implements \RainLoop\Providers\Domain\DomainAdminInterface
|
|||
*/
|
||||
public function Disable($sName, $bDisable)
|
||||
{
|
||||
$sName = \MailSo\Base\Utils::IdnToAscii($sName, true);
|
||||
|
||||
$sFile = '';
|
||||
if (\file_exists($this->sDomainPath.'/disabled'))
|
||||
{
|
||||
|
|
@ -111,8 +121,8 @@ class DefaultDomain implements \RainLoop\Providers\Domain\DomainAdminInterface
|
|||
$aList = \glob($this->sDomainPath.'/*.ini');
|
||||
foreach ($aList as $sFile)
|
||||
{
|
||||
$sName = \strtolower(\substr(\basename($sFile), 0, -4));
|
||||
if ('default' === $sName || false !== strpos($sName, '_wildcard_'))
|
||||
$sName = \substr(\basename($sFile), 0, -4);
|
||||
if ('default' === $sName || false !== \strpos($sName, '_wildcard_'))
|
||||
{
|
||||
$aNames[] = $this->codeFileName($sName, true);
|
||||
}
|
||||
|
|
@ -135,16 +145,16 @@ class DefaultDomain implements \RainLoop\Providers\Domain\DomainAdminInterface
|
|||
/**
|
||||
* @param string $sName
|
||||
* @param bool $bFindWithWildCard = false
|
||||
* @param bool $bCheckDisabled = true
|
||||
*
|
||||
* @return \RainLoop\Domain|null
|
||||
*/
|
||||
public function Load($sName, $bFindWithWildCard = false)
|
||||
public function Load($sName, $bFindWithWildCard = false, $bCheckDisabled = true)
|
||||
{
|
||||
$mResult = null;
|
||||
|
||||
$sDisabled = '';
|
||||
$sFoundedValue = '';
|
||||
$sName = \strtolower($sName);
|
||||
|
||||
$sRealFileName = $this->codeFileName($sName);
|
||||
|
||||
|
|
@ -154,7 +164,7 @@ class DefaultDomain implements \RainLoop\Providers\Domain\DomainAdminInterface
|
|||
}
|
||||
|
||||
if (\file_exists($this->sDomainPath.'/'.$sRealFileName.'.ini') &&
|
||||
(0 === \strlen($sDisabled) || false === \strpos(\strtolower(','.$sDisabled.','), \strtolower(','.$sName.','))))
|
||||
(!$bCheckDisabled || 0 === \strlen($sDisabled) || false === \strpos(','.$sDisabled.',', ','.\MailSo\Base\Utils::IdnToAscii($sName, true).',')))
|
||||
{
|
||||
$aDomain = @\parse_ini_file($this->sDomainPath.'/'.$sRealFileName.'.ini');
|
||||
// fix misspellings (#119)
|
||||
|
|
@ -189,9 +199,10 @@ class DefaultDomain implements \RainLoop\Providers\Domain\DomainAdminInterface
|
|||
$sNames = $this->getWildcardDomainsLine();
|
||||
if (0 < \strlen($sNames))
|
||||
{
|
||||
if (\RainLoop\Plugins\Helper::ValidateWildcardValues($sName, $sNames, $sFoundedValue) && 0 < \strlen($sFoundedValue))
|
||||
if (\RainLoop\Plugins\Helper::ValidateWildcardValues(
|
||||
\MailSo\Base\Utils::IdnToUtf8($sName, true), $sNames, $sFoundedValue) && 0 < \strlen($sFoundedValue))
|
||||
{
|
||||
if (0 === \strlen($sDisabled) || false === \strpos(\strtolower(','.$sDisabled.','), \strtolower(','.$sFoundedValue.',')))
|
||||
if (!$bCheckDisabled || 0 === \strlen($sDisabled) || false === \strpos(','.$sDisabled.',', ','.$sFoundedValue.','))
|
||||
{
|
||||
$mResult = $this->Load($sFoundedValue, false);
|
||||
}
|
||||
|
|
@ -209,8 +220,7 @@ class DefaultDomain implements \RainLoop\Providers\Domain\DomainAdminInterface
|
|||
*/
|
||||
public function Save(\RainLoop\Domain $oDomain)
|
||||
{
|
||||
$sName = \strtolower($oDomain->Name());
|
||||
$sRealFileName = $this->codeFileName($sName);
|
||||
$sRealFileName = $this->codeFileName($oDomain->Name());
|
||||
|
||||
if ($this->oCacher)
|
||||
{
|
||||
|
|
@ -229,7 +239,6 @@ class DefaultDomain implements \RainLoop\Providers\Domain\DomainAdminInterface
|
|||
public function Delete($sName)
|
||||
{
|
||||
$bResult = true;
|
||||
$sName = \strtolower($sName);
|
||||
$sRealFileName = $this->codeFileName($sName);
|
||||
|
||||
if (0 < \strlen($sName) && \file_exists($this->sDomainPath.'/'.$sRealFileName.'.ini'))
|
||||
|
|
@ -264,8 +273,9 @@ class DefaultDomain implements \RainLoop\Providers\Domain\DomainAdminInterface
|
|||
|
||||
foreach ($aList as $sFile)
|
||||
{
|
||||
$sName = \strtolower(\substr(\basename($sFile), 0, -4));
|
||||
$sName = \substr(\basename($sFile), 0, -4);
|
||||
$sName = $this->codeFileName($sName, true);
|
||||
|
||||
if (false === \strpos($sName, '*'))
|
||||
{
|
||||
$aResult[] = $sName;
|
||||
|
|
@ -292,15 +302,19 @@ class DefaultDomain implements \RainLoop\Providers\Domain\DomainAdminInterface
|
|||
$sDisabled = @\file_get_contents($this->sDomainPath.'/disabled');
|
||||
if (false !== $sDisabled && 0 < strlen($sDisabled))
|
||||
{
|
||||
$aDisabledNames = \explode(',', strtolower($sDisabled));
|
||||
$aDisabledNames = \explode(',', $sDisabled);
|
||||
$aDisabledNames = \array_unique($aDisabledNames);
|
||||
foreach ($aDisabledNames as $iIndex => $sValue)
|
||||
{
|
||||
$aDisabledNames[$iIndex] = \MailSo\Base\Utils::IdnToUtf8($sValue, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$aReturn = array();
|
||||
foreach ($aResult as $sName)
|
||||
{
|
||||
$aReturn[$sName] = !\in_array(\strtolower($sName), $aDisabledNames);
|
||||
$aReturn[$sName] = !\in_array($sName, $aDisabledNames);
|
||||
}
|
||||
|
||||
return $aReturn;
|
||||
|
|
|
|||
|
|
@ -16,10 +16,11 @@ interface DomainAdminInterface extends DomainInterface
|
|||
/**
|
||||
* @param string $sName
|
||||
* @param bool $bFindWithWildCard = false
|
||||
* @param bool $bCheckDisabled = true
|
||||
*
|
||||
* @return \RainLoop\Domain|null
|
||||
*/
|
||||
public function Load($sName, $bFindWithWildCard = false);
|
||||
public function Load($sName, $bFindWithWildCard = false, $bCheckDisabled = true);
|
||||
|
||||
/**
|
||||
* @param \RainLoop\Domain $oDomain
|
||||
|
|
|
|||
|
|
@ -126,7 +126,8 @@ class Service
|
|||
{
|
||||
$bAdmin = !empty($aPaths[0]) && \in_array(\strtolower($aPaths[0]), array('admin', 'cp'));
|
||||
}
|
||||
else if (empty($aPaths[0]) && \strtolower($sAdminPanelHost) === \strtolower($this->oHttp->GetHost()))
|
||||
else if (empty($aPaths[0]) &&
|
||||
\MailSo\Base\Utils::StrToLowerIfAscii($sAdminPanelHost) === \MailSo\Base\Utils::StrToLowerIfAscii($this->oHttp->GetHost()))
|
||||
{
|
||||
$bAdmin = true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -751,7 +751,7 @@ class ServiceActions
|
|||
|
||||
if (\is_array($mData) && !empty($mData['Email']) && isset($mData['Password']))
|
||||
{
|
||||
$sEmail = \strtolower(\trim($mData['Email']));
|
||||
$sEmail = \trim($mData['Email']);
|
||||
$sPassword = $mData['Password'];
|
||||
$sLogin = isset($mData['Login']) ? $mData['Login'] : '';
|
||||
|
||||
|
|
@ -875,9 +875,11 @@ class ServiceActions
|
|||
if ($this->Config()->Get('webmail', 'allow_additional_accounts', true))
|
||||
{
|
||||
$oAccountToLogin = null;
|
||||
$sEmail = empty($this->aPaths[2]) ? '' : \strtolower(\urldecode(\trim($this->aPaths[2])));
|
||||
$sEmail = empty($this->aPaths[2]) ? '' : \urldecode(\trim($this->aPaths[2]));
|
||||
if (!empty($sEmail))
|
||||
{
|
||||
$sEmail = \MailSo\Base\Utils::IdnToAscii($sEmail);
|
||||
|
||||
$oAccount = $this->oActions->GetAccount();
|
||||
if ($oAccount)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ class Social
|
|||
$mResult = null;
|
||||
if (!empty($oItem['gd$email'][0]['address']))
|
||||
{
|
||||
$mEmail = \strtolower($oItem['gd$email'][0]['address']);
|
||||
$mEmail = \MailSo\Base\Utils::IdnToAscii($oItem['gd$email'][0]['address'], true);
|
||||
if (\is_array($oItem['gd$email']) && 1 < \count($oItem['gd$email']))
|
||||
{
|
||||
$mEmail = array();
|
||||
|
|
@ -44,13 +44,13 @@ class Social
|
|||
{
|
||||
if (!empty($oEmail['address']))
|
||||
{
|
||||
$mEmail[] = \strtolower($oEmail['address']);
|
||||
$mEmail[] = \MailSo\Base\Utils::IdnToAscii($oEmail['address'], true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$sImg = '';
|
||||
if (!empty($oItem['link']) && is_array($oItem['link']))
|
||||
if (!empty($oItem['link']) && \is_array($oItem['link']))
|
||||
{
|
||||
foreach ($oItem['link'] as $oLink)
|
||||
{
|
||||
|
|
@ -79,29 +79,29 @@ class Social
|
|||
if (isset($aPics[$sHash]))
|
||||
{
|
||||
$mData = $aPics[$sHash];
|
||||
if (!is_array($mData))
|
||||
if (!\is_array($mData))
|
||||
{
|
||||
$mData = array($mData);
|
||||
}
|
||||
}
|
||||
|
||||
if (is_array($mEmail))
|
||||
if (\is_array($mEmail))
|
||||
{
|
||||
$mData = array_merge($mData, $mEmail);
|
||||
$mData = array_unique($mData);
|
||||
$mData = \array_merge($mData, $mEmail);
|
||||
$mData = \array_unique($mData);
|
||||
}
|
||||
else if (0 < strlen($mEmail))
|
||||
else if (0 < \strlen($mEmail))
|
||||
{
|
||||
$mData[] = $mEmail;
|
||||
}
|
||||
|
||||
if (is_array($mData))
|
||||
if (\is_array($mData))
|
||||
{
|
||||
if (1 === count($mData) && !empty($mData[0]))
|
||||
if (1 === \count($mData) && !empty($mData[0]))
|
||||
{
|
||||
$aPics[$sHash] = $mData[0];
|
||||
}
|
||||
else if (1 < count($mData))
|
||||
else if (1 < \count($mData))
|
||||
{
|
||||
$aPics[$sHash] = $mData;
|
||||
}
|
||||
|
|
@ -132,7 +132,7 @@ class Social
|
|||
'alt' => 'json'
|
||||
));
|
||||
|
||||
if (!empty($aResponse['result']['feed']['entry']) && is_array($aResponse['result']['feed']['entry']))
|
||||
if (!empty($aResponse['result']['feed']['entry']) && \is_array($aResponse['result']['feed']['entry']))
|
||||
{
|
||||
$mResult = array();
|
||||
foreach ($aResponse['result']['feed']['entry'] as $oItem)
|
||||
|
|
@ -140,7 +140,7 @@ class Social
|
|||
$aItem = $this->convertGoogleJsonContactToResponseContact($oItem, $aPics);
|
||||
if ($aItem)
|
||||
{
|
||||
if (is_array($aItem['email']))
|
||||
if (\is_array($aItem['email']))
|
||||
{
|
||||
$aNewItem = $aItem;
|
||||
unset($aNewItem['email']);
|
||||
|
|
@ -185,7 +185,7 @@ class Social
|
|||
if (!empty($sEncodedeData))
|
||||
{
|
||||
$aData = \RainLoop\Utils::DecodeKeyValues($sEncodedeData);
|
||||
if (is_array($aData) && isset($aData['access_token'], $aData['id']))
|
||||
if (\is_array($aData) && isset($aData['access_token'], $aData['id']))
|
||||
{
|
||||
$this->oActions->StorageProvider()->Clear(null,
|
||||
\RainLoop\Providers\Storage\Enumerations\StorageType::NOBODY,
|
||||
|
|
|
|||
|
|
@ -225,7 +225,7 @@
|
|||
<div data-bind="foreach: viewPropertiesEmails">
|
||||
<div class="property-line">
|
||||
<span class="contactValueStatic" data-bind="text: value" />
|
||||
<input type="email" class="contactValueInput" placeholder=""
|
||||
<input type="text" class="contactValueInput" placeholder=""
|
||||
autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"
|
||||
data-bind="value: value, hasFocus: focused, valueUpdate: 'keyup'" />
|
||||
</div>
|
||||
|
|
|
|||
8
rainloop/v/0.0.0/static/js/admin.min.js
vendored
8
rainloop/v/0.0.0/static/js/admin.min.js
vendored
File diff suppressed because one or more lines are too long
12
rainloop/v/0.0.0/static/js/app.min.js
vendored
12
rainloop/v/0.0.0/static/js/app.min.js
vendored
File diff suppressed because one or more lines are too long
Loading…
Add table
Add a link
Reference in a new issue