Skip to content

Commit b12ce94

Browse files
committed
[HttpFoundation] fix symfony#2142 PathInfo parsing/checking
Bug fix: yes Feature addition: no Backwards compatibility break: no Symfony2 tests pass: yes Fixes the following tickets: symfony#2142
1 parent 2db24c2 commit b12ce94

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

src/Symfony/Component/HttpFoundation/Request.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1188,7 +1188,7 @@ protected function preparePathInfo()
11881188
$requestUri = substr($requestUri, 0, $pos);
11891189
}
11901190

1191-
if ((null !== $baseUrl) && (false === ($pathInfo = substr($requestUri, strlen($baseUrl))))) {
1191+
if ((null !== $baseUrl) && (false === ($pathInfo = substr(urldecode($requestUri), strlen(urldecode($baseUrl)))))) {
11921192
// If substr() returns false then PATH_INFO is set to an empty string
11931193
return '/';
11941194
} elseif (null === $baseUrl) {

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

+25
Original file line numberDiff line numberDiff line change
@@ -689,6 +689,31 @@ public function testGetBasePath()
689689
$this->assertEquals('', $request->getBasePath());
690690
}
691691

692+
public function testGetPathInfo()
693+
{
694+
$request = new Request();
695+
$this->assertEquals('/', $request->getPathInfo());
696+
697+
$server = array();
698+
$server['REQUEST_URI'] = '/path/info';
699+
$request->initialize(array(), array(), array(), array(), array(), $server);
700+
701+
$this->assertEquals('/path/info', $request->getPathInfo());
702+
703+
$server = array();
704+
$server['REQUEST_URI'] = '/path test/info';
705+
$request->initialize(array(), array(), array(), array(), array(), $server);
706+
707+
$this->assertEquals('/path test/info', $request->getPathInfo());
708+
709+
$server = array();
710+
$server['REQUEST_URI'] = '/path%20test/info';
711+
$request->initialize(array(), array(), array(), array(), array(), $server);
712+
713+
$this->assertEquals('/path test/info', $request->getPathInfo());
714+
715+
}
716+
692717
public function testGetPreferredLanguage()
693718
{
694719
$request = new Request();

0 commit comments

Comments
 (0)