Skip to content

Commit db488a6

Browse files
Merge branch '6.4' into 7.3
* 6.4: [HttpFoundation] Fix parsing pathinfo with no leading slash
2 parents 6379e49 + b03d11e commit db488a6

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
@@ -1908,9 +1908,8 @@ protected function preparePathInfo(): string
19081908
}
19091909

19101910
$pathInfo = substr($requestUri, \strlen($baseUrl));
1911-
if ('' === $pathInfo) {
1912-
// If substr() returns false then PATH_INFO is set to an empty string
1913-
return '/';
1911+
if ('' === $pathInfo || '/' !== $pathInfo[0]) {
1912+
return '/'.$pathInfo;
19141913
}
19151914

19161915
return $pathInfo;

Tests/RequestTest.php

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

0 commit comments

Comments
 (0)