Skip to content

Commit b03d11e

Browse files
Merge branch '5.4' into 6.4
* 5.4: [HttpFoundation] Fix parsing pathinfo with no leading slash
2 parents 1ba1d5f + 1a0706e commit b03d11e

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

Request.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1933,9 +1933,8 @@ protected function preparePathInfo(): string
19331933
}
19341934

19351935
$pathInfo = substr($requestUri, \strlen($baseUrl));
1936-
if (false === $pathInfo || '' === $pathInfo) {
1937-
// If substr() returns false then PATH_INFO is set to an empty string
1938-
return '/';
1936+
if (false === $pathInfo || '' === $pathInfo || '/' !== $pathInfo[0]) {
1937+
return '/'.$pathInfo;
19391938
}
19401939

19411940
return $pathInfo;

Tests/RequestTest.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1904,6 +1904,16 @@ public static function getBaseUrlData()
19041904
'',
19051905
'/foo/api/bar',
19061906
],
1907+
[
1908+
'/api/index.phpfoo',
1909+
[
1910+
'SCRIPT_FILENAME' => '/var/www/api/index.php',
1911+
'SCRIPT_NAME' => '/api/index.php',
1912+
'PHP_SELF' => '/api/index.php',
1913+
],
1914+
'/api/index.php',
1915+
'/foo',
1916+
],
19071917
];
19081918
}
19091919

0 commit comments

Comments
 (0)