Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMatthieu Napoli <matthieu@mnapoli.fr>2014-10-22 05:49:29 +0400
committerMatthieu Napoli <matthieu@mnapoli.fr>2014-10-22 05:50:23 +0400
commitad2c051089281bbfa39b9426e1009a7a2fb9d08d (patch)
tree9a23e3bb3d167c86884f26a13584e4e43da7fb53 /tests
parentef4e84f20e59649a05240118de5ecedb56fd6996 (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.php28
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',