Skip to content

Commit 864012b

Browse files
committed
Merge branch '5.1' into 5.2
* 5.1: remove unreachable code Update ExceptionEvent.php fix firebase transport factory DI tag type [HttpFoundation] Fix for virtualhosts based on URL path
2 parents 46ff6a7 + 1e6e9e2 commit 864012b

File tree

2 files changed

+39
-3
lines changed

2 files changed

+39
-3
lines changed

Request.php

+9-3
Original file line numberDiff line numberDiff line change
@@ -1907,9 +1907,15 @@ protected function prepareBaseUrl()
19071907
}
19081908

19091909
$basename = basename($baseUrl);
1910-
if (empty($basename) || !strpos(rawurldecode($truncatedRequestUri), $basename)) {
1911-
// no match whatsoever; set it blank
1912-
return '';
1910+
if (empty($basename) || !strpos(rawurldecode($truncatedRequestUri).'/', '/'.$basename.'/')) {
1911+
// strip autoindex filename, for virtualhost based on URL path
1912+
$baseUrl = \dirname($baseUrl).'/';
1913+
1914+
$basename = basename($baseUrl);
1915+
if (empty($basename) || !strpos(rawurldecode($truncatedRequestUri).'/', '/'.$basename.'/')) {
1916+
// no match whatsoever; set it blank
1917+
return '';
1918+
}
19131919
}
19141920

19151921
// If using mod_rewrite or ISAPI_Rewrite strip the script filename

Tests/RequestTest.php

+30
Original file line numberDiff line numberDiff line change
@@ -1785,6 +1785,36 @@ public function getBaseUrlData()
17851785
'/foo',
17861786
'/bar+baz',
17871787
],
1788+
[
1789+
'/sub/foo/bar',
1790+
[
1791+
'SCRIPT_FILENAME' => '/home/John Doe/public_html/foo/app.php',
1792+
'SCRIPT_NAME' => '/foo/app.php',
1793+
'PHP_SELF' => '/foo/app.php',
1794+
],
1795+
'/sub/foo',
1796+
'/bar',
1797+
],
1798+
[
1799+
'/sub/foo/app.php/bar',
1800+
[
1801+
'SCRIPT_FILENAME' => '/home/John Doe/public_html/foo/app.php',
1802+
'SCRIPT_NAME' => '/foo/app.php',
1803+
'PHP_SELF' => '/foo/app.php',
1804+
],
1805+
'/sub/foo/app.php',
1806+
'/bar',
1807+
],
1808+
[
1809+
'/sub/foo/bar/baz',
1810+
[
1811+
'SCRIPT_FILENAME' => '/home/John Doe/public_html/foo/app2.phpx',
1812+
'SCRIPT_NAME' => '/foo/app2.phpx',
1813+
'PHP_SELF' => '/foo/app2.phpx',
1814+
],
1815+
'/sub/foo',
1816+
'/bar/baz',
1817+
],
17881818
];
17891819
}
17901820

0 commit comments

Comments
 (0)