diff --git a/snappymail/v/0.0.0/app/libraries/MailSo/Base/Http.php b/snappymail/v/0.0.0/app/libraries/MailSo/Base/Http.php index 3cde857291..4d8e37fb3e 100644 --- a/snappymail/v/0.0.0/app/libraries/MailSo/Base/Http.php +++ b/snappymail/v/0.0.0/app/libraries/MailSo/Base/Http.php @@ -109,23 +109,18 @@ public function IsSecure(bool $bCheckProxy = true) : bool )); } - public function GetHost(bool $bWithRemoteUserData = false, bool $bWithoutWWW = true, bool $bWithoutPort = false) : string + public function GetHost(bool $bWithoutWWW = true, bool $bWithoutPort = false) : string { $sHost = static::GetServer('HTTP_HOST', ''); if (!\strlen($sHost)) { - $sName = static::GetServer('SERVER_NAME'); + $sName = static::GetServer('SERVER_NAME', ''); $iPort = (int) static::GetServer('SERVER_PORT', 80); $sHost = (\in_array($iPort, array(80, 433))) ? $sName : $sName.':'.$iPort; } - if ($bWithoutWWW) { - $sHost = 'www.' === \substr(\strtolower($sHost), 0, 4) ? \substr($sHost, 4) : $sHost; - } - - if ($bWithRemoteUserData) { - $sUser = \trim(static::GetServer('REMOTE_USER', '')); - $sHost = (\strlen($sUser) ? $sUser.'@' : '').$sHost; + if ($bWithoutWWW && 'www.' === \substr(\strtolower($sHost), 0, 4)) { + $sHost = \substr($sHost, 4); } return $bWithoutPort ? \preg_replace('/:\d+$/', '', $sHost) : $sHost; @@ -249,6 +244,6 @@ public function GetUrl() : string public function GetFullUrl() : string { - return $this->GetScheme().'://'.$this->GetHost(true, false).$this->GetPath(); + return $this->GetScheme().'://'.$this->GetHost(false).$this->GetPath(); } } diff --git a/snappymail/v/0.0.0/app/libraries/RainLoop/Actions.php b/snappymail/v/0.0.0/app/libraries/RainLoop/Actions.php index 59d2111abc..b5cdaa18b9 100644 --- a/snappymail/v/0.0.0/app/libraries/RainLoop/Actions.php +++ b/snappymail/v/0.0.0/app/libraries/RainLoop/Actions.php @@ -147,7 +147,7 @@ function __construct() . '][' . \MailSo\Base\Http::GetServer('SERVER_SOFTWARE', '~') . '][' . (\MailSo\Base\Utils::FunctionCallable('php_sapi_name') ? \php_sapi_name() : '~') . '][Streams:' . \implode(',', \stream_get_transports()) - . '][' . $oHttp->GetMethod() . ' ' . $oHttp->GetScheme() . '://' . $oHttp->GetHost(false, false) . \MailSo\Base\Http::GetServer('REQUEST_URI', '') . ']' + . '][' . $oHttp->GetMethod() . ' ' . $oHttp->GetScheme() . '://' . $oHttp->GetHost(false) . \MailSo\Base\Http::GetServer('REQUEST_URI', '') . ']' ); } @@ -293,13 +293,13 @@ protected function compileLogParams(string $sLine, ?Model\Account $oAccount = nu if (false !== \strpos($sLine, '{request:domain}')) { $sLine = \str_replace('{request:domain}', - Utils::UrlEncode($this->Http()->GetHost(false, true, true), $bUrlEncode), $sLine); + Utils::UrlEncode($this->Http()->GetHost(true, true), $bUrlEncode), $sLine); } if (false !== \strpos($sLine, '{request:domain-clear}')) { $sLine = \str_replace('{request:domain-clear}', - Utils::UrlEncode( - \MailSo\Base\Utils::GetClearDomainName($this->Http()->GetHost(false, true, true)), $bUrlEncode), $sLine); + Utils::UrlEncode(\MailSo\Base\Utils::GetClearDomainName($this->Http()->GetHost(true, true)), $bUrlEncode), + $sLine); } $aClear['/\{request:([^}]*)\}/i'] = 'request'; @@ -907,7 +907,7 @@ protected function loginErrorDelay(): void protected function getAdditionalLogParamsByUserLogin(string $sLogin, bool $bAdmin = false): array { - $sHost = $bAdmin ? $this->Http()->GetHost(false, true, true) : \MailSo\Base\Utils::GetDomainFromEmail($sLogin); + $sHost = $bAdmin ? $this->Http()->GetHost(true, true) : \MailSo\Base\Utils::GetDomainFromEmail($sLogin); return array( '{imap:login}' => $sLogin, '{imap:host}' => $sHost, diff --git a/snappymail/v/0.0.0/app/libraries/RainLoop/Actions/UserAuth.php b/snappymail/v/0.0.0/app/libraries/RainLoop/Actions/UserAuth.php index c725aacff1..f1a2b7bde6 100644 --- a/snappymail/v/0.0.0/app/libraries/RainLoop/Actions/UserAuth.php +++ b/snappymail/v/0.0.0/app/libraries/RainLoop/Actions/UserAuth.php @@ -37,7 +37,7 @@ public function resolveLoginCredentials(string &$sEmail, string &$sPassword, str $bAdded = false; if ($this->Config()->Get('login', 'determine_user_domain', false)) { - $sUserHost = \trim($this->Http()->GetHost(false, true, true)); + $sUserHost = \trim($this->Http()->GetHost(true, true)); $this->Logger()->Write('Determined user domain: ' . $sUserHost, \LOG_INFO, 'LOGIN'); $aDomainParts = \explode('.', $sUserHost); diff --git a/snappymail/v/0.0.0/app/libraries/RainLoop/Service.php b/snappymail/v/0.0.0/app/libraries/RainLoop/Service.php index f7c5ecf7ed..62200f3517 100644 --- a/snappymail/v/0.0.0/app/libraries/RainLoop/Service.php +++ b/snappymail/v/0.0.0/app/libraries/RainLoop/Service.php @@ -39,7 +39,7 @@ private static function RunResult() : bool $oHttp = \MailSo\Base\Http::SingletonInstance(); if ($oConfig->Get('security', 'force_https', false) && !$oHttp->IsSecure()) { - \header('Location: https://'.$oHttp->GetHost(false, false).$oHttp->GetUrl()); + \header('Location: https://'.$oHttp->GetHost(false).$oHttp->GetUrl()); exit; }