diff options
author | Matthieu Napoli <matthieu@mnapoli.fr> | 2014-10-22 05:49:29 +0400 |
---|---|---|
committer | Matthieu Napoli <matthieu@mnapoli.fr> | 2014-10-22 05:50:23 +0400 |
commit | ad2c051089281bbfa39b9426e1009a7a2fb9d08d (patch) | |
tree | 9a23e3bb3d167c86884f26a13584e4e43da7fb53 /tests | |
parent | ef4e84f20e59649a05240118de5ecedb56fd6996 (diff) |
#6491 Fixes a redirection loop when Nginx is misconfigured and passes an incorrect PATH_INFO
Diffstat (limited to 'tests')
-rw-r--r-- | tests/PHPUnit/Unit/UrlTest.php | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/tests/PHPUnit/Unit/UrlTest.php b/tests/PHPUnit/Unit/UrlTest.php index c408438f35..bbde992785 100644 --- a/tests/PHPUnit/Unit/UrlTest.php +++ b/tests/PHPUnit/Unit/UrlTest.php @@ -375,6 +375,34 @@ class UrlTest extends PHPUnit_Framework_TestCase $this->assertEquals($expected, Url::getCurrentUrlWithoutQueryString()); } + /** + * Tests a use case that was reported by some users: Nginx is not properly configured and passes + * incorrect PATH_INFO values in $_SERVER. + * @link https://github.com/piwik/piwik/issues/6491 + * @group Core + */ + public function testMisconfiguredNginxPathInfo() + { + $this->resetGlobalVariables(); + + // these variables where taken from a bug report + $_SERVER = array( + 'QUERY_STRING' => 'foo=bar', + 'PATH_INFO' => '/test.php', // Nginx passed a wrong value here (should be empty) + 'SCRIPT_NAME' => '/test.php', + 'REQUEST_URI' => '/test.php?foo=bar', + 'DOCUMENT_URI' => '/test.php', + 'SERVER_PROTOCOL' => 'HTTP/1.1', + 'SERVER_NAME' => 'example.com', + 'HTTP_HOST' => 'example.com', + 'PHP_SELF' => '/test.php/test.php', // Nginx passed a wrong value here (should be /test.php) + ); + + $expectedUrl = 'http://example.com/test.php?foo=bar'; + + $this->assertEquals($expectedUrl, Url::getCurrentUrl()); + } + private function resetGlobalVariables() { $names = array('PATH_INFO', 'REQUEST_URI', 'SCRIPT_NAME', 'SCRIPT_FILENAME', 'argv', 'HTTPS', |