Revert #38614, add assert to avoid regression

This commit is contained in:
BafS 2021-01-18 20:06:40 +01:00
parent 6af444607c
commit 3058cd0ec6
No known key found for this signature in database
GPG Key ID: BDA2FEE6CBF7990A
2 changed files with 17 additions and 13 deletions

View File

@ -1836,15 +1836,9 @@ class Request
}
$basename = basename($baseUrl);
if (empty($basename) || !strpos(rawurldecode($truncatedRequestUri).'/', '/'.$basename.'/')) {
// strip autoindex filename, for virtualhost based on URL path
$baseUrl = \dirname($baseUrl).'/';
$basename = basename($baseUrl);
if (empty($basename) || !strpos(rawurldecode($truncatedRequestUri).'/', '/'.$basename.'/')) {
// no match whatsoever; set it blank
return '';
}
if (empty($basename) || !strpos(rawurldecode($truncatedRequestUri), $basename)) {
// no match whatsoever; set it blank
return '';
}
// If using mod_rewrite or ISAPI_Rewrite strip the script filename

View File

@ -1770,8 +1770,8 @@ class RequestTest extends TestCase
'SCRIPT_NAME' => '/foo/app.php',
'PHP_SELF' => '/foo/app.php',
],
'/sub/foo',
'/bar',
'',
'/sub/foo/bar',
],
[
'/sub/foo/app.php/bar',
@ -1790,8 +1790,18 @@ class RequestTest extends TestCase
'SCRIPT_NAME' => '/foo/app2.phpx',
'PHP_SELF' => '/foo/app2.phpx',
],
'/sub/foo',
'/bar/baz',
'',
'/sub/foo/bar/baz',
],
[
'/foo/api/bar',
[
'SCRIPT_FILENAME' => '/var/www/api/index.php',
'SCRIPT_NAME' => '/api/index.php',
'PHP_SELF' => '/api/index.php',
],
'',
'/foo/api/bar',
],
];
}