[HttpFoundation] fix #2142 PathInfo parsing/checking

Bug fix: yes
Feature addition: no
Backwards compatibility break: no
Symfony2 tests pass: yes
Fixes the following tickets: #2142
This commit is contained in:
stealth35 2011-09-28 13:18:44 +02:00
parent 2db24c264f
commit b12ce94c38
2 changed files with 26 additions and 1 deletions

View File

@ -1188,7 +1188,7 @@ class Request
$requestUri = substr($requestUri, 0, $pos);
}
if ((null !== $baseUrl) && (false === ($pathInfo = substr($requestUri, strlen($baseUrl))))) {
if ((null !== $baseUrl) && (false === ($pathInfo = substr(urldecode($requestUri), strlen(urldecode($baseUrl)))))) {
// If substr() returns false then PATH_INFO is set to an empty string
return '/';
} elseif (null === $baseUrl) {

View File

@ -689,6 +689,31 @@ class RequestTest extends \PHPUnit_Framework_TestCase
$this->assertEquals('', $request->getBasePath());
}
public function testGetPathInfo()
{
$request = new Request();
$this->assertEquals('/', $request->getPathInfo());
$server = array();
$server['REQUEST_URI'] = '/path/info';
$request->initialize(array(), array(), array(), array(), array(), $server);
$this->assertEquals('/path/info', $request->getPathInfo());
$server = array();
$server['REQUEST_URI'] = '/path test/info';
$request->initialize(array(), array(), array(), array(), array(), $server);
$this->assertEquals('/path test/info', $request->getPathInfo());
$server = array();
$server['REQUEST_URI'] = '/path%20test/info';
$request->initialize(array(), array(), array(), array(), array(), $server);
$this->assertEquals('/path test/info', $request->getPathInfo());
}
public function testGetPreferredLanguage()
{
$request = new Request();