Skip to content

Commit f24a6dd

Browse files
danezfabpot
authored andcommitted
[HttpFoundation] Fix baseUrl when script filename is contained in pathInfo
1 parent 5d428b7 commit f24a6dd

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

src/Symfony/Component/HttpFoundation/Request.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1712,7 +1712,7 @@ protected function prepareBaseUrl()
17121712
return $prefix;
17131713
}
17141714

1715-
if ($baseUrl && false !== $prefix = $this->getUrlencodedPrefix($requestUri, dirname($baseUrl).'/')) {
1715+
if ($baseUrl && false !== $prefix = $this->getUrlencodedPrefix($requestUri, rtrim(dirname($baseUrl), '/').'/')) {
17161716
// directory portion of $baseUrl matches
17171717
return rtrim($prefix, '/');
17181718
}

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

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1320,6 +1320,26 @@ public function testGetBaseUrl($uri, $server, $expectedBaseUrl, $expectedPathInf
13201320
public function getBaseUrlData()
13211321
{
13221322
return array(
1323+
array(
1324+
'/fruit/strawberry/1234index.php/blah',
1325+
array(
1326+
'SCRIPT_FILENAME' => 'E:/Sites/cc-new/public_html/fruit/index.php',
1327+
'SCRIPT_NAME' => '/fruit/index.php',
1328+
'PHP_SELF' => '/fruit/index.php',
1329+
),
1330+
'/fruit',
1331+
'/strawberry/1234index.php/blah',
1332+
),
1333+
array(
1334+
'/fruit/strawberry/1234index.php/blah',
1335+
array(
1336+
'SCRIPT_FILENAME' => 'E:/Sites/cc-new/public_html/index.php',
1337+
'SCRIPT_NAME' => '/index.php',
1338+
'PHP_SELF' => '/index.php',
1339+
),
1340+
'',
1341+
'/fruit/strawberry/1234index.php/blah',
1342+
),
13231343
array(
13241344
'/foo%20bar/',
13251345
array(

0 commit comments

Comments
 (0)