From 9e5229495bc37d8739700db40b1ec27f9a27024b Mon Sep 17 00:00:00 2001 From: Alex Pott Date: Fri, 9 Apr 2021 10:27:04 +0100 Subject: [PATCH 1/3] Ensure path info has a leading slash --- src/Symfony/Component/HttpFoundation/Request.php | 3 +++ .../HttpFoundation/Tests/RequestTest.php | 15 +++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/src/Symfony/Component/HttpFoundation/Request.php b/src/Symfony/Component/HttpFoundation/Request.php index 34d352a25df4d..149c2418b65d8 100644 --- a/src/Symfony/Component/HttpFoundation/Request.php +++ b/src/Symfony/Component/HttpFoundation/Request.php @@ -1964,6 +1964,9 @@ protected function preparePathInfo() // If substr() returns false then PATH_INFO is set to an empty string return '/'; } + if ('/' !== $pathInfo[0]) { + $pathInfo = '/'.$pathInfo; + } return (string) $pathInfo; } diff --git a/src/Symfony/Component/HttpFoundation/Tests/RequestTest.php b/src/Symfony/Component/HttpFoundation/Tests/RequestTest.php index 0fab586dabe31..1bfba9f9904f9 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/RequestTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/RequestTest.php @@ -244,6 +244,21 @@ public function testCreate() // Fragment should not be included in the URI $request = Request::create('http://test.com/foo#bar'); $this->assertEquals('http://test.com/foo', $request->getUri()); + + // assume no rewrite rule: /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() From 5464a704f9c60e4d568c6e726d203db0214ddaa8 Mon Sep 17 00:00:00 2001 From: Alex Pott Date: Fri, 9 Apr 2021 11:23:42 +0100 Subject: [PATCH 2/3] Move test to its own method --- src/Symfony/Component/HttpFoundation/Tests/RequestTest.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Symfony/Component/HttpFoundation/Tests/RequestTest.php b/src/Symfony/Component/HttpFoundation/Tests/RequestTest.php index 1bfba9f9904f9..4d179ea46d144 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/RequestTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/RequestTest.php @@ -244,8 +244,12 @@ public function testCreate() // Fragment should not be included in the URI $request = Request::create('http://test.com/foo#bar'); $this->assertEquals('http://test.com/foo', $request->getUri()); + } + public function testIndexDotPhpPathInfo() + { // assume no rewrite rule: /index.php --> / + // assume rewrite rule: /index.php/something --> /something $request = Request::create('http://test.com/index.php.php', 'GET', [], [], [], [ 'DOCUMENT_ROOT' => '/var/www/www.test.com', From 3a5f319ff8003a9f3b994bc3d729fead0036718b Mon Sep 17 00:00:00 2001 From: Alex Pott Date: Fri, 9 Apr 2021 11:29:27 +0100 Subject: [PATCH 3/3] Improve documentation of assumptions --- src/Symfony/Component/HttpFoundation/Tests/RequestTest.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Component/HttpFoundation/Tests/RequestTest.php b/src/Symfony/Component/HttpFoundation/Tests/RequestTest.php index 4d179ea46d144..a6d482224296c 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/RequestTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/RequestTest.php @@ -249,7 +249,9 @@ public function testCreate() public function testIndexDotPhpPathInfo() { // assume no rewrite rule: /index.php --> / - // assume rewrite rule: /index.php/something --> /something + // 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', 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