8000 [HttpFoundation] [Request] fix baseUrl parsing to fix wrong path_info · symfony/symfony@3a3ecd3 · GitHub
[go: up one dir, main page]

Skip to content

Commit 3a3ecd3

Browse files
rkernerfabpot
rkerner
authored andcommitted
[HttpFoundation] [Request] fix baseUrl parsing to fix wrong path_info
1 parent 2f53d69 commit 3a3ecd3

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

src/Symfony/Component/HttpFoundation/Request.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1693,7 +1693,7 @@ protected function prepareBaseUrl()
16931693
return $prefix;
16941694
}
16951695

1696-
if ($baseUrl && false !== $prefix = $this->getUrlencodedPrefix($requestUri, dirname($baseUrl))) {
1696+
if ($baseUrl && false !== $prefix = $this->getUrlencodedPrefix($requestUri, dirname($baseUrl).'/')) {
16971697
// directory portion of $baseUrl matches
16981698
return rtrim($prefix, '/');
16991699
}

src/Symfony/Component/HttpFoundation/Tests/RequestTest.php

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,21 @@ public function testCreate()
223223
$request = Request::create('http://test.com/?foo');
224224
$this->assertEquals('/?foo', $request->getRequestUri());
225225
$this->assertEquals(array('foo' => ''), $request->query->all());
226+
227+
## assume rewrite rule: (.*) --> app/app.php ; app/ is a symlink to a symfony web/ directory
228+
$request = Request::create('http://test.com/apparthotel-1234', 'GET', array(), array(), array(),
229+
array(
230+
'DOCUMENT_ROOT' => '/var/www/www.test.com',
231+
'SCRIPT_FILENAME' => '/var/www/www.test.com/app/app.php',
232+
'SCRIPT_NAME' => '/app/app.php',
233+
'PHP_SELF' => '/app/app.php/apparthotel-1234',
234+
));
235+
$this->assertEquals('http://test.com/apparthotel-1234', $request->getUri());
236+
$this->assertEquals('/apparthotel-1234', $request->getPathInfo());
237+
$this->assertEquals('', $request->getQueryString());
238+
$this->assertEquals(80, $request->getPort());
239+
$this->assertEquals('test.com', $request->getHttpHost());
240+
$this->assertFalse($request->isSecure());
226241
}
227242

228243
/**
@@ -1299,7 +1314,7 @@ public function getBaseUrlData()
12991314
{
13001315
return array(
13011316
array(
1302-
'/foo%20bar',
1317+
'/foo%20bar/',
13031318
array(
13041319
'SCRIPT_FILENAME' => '/home/John Doe/public_html/foo bar/app.php',
13051320
'SCRIPT_NAME' => '/foo bar/app.php',

0 commit comments

Comments
 (0)
0