[HttpFoundation] Fix baseUrl when script filename is contained in pathInfo

This commit is contained in:
Daniel Tschinder 2015-04-13 12:21:56 +02:00 committed by Fabien Potencier
parent 5d428b7091
commit f24a6dd43a
2 changed files with 21 additions and 1 deletions

View File

@ -1712,7 +1712,7 @@ class Request
return $prefix; return $prefix;
} }
if ($baseUrl && false !== $prefix = $this->getUrlencodedPrefix($requestUri, dirname($baseUrl).'/')) { if ($baseUrl && false !== $prefix = $this->getUrlencodedPrefix($requestUri, rtrim(dirname($baseUrl), '/').'/')) {
// directory portion of $baseUrl matches // directory portion of $baseUrl matches
return rtrim($prefix, '/'); return rtrim($prefix, '/');
} }

View File

@ -1320,6 +1320,26 @@ class RequestTest extends \PHPUnit_Framework_TestCase
public function getBaseUrlData() public function getBaseUrlData()
{ {
return array( return array(
array(
'/fruit/strawberry/1234index.php/blah',
array(
'SCRIPT_FILENAME' => 'E:/Sites/cc-new/public_html/fruit/index.php',
'SCRIPT_NAME' => '/fruit/index.php',
'PHP_SELF' => '/fruit/index.php',
),
'/fruit',
'/strawberry/1234index.php/blah',
),
array(
'/fruit/strawberry/1234index.php/blah',
array(
'SCRIPT_FILENAME' => 'E:/Sites/cc-new/public_html/index.php',
'SCRIPT_NAME' => '/index.php',
'PHP_SELF' => '/index.php',
),
'',
'/fruit/strawberry/1234index.php/blah',
),
array( array(
'/foo%20bar/', '/foo%20bar/',
array( array(