From 4fb2810add2ad1eb6199ae1dd80fc70adf620d8d Mon Sep 17 00:00:00 2001 From: Lukas Reschke Date: Fri, 19 Aug 2016 14:46:20 +0200 Subject: [PATCH] Remove reading PATH_INFO from server variable Having two code paths for this is unreliable and can lead to bugs. Also, in some cases Apache isn't setting the PATH_INFO variable when mod_rewrite is used. Fixes https://github.com/nextcloud/server/issues/983 --- lib/private/AppFramework/Http/Request.php | 4 ---- tests/lib/AppFramework/Http/RequestTest.php | 16 ---------------- 2 files changed, 20 deletions(-) diff --git a/lib/private/AppFramework/Http/Request.php b/lib/private/AppFramework/Http/Request.php index 8fb19f2d9b..4a0c26a54f 100644 --- a/lib/private/AppFramework/Http/Request.php +++ b/lib/private/AppFramework/Http/Request.php @@ -701,10 +701,6 @@ class Request implements \ArrayAccess, \Countable, IRequest { * @return string|false Path info or false when not found */ public function getPathInfo() { - if(isset($this->server['PATH_INFO'])) { - return $this->server['PATH_INFO']; - } - $pathInfo = $this->getRawPathInfo(); // following is taken from \Sabre\HTTP\URLUtil::decodePathSegment $pathInfo = rawurldecode($pathInfo); diff --git a/tests/lib/AppFramework/Http/RequestTest.php b/tests/lib/AppFramework/Http/RequestTest.php index 8df81afeb3..a3433e558d 100644 --- a/tests/lib/AppFramework/Http/RequestTest.php +++ b/tests/lib/AppFramework/Http/RequestTest.php @@ -1063,22 +1063,6 @@ class RequestTest extends \Test\TestCase { $this->assertSame('www.owncloud.org', self::invokePrivate($request, 'getOverwriteHost')); } - public function testGetPathInfoWithSetEnv() { - $request = new Request( - [ - 'server' => [ - 'PATH_INFO' => 'apps/files/', - ] - ], - $this->secureRandom, - $this->config, - $this->csrfTokenManager, - $this->stream - ); - - $this->assertSame('apps/files/', $request->getPathInfo()); - } - /** * @expectedException \Exception * @expectedExceptionMessage The requested uri(/foo.php) cannot be processed by the script '/var/www/index.php')