Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit bb774d2

Browse files
committed
Revert #38614, add assert to avoid regression
1 parent 6af4446 commit bb774d2

File tree

2 files changed

+17
-13
lines changed

2 files changed

+17
-13
lines changed

src/Symfony/Component/HttpFoundation/Request.php

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1836,15 +1836,9 @@ protected function prepareBaseUrl()
18361836
}
18371837

18381838
$basename = basename($baseUrl);
1839-
if (empty($basename) || !strpos(rawurldecode($truncatedRequestUri).'/', '/'.$basename.'/')) {
1840-
// strip autoindex filename, for virtualhost based on URL path
1841-
$baseUrl = \dirname($baseUrl).'/';
1842-
1843-
$basename = basename($baseUrl);
1844-
if (empty($basename) || !strpos(rawurldecode($truncatedRequestUri).'/', '/'.$basename.'/')) {
1845-
// no match whatsoever; set it blank
1846-
return '';
1847-
}
1839+
if (empty($basename) || !strpos(rawurldecode($truncatedRequestUri), $basename)) {
1840+
// no match whatsoever; set it blank
1841+
return '';
18481842
}
18491843

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

src/Symfony/Component/HttpFoundation/Tests/RequestTest.php

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1770,8 +1770,8 @@ public function getBaseUrlData()
17701770
'SCRIPT_NAME' => '/foo/app.php',
17711771
'PHP_SELF' => '/foo/app.php',
17721772
],
1773-
'/sub/foo',
1774-
'/bar',
1773+
'',
1774+
'/sub/foo/bar',
17751775
],
17761776
[
17771777
'/sub/foo/app.php/bar',
@@ -1790,8 +1790,18 @@ public function getBaseUrlData()
17901790
'SCRIPT_NAME' => '/foo/app2.phpx',
17911791
'PHP_SELF' => '/foo/app2.phpx',
17921792
],
1793-
'/sub/foo',
1794-
'/bar/baz',
1793+
'',
1794+
'/sub/foo/bar/baz',
1795+
],
1796+
[
1797+
'/foo/api/bar',
1798+
[
1799+
'SCRIPT_FILENAME' => '/home/user/public_html/api/index.php',
1800+
'SCRIPT_NAME' => '/api/index.php',
1801+
'PHP_SELF' => '/api/index.php',
1802+
],
1803+
'',
1804+
'/foo/api/bar',
17951805
],
17961806
];
17971807
}

0 commit comments

Comments
 (0)