use hostname from setup, only if webserver-url starts with a slash, closer to previous behavior

This commit is contained in:
Ralf Becker 2019-11-13 18:28:33 +01:00
parent 2fcdcb5afe
commit 056e5c053a

View File

@ -25,11 +25,13 @@ class Http
* 2. $_SERVER['HTTP_X_FORWARDED_HOST'] (X-Forwarded-Host HTTP header) * 2. $_SERVER['HTTP_X_FORWARDED_HOST'] (X-Forwarded-Host HTTP header)
* 3. $_SERVER['HTTP_HOST'] (Host HTTP header) * 3. $_SERVER['HTTP_HOST'] (Host HTTP header)
* *
* @param boolean $use_setup_hostname =false true: hostame config from setup has highest precedence, default not
* @return string * @return string
*/ */
static function host() static function host($use_setup_hostname=false)
{ {
if (!empty($GLOBALS['egw_info']['server']['hostname']) && $GLOBALS['egw_info']['server']['hostname'] !== 'localhost') if ($use_setup_hostname && !empty($GLOBALS['egw_info']['server']['hostname']) &&
$GLOBALS['egw_info']['server']['hostname'] !== 'localhost')
{ {
$host = $GLOBALS['egw_info']['server']['hostname']; $host = $GLOBALS['egw_info']['server']['hostname'];
} }
@ -75,7 +77,7 @@ class Http
{ {
if ($link[0] === '/') if ($link[0] === '/')
{ {
$link = self::schema().'://'.self::host().$link; $link = self::schema().'://'.self::host(true).$link;
} }
return $link; return $link;
} }