Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 62d09b8

Browse files
committed
[HttpFoundation] ensures that path info always starts with a /
1 parent d2525c9 commit 62d09b8

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/Symfony/Component/HttpFoundation/Request.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -377,6 +377,8 @@ public function getScriptName()
377377
/**
378378
* Returns the path being requested relative to the executed script.
379379
*
380+
* The path info always starts with a /.
381+
*
380382
* Suppose this request is instantiated from /mysite on localhost:
381383
*
382384
* * http://localhost/mysite returns an empty string
@@ -417,6 +419,8 @@ public function getBasePath()
417419
/**
418420
* Returns the root url from which this request is executed.
419421
*
422+
* The base URL never ends with a /.
423+
*
420424
* This is similar to getBasePath(), except that it also includes the
421425
* script filename (e.g. index.php) if one exists.
422426
*
@@ -976,10 +980,10 @@ protected function preparePathInfo()
976980
$baseUrl = $this->getBaseUrl();
977981

978982
if (null === ($requestUri = $this->getRequestUri())) {
979-
return '';
983+
return '/';
980984
}
981985

982-
$pathInfo = '';
986+
$pathInfo = '/';
983987

984988
// Remove the query string from REQUEST_URI
985989
if ($pos = strpos($requestUri, '?')) {
@@ -988,7 +992,7 @@ protected function preparePathInfo()
988992

989993
if ((null !== $baseUrl) && (false === ($pathInfo = substr($requestUri, strlen($baseUrl))))) {
990994
// If substr() returns false then PATH_INFO is set to an empty string
991-
return '';
995+
return '/';
992996
} elseif (null === $baseUrl) {
993997
return $requestUri;
994998
}

0 commit comments

Comments
 (0)