Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 3 additions & 9 deletions src/Symfony/Component/HttpFoundation/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -1836,15 +1836,9 @@ protected function prepareBaseUrl()
}

$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
Expand Down
18 changes: 14 additions & 4 deletions src/Symfony/Component/HttpFoundation/Tests/RequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1770,8 +1770,8 @@ public function getBaseUrlData()
'SCRIPT_NAME' => '/foo/app.php',
'PHP_SELF' => '/foo/app.php',
],
'/sub/foo',
'/bar',
'',
'/sub/foo/bar',
],
[
'/sub/foo/app.php/bar',
Expand All @@ -1790,8 +1790,18 @@ public function getBaseUrlData()
'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',
],
];
}
Expand Down