diff options
author | mattab <matthieu.aubry@gmail.com> | 2014-05-12 06:46:42 +0400 |
---|---|---|
committer | mattab <matthieu.aubry@gmail.com> | 2014-05-12 06:46:42 +0400 |
commit | 3fc338a51bd001eec5a366e915d22abf84dcdc8b (patch) | |
tree | 3b6bce697dfaccb11eb8610e84c5c3584b825097 /core | |
parent | c866f47f5e7b9f872db969324786f0b28e7750d7 (diff) |
Fixes issue when a port number is appended to the hostname, expected: pick the hostname'd config file (without port number)
Diffstat (limited to 'core')
-rw-r--r-- | core/Config.php | 9 | ||||
-rw-r--r-- | core/Url.php | 13 |
2 files changed, 21 insertions, 1 deletions
diff --git a/core/Config.php b/core/Config.php index d08e89ce4c..2e093007c7 100644 --- a/core/Config.php +++ b/core/Config.php @@ -234,10 +234,19 @@ class Config extends Singleton return false; } + /** + * Returns the hostname of the current request (without port number) + * + * @return string + */ public static function getHostname() { // Check trusted requires config file which is not ready yet $host = Url::getHost($checkIfTrusted = false); + + // Remove any port number to get actual hostname + $host = Url::getHostSanitized($host); + return $host; } diff --git a/core/Url.php b/core/Url.php index df60c388d1..7d5d05d08d 100644 --- a/core/Url.php +++ b/core/Url.php @@ -528,7 +528,7 @@ class Url } // drop port numbers from hostnames and IP addresses - $hosts = array_map(array('Piwik\IP', 'sanitizeIp'), $hosts); + $hosts = array_map(array('self', 'getHostSanitized'), $hosts); $disableHostCheck = Config::getInstance()->General['enable_trusted_host_check'] == 0; // compare scheme and host @@ -564,4 +564,15 @@ class Url return $trustedHosts; } + + /** + * Returns hostname, without port numbers + * + * @param $host + * @return array + */ + public static function getHostSanitized($host) + { + return IP::sanitizeIp($host); + } } |