mirror of
https://github.com/the-djmaze/snappymail.git
synced 2025-02-24 23:08:08 +08:00
Replaced StrToLowerIfAscii() for the better mb_strtolower()
This commit is contained in:
parent
6a4bd6044a
commit
b0463f3bff
7 changed files with 17 additions and 28 deletions
|
@ -206,30 +206,16 @@ abstract class Utils
|
|||
|
||||
public static function IsAscii(string $sValue) : bool
|
||||
{
|
||||
if ('' === \trim($sValue))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return !\preg_match('/[^\x09\x10\x13\x0A\x0D\x20-\x7E]/', $sValue);
|
||||
return '' === \trim($sValue)
|
||||
|| !\preg_match('/[^\x09\x10\x13\x0A\x0D\x20-\x7E]/', $sValue);
|
||||
}
|
||||
|
||||
public static function StrToLowerIfAscii(string $sValue) : string
|
||||
{
|
||||
return static::IsAscii($sValue) ? \strtolower($sValue) : $sValue;
|
||||
}
|
||||
|
||||
public static function StrToUpperIfAscii(string $sValue) : string
|
||||
{
|
||||
return static::IsAscii($sValue) ? \strtoupper($sValue) : $sValue;
|
||||
}
|
||||
|
||||
public static function StrMailDomainToLowerIfAscii(string $sValue) : string
|
||||
public static function StrMailDomainToLower(string $sValue) : string
|
||||
{
|
||||
$aParts = \explode('@', $sValue, 2);
|
||||
if (!empty($aParts[1]))
|
||||
{
|
||||
$aParts[1] = static::IsAscii($aParts[1]) ? \strtolower($aParts[1]) : $aParts[1];
|
||||
$aParts[1] = \mb_strtolower($aParts[1]);
|
||||
}
|
||||
|
||||
return \implode('@', $aParts);
|
||||
|
@ -1385,12 +1371,12 @@ abstract class Utils
|
|||
catch (\Throwable $oException) {}
|
||||
}
|
||||
|
||||
return $bLowerIfAscii ? static::StrMailDomainToLowerIfAscii($sStr) : $sStr;
|
||||
return $bLowerIfAscii ? static::StrMailDomainToLower($sStr) : $sStr;
|
||||
}
|
||||
|
||||
public static function IdnToAscii(string $sStr, bool $bLowerIfAscii = false) : string
|
||||
{
|
||||
$sStr = $bLowerIfAscii ? static::StrMailDomainToLowerIfAscii($sStr) : $sStr;
|
||||
$sStr = $bLowerIfAscii ? static::StrMailDomainToLower($sStr) : $sStr;
|
||||
|
||||
$sUser = '';
|
||||
$sDomain = $sStr;
|
||||
|
|
|
@ -29,7 +29,7 @@ trait UserAuth
|
|||
|
||||
$sEmail = \MailSo\Base\Utils::Trim($sEmail);
|
||||
if ($this->Config()->Get('login', 'login_lowercase', true)) {
|
||||
$sEmail = \MailSo\Base\Utils::StrToLowerIfAscii($sEmail);
|
||||
$sEmail = \mb_strtolower($sEmail);
|
||||
}
|
||||
|
||||
if (false === \strpos($sEmail, '@')) {
|
||||
|
@ -104,7 +104,7 @@ trait UserAuth
|
|||
|
||||
$sLogin = $sEmail;
|
||||
if ($this->Config()->Get('login', 'login_lowercase', true)) {
|
||||
$sLogin = \MailSo\Base\Utils::StrToLowerIfAscii($sLogin);
|
||||
$sLogin = \mb_strtolower($sLogin);
|
||||
}
|
||||
|
||||
$this->Plugins()->RunHook('login.credentials', array(&$sEmail, &$sLogin, &$sPassword));
|
||||
|
|
|
@ -409,7 +409,7 @@ trait CardDAV
|
|||
if (\preg_match('/\|(.+)$/', $sUrl, $aMatch) && !empty($aMatch[1]))
|
||||
{
|
||||
$sUserAddressBookNameName = \trim($aMatch[1]);
|
||||
$sUserAddressBookNameName = \MailSo\Base\Utils::StrToLowerIfAscii($sUserAddressBookNameName);
|
||||
$sUserAddressBookNameName = \mb_strtolower($sUserAddressBookNameName);
|
||||
|
||||
$sUrl = \preg_replace('/\|(.+)$/', '', $sUrl);
|
||||
}
|
||||
|
@ -434,7 +434,7 @@ trait CardDAV
|
|||
{
|
||||
foreach ($aPaths as $sKey => $sValue)
|
||||
{
|
||||
$sValue = \MailSo\Base\Utils::StrToLowerIfAscii(\trim($sValue));
|
||||
$sValue = \mb_strtolower(\trim($sValue));
|
||||
if ($sValue === $sUserAddressBookNameName)
|
||||
{
|
||||
$sNewPath = $sKey;
|
||||
|
@ -447,7 +447,7 @@ trait CardDAV
|
|||
{
|
||||
foreach ($aPaths as $sKey => $sValue)
|
||||
{
|
||||
$sValue = \MailSo\Base\Utils::StrToLowerIfAscii($sValue);
|
||||
$sValue = \mb_strtolower($sValue);
|
||||
if (\in_array($sValue, array('contacts', 'default', 'addressbook', 'address book')))
|
||||
{
|
||||
$sNewPath = $sKey;
|
||||
|
|
|
@ -120,7 +120,7 @@ class Property implements \JsonSerializable
|
|||
// lower
|
||||
if ($this->IsEmail())
|
||||
{
|
||||
$this->Value = \MailSo\Base\Utils::StrMailDomainToLowerIfAscii($this->Value);
|
||||
$this->Value = \MailSo\Base\Utils::StrMailDomainToLower($this->Value);
|
||||
}
|
||||
|
||||
if ($this->IsName())
|
||||
|
|
|
@ -1020,7 +1020,7 @@ class PdoAddressBook
|
|||
{
|
||||
if ($aItem && !empty($aItem['prop_value']))
|
||||
{
|
||||
$aExists[] = \MailSo\Base\Utils::StrToLowerIfAscii(\trim($aItem['prop_value']));
|
||||
$aExists[] = \mb_strtolower(\trim($aItem['prop_value']));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -91,7 +91,7 @@ class Service
|
|||
$bAdmin = !empty($aPaths[0]) && \strtolower($aPaths[0]) === $sAdminPanelKey;
|
||||
}
|
||||
else if (empty($aPaths[0]) &&
|
||||
\MailSo\Base\Utils::StrToLowerIfAscii($sAdminPanelHost) === \MailSo\Base\Utils::StrToLowerIfAscii($this->oHttp->GetHost()))
|
||||
\mb_strtolower($sAdminPanelHost) === \mb_strtolower($this->oHttp->GetHost()))
|
||||
{
|
||||
$bAdmin = true;
|
||||
}
|
||||
|
|
|
@ -146,6 +146,9 @@ if (defined('APP_VERSION'))
|
|||
|
||||
define('APP_PLUGINS_PATH', APP_PRIVATE_DATA.'plugins/');
|
||||
|
||||
mb_internal_encoding('UTF-8');
|
||||
mb_language('uni');
|
||||
|
||||
if (APP_VERSION !== $sInstalled || (!is_dir(APP_PRIVATE_DATA) && strlen($sPrivateDataFolderInternalName) && '_default_' !== APP_PRIVATE_DATA_NAME))
|
||||
{
|
||||
define('APP_INSTALLED_START', true);
|
||||
|
|
Loading…
Reference in a new issue