diff --git a/src/Symfony/Component/HttpFoundation/Request.php b/src/Symfony/Component/HttpFoundation/Request.php index 10b04aedbd079..aba20b29a9cc4 100644 --- a/src/Symfony/Component/HttpFoundation/Request.php +++ b/src/Symfony/Component/HttpFoundation/Request.php @@ -1872,6 +1872,9 @@ protected function preparePathInfo(): string // If substr() returns false then PATH_INFO is set to an empty string return '/'; } + if ('/' !== $pathInfo[0]) { + $pathInfo = '/'.$pathInfo; + } return $pathInfo; } diff --git a/src/Symfony/Component/HttpFoundation/Tests/RequestTest.php b/src/Symfony/Component/HttpFoundation/Tests/RequestTest.php index c7f0c2a146736..fd70384f7191d 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/RequestTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/RequestTest.php @@ -265,6 +265,27 @@ public function testCreate() $this->assertEquals('http://test.com/foo', $request->getUri()); } + public function testIndexDotPhpPathInfo() + { + // assume no rewrite rule: /index.php --> / + // assume index.php is a real file. + // assume rewrite rule passes all requests not referring directly to + // files in the filesystem to index.php. + $request = Request::create('http://test.com/index.php.php', 'GET', [], [], [], + [ + 'DOCUMENT_ROOT' => '/var/www/www.test.com', + 'SCRIPT_FILENAME' => '/var/www/www.test.com/index.php', + 'SCRIPT_NAME' => '/index.php', + 'PHP_SELF' => '/index.php', + ]); + $this->assertEquals('http://test.com/index.php/.php', $request->getUri()); + $this->assertEquals('/.php', $request->getPathInfo()); + $this->assertEquals('', $request->getQueryString()); + $this->assertEquals(80, $request->getPort()); + $this->assertEquals('test.com', $request->getHttpHost()); + $this->assertFalse($request->isSecure()); + } + public function testCreateWithRequestUri() { $request = Request::create('http://test.com:80/foo'); pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy