Skip to content

Commit 1e6e9e2

Browse files
committed
Merge branch '4.4' into 5.1
2 parents 79148b4 + 9eeb37e commit 1e6e9e2

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
@@ -1850,9 +1850,15 @@ protected function prepareBaseUrl()
18501850
}
18511851

18521852
$basename = basename($baseUrl);
1853-
if (empty($basename) || !strpos(rawurldecode($truncatedRequestUri), $basename)) {
1854-
// no match whatsoever; set it blank
1855-
return '';
1853+
if (empty($basename) || !strpos(rawurldecode($truncatedRequestUri).'/', '/'.$basename.'/')) {
1854+
// strip autoindex filename, for virtualhost based on URL path
1855+
$baseUrl = \dirname($baseUrl).'/';
1856+
1857+
$basename = basename($baseUrl);
1858+
if (empty($basename) || !strpos(rawurldecode($truncatedRequestUri).'/', '/'.$basename.'/')) {
1859+
// no match whatsoever; set it blank
1860+
return '';
1861+
}
18561862
}
18571863

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

Tests/RequestTest.php

+30
Original file line numberDiff line numberDiff line change
@@ -1757,6 +1757,36 @@ public function getBaseUrlData()
17571757
'/foo',
17581758
'/bar+baz',
17591759
],
1760+
[
1761+
'/sub/foo/bar',
1762+
[
1763+
'SCRIPT_FILENAME' => '/home/John Doe/public_html/foo/app.php',
1764+
'SCRIPT_NAME' => '/foo/app.php',
1765+
'PHP_SELF' => '/foo/app.php',
1766+
],
1767+
'/sub/foo',
1768+
'/bar',
1769+
],
1770+
[
1771+
'/sub/foo/app.php/bar',
1772+
[
1773+
'SCRIPT_FILENAME' => '/home/John Doe/public_html/foo/app.php',
1774+
'SCRIPT_NAME' => '/foo/app.php',
1775+
'PHP_SELF' => '/foo/app.php',
1776+
],
1777+
'/sub/foo/app.php',
1778+
'/bar',
1779+
],
1780+
[
1781+
'/sub/foo/bar/baz',
1782+
[
1783+
'SCRIPT_FILENAME' => '/home/John Doe/public_html/foo/app2.phpx',
1784+
'SCRIPT_NAME' => '/foo/app2.phpx',
1785+
'PHP_SELF' => '/foo/app2.phpx',
1786+
],
1787+
'/sub/foo',
1788+
'/bar/baz',
1789+
],
17601790
];
17611791
}
17621792

0 commit comments

Comments
 (0)