From 7eb5156f995863e7cb0bfda2c7e9360608fa961e Mon Sep 17 00:00:00 2001 From: Laurent Giovannoni <laurent.giovannoni@maarch.org> Date: Mon, 30 Jan 2012 11:48:24 +0000 Subject: [PATCH] fixes #295: URL::_buildCoreUrl() added the port number twice if it is nonstandard. --- core/trunk/core/class/Url.php | 8 ++++++-- core/trunk/core/tests/class/UrlTest.php | 2 +- core/trunk/core/tests/class/UrlWithProxyTest.php | 2 +- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/core/trunk/core/class/Url.php b/core/trunk/core/class/Url.php index 2d4ad5db288..596bb806524 100644 --- a/core/trunk/core/class/Url.php +++ b/core/trunk/core/class/Url.php @@ -185,8 +185,12 @@ class Url private static function _buildHost() { - return array_key_exists('HTTP_X_FORWARDED_HOST', $_SERVER) - ? $_SERVER['HTTP_X_FORWARDED_HOST'] : $_SERVER['HTTP_HOST']; + if (array_key_exists('HTTP_X_FORWARDED_HOST', $_SERVER)) { + return $_SERVER['HTTP_X_FORWARDED_HOST']; + } else { + $hostParts = explode(':',$_SERVER['HTTP_HOST']); + return $hostParts[0]; + } } private static function _buildPort() diff --git a/core/trunk/core/tests/class/UrlTest.php b/core/trunk/core/tests/class/UrlTest.php index a42b8b47642..8ed17f55084 100644 --- a/core/trunk/core/tests/class/UrlTest.php +++ b/core/trunk/core/tests/class/UrlTest.php @@ -25,7 +25,7 @@ class UrlTest extends PHPUnit_Framework_TestCase $_SERVER['HTTPS'] = (strpos($url_parts[0], 's') !== false) ? 'on': ''; $host_parts = explode(':', $url_parts[2]); - $_SERVER['HTTP_HOST'] = $host_parts[0]; + $_SERVER['HTTP_HOST'] = $url_parts[2]; if (count($host_parts) == 2) { $_SERVER['SERVER_PORT'] = $host_parts[1]; } else { diff --git a/core/trunk/core/tests/class/UrlWithProxyTest.php b/core/trunk/core/tests/class/UrlWithProxyTest.php index ce41d0f54ad..5f8eb6dd436 100644 --- a/core/trunk/core/tests/class/UrlWithProxyTest.php +++ b/core/trunk/core/tests/class/UrlWithProxyTest.php @@ -25,7 +25,7 @@ class UrlWithProxyTest extends PHPUnit_Framework_TestCase $_SERVER['HTTPS'] = (strpos($url_parts[0], 's') !== false) ? 'on': ''; $host_parts = explode(':', $url_parts[2]); - $_SERVER['HTTP_HOST'] = $host_parts[0]; + $_SERVER['HTTP_HOST'] = $url_parts[2]; if (count($host_parts) == 2) { $_SERVER['SERVER_PORT'] = $host_parts[1]; } else { -- GitLab