8000 [HttpFoundation] [Request] fix baseUrl parsing to fix wrong path_info by rk3rn3r · Pull Request #13039 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[HttpFoundation] [Request] fix baseUrl parsing to fix wrong path_info #13039

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Symfony/Component/HttpFoundation/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -1693,7 +1693,7 @@ protected function prepareBaseUrl()
return $prefix;
}

if ($baseUrl && false !== $prefix = $this->getUrlencodedPrefix($requestUri, dirname($baseUrl))) {
if ($baseUrl && false !== $prefix = $this->getUrlencodedPrefix($requestUri, dirname($baseUrl).'/')) {
// directory portion of $baseUrl matches
return rtrim($prefix, '/');
}
Expand Down
17 changes: 16 additions & 1 deletion src/Symfony/Component/HttpFoundation/Tests/RequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,21 @@ public function testCreate()
$request = Request::create('http://test.com/?foo');
$this->assertEquals('/?foo', $request->getRequestUri());
$this->assertEquals(array('foo' => ''), $request->query->all());

## assume rewrite rule: (.*) --> app/app.php ; app/ is a symlink to a symfony web/ directory
$request = Request::create('http://test.com/apparthotel-1234', 'GET', array(), array(), array(),
array(
'DOCUMENT_ROOT' => '/var/www/www.test.com',
'SCRIPT_FILENAME' => '/var/www/www.test.com/app/app.php',
'SCRIPT_NAME' => '/app/app.php',
'PHP_SELF' => '/app/app.php/apparthotel-1234',
));
$this->assertEquals('http://test.com/apparthotel-1234', $request->getUri());
$this->assertEquals('/apparthotel-1234', $request->getPathInfo());
$this->assertEquals('', $request->getQueryString());
$this->assertEquals(80, $request->getPort());
$this->assertEquals('test.com', $request->getHttpHost());
$this->assertFalse($request->isSecure());
}

/**
Expand Down Expand Up @@ -1299,7 +1314,7 @@ public function getBaseUrlData()
{
return array(
array(
'/foo%20bar',
'/foo%20bar/',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just double checking. Could anyone rely on the slash not being there and what are the implications?

array(
'SCRIPT_FILENAME' => '/home/John Doe/public_html/foo bar/app.php',
'SCRIPT_NAME' => '/foo bar/app.php',
Expand Down
0