From ae6a264d6d7dfa393639fdea39757a828caafa2b Mon Sep 17 00:00:00 2001 From: bruno-ds Date: Fri, 5 Mar 2021 16:57:03 +0100 Subject: [PATCH] =?UTF-8?q?N=C2=B03671=20-=20fix=20typo=20in=20HTTP=20head?= =?UTF-8?q?er=20name?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/utils.inc.php | 4 ++-- test/application/UtilsTest.php | 32 ++++++++++++++++---------------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/application/utils.inc.php b/application/utils.inc.php index afa04a5b0..721fda1d7 100644 --- a/application/utils.inc.php +++ b/application/utils.inc.php @@ -916,7 +916,7 @@ class utils $sServerName = isset($_SERVER['SERVER_NAME']) ? $_SERVER['SERVER_NAME'] : ''; if ($bTrustProxy) { - $sServerName = isset($_SERVER['X_FORWARDED_HOST']) ? $_SERVER['X_FORWARDED_HOST'] : $sServerName; + $sServerName = isset($_SERVER['HTTP_X_FORWARDED_HOST']) ? $_SERVER['HTTP_X_FORWARDED_HOST'] : $sServerName; } return $sServerName; @@ -935,7 +935,7 @@ class utils $sServerPort = isset($_SERVER['SERVER_PORT']) ? $_SERVER['SERVER_PORT'] : 80; if ($bTrustProxy) { - $sServerPort = isset($_SERVER['X_FORWARDED_PORT']) ? $_SERVER['X_FORWARDED_PORT'] : $sServerPort; + $sServerPort = isset($_SERVER['HTTP_X_FORWARDED_PORT']) ? $_SERVER['HTTP_X_FORWARDED_PORT'] : $sServerPort; } return $sServerPort; diff --git a/test/application/UtilsTest.php b/test/application/UtilsTest.php index 93e2ab241..779ea8b38 100644 --- a/test/application/UtilsTest.php +++ b/test/application/UtilsTest.php @@ -186,9 +186,9 @@ class UtilsTest extends \Combodo\iTop\Test\UnitTest\ItopTestCase $baseServerVar = [ 'REMOTE_ADDR' => '127.0.0.1', //is not set, disable IsProxyTrusted 'SERVER_NAME' => 'example.com', - 'X_FORWARDED_HOST' => null, + 'HTTP_X_FORWARDED_HOST' => null, 'SERVER_PORT' => '80', - 'X_FORWARDED_PORT' => null, + 'HTTP_X_FORWARDED_PORT' => null, 'REQUEST_URI' => '/index.php?baz=1', 'SCRIPT_NAME' => '/index.php', 'SCRIPT_FILENAME' => APPROOT.'index.php', @@ -244,8 +244,8 @@ class UtilsTest extends \Combodo\iTop\Test\UnitTest\ItopTestCase 'bForceTrustProxy' => false, 'bConfTrustProxy' => false, 'aServerVars' => array_merge($baseServerVar, [ - 'X_FORWARDED_HOST' => 'proxy.com', - 'X_FORWARDED_PORT' => '4443', + 'HTTP_X_FORWARDED_HOST' => 'proxy.com', + 'HTTP_X_FORWARDED_PORT' => '4443', 'HTTP_X_FORWARDED_PROTO' => 'https', ]), 'sExpectedAppRootUrl' => 'http://example.com/', @@ -254,8 +254,8 @@ class UtilsTest extends \Combodo\iTop\Test\UnitTest\ItopTestCase 'bForceTrustProxy' => false, 'bConfTrustProxy' => true, 'aServerVars' => array_merge($baseServerVar, [ - 'X_FORWARDED_HOST' => 'proxy.com', - 'X_FORWARDED_PORT' => '4443', + 'HTTP_X_FORWARDED_HOST' => 'proxy.com', + 'HTTP_X_FORWARDED_PORT' => '4443', 'HTTP_X_FORWARDED_PROTO' => 'https', ]), 'sExpectedAppRootUrl' => 'https://proxy.com:4443/', @@ -264,8 +264,8 @@ class UtilsTest extends \Combodo\iTop\Test\UnitTest\ItopTestCase 'bForceTrustProxy' => false, 'bConfTrustProxy' => true, 'aServerVars' => array_merge($baseServerVar, [ - 'X_FORWARDED_HOST' => 'proxy.com', - 'X_FORWARDED_PORT' => '4443', + 'HTTP_X_FORWARDED_HOST' => 'proxy.com', + 'HTTP_X_FORWARDED_PORT' => '4443', 'HTTP_X_FORWARDED_PROTOCOL' => 'https', ]), 'sExpectedAppRootUrl' => 'https://proxy.com:4443/', @@ -274,8 +274,8 @@ class UtilsTest extends \Combodo\iTop\Test\UnitTest\ItopTestCase 'bForceTrustProxy' => true, 'bConfTrustProxy' => false, 'aServerVars' => array_merge($baseServerVar, [ - 'X_FORWARDED_HOST' => 'proxy.com', - 'X_FORWARDED_PORT' => '4443', + 'HTTP_X_FORWARDED_HOST' => 'proxy.com', + 'HTTP_X_FORWARDED_PORT' => '4443', 'HTTP_X_FORWARDED_PROTO' => 'https', ]), 'sExpectedAppRootUrl' => 'https://proxy.com:4443/', @@ -284,8 +284,8 @@ class UtilsTest extends \Combodo\iTop\Test\UnitTest\ItopTestCase 'bForceTrustProxy' => true, 'bConfTrustProxy' => true, 'aServerVars' => array_merge($baseServerVar, [ - 'X_FORWARDED_HOST' => 'proxy.com', - 'X_FORWARDED_PORT' => '4443', + 'HTTP_X_FORWARDED_HOST' => 'proxy.com', + 'HTTP_X_FORWARDED_PORT' => '4443', 'HTTP_X_FORWARDED_PROTO' => 'https', ]), 'sExpectedAppRootUrl' => 'https://proxy.com:4443/', @@ -296,8 +296,8 @@ class UtilsTest extends \Combodo\iTop\Test\UnitTest\ItopTestCase 'bConfTrustProxy' => false, 'aServerVars' => array_merge($baseServerVar, [ 'REMOTE_ADDR' => null, - 'X_FORWARDED_HOST' => 'proxy.com', - 'X_FORWARDED_PORT' => '4443', + 'HTTP_X_FORWARDED_HOST' => 'proxy.com', + 'HTTP_X_FORWARDED_PORT' => '4443', 'HTTP_X_FORWARDED_PROTO' => 'https', ]), 'sExpectedAppRootUrl' => 'https://proxy.com:4443/', @@ -307,8 +307,8 @@ class UtilsTest extends \Combodo\iTop\Test\UnitTest\ItopTestCase 'bConfTrustProxy' => true, 'aServerVars' => array_merge($baseServerVar, [ 'REMOTE_ADDR' => null, - 'X_FORWARDED_HOST' => 'proxy.com', - 'X_FORWARDED_PORT' => '4443', + 'HTTP_X_FORWARDED_HOST' => 'proxy.com', + 'HTTP_X_FORWARDED_PORT' => '4443', 'HTTP_X_FORWARDED_PROTO' => 'https', ]), 'sExpectedAppRootUrl' => 'http://example.com/',