mirror of
https://github.com/phpbb/phpbb.git
synced 2025-07-09 11:24:35 +02:00
Merge pull request #4160 from Nicofuma/ticket/14440
[ticket/14440] Correctly remove the web root path in update_web_root_path
This commit is contained in:
@ -100,11 +100,18 @@ class path_helper
|
|||||||
*/
|
*/
|
||||||
public function update_web_root_path($path)
|
public function update_web_root_path($path)
|
||||||
{
|
{
|
||||||
|
$web_root_path = $this->get_web_root_path();
|
||||||
|
|
||||||
|
// Removes the web root path if it is already present
|
||||||
|
if (strpos($path, $web_root_path) === 0)
|
||||||
|
{
|
||||||
|
$path = $this->phpbb_root_path . substr($path, strlen($web_root_path));
|
||||||
|
}
|
||||||
|
|
||||||
if (strpos($path, $this->phpbb_root_path) === 0)
|
if (strpos($path, $this->phpbb_root_path) === 0)
|
||||||
{
|
{
|
||||||
$path = substr($path, strlen($this->phpbb_root_path));
|
$path = substr($path, strlen($this->phpbb_root_path));
|
||||||
|
|
||||||
$web_root_path = $this->get_web_root_path();
|
|
||||||
if (substr($web_root_path, -8) === 'app.php/' && substr($path, 0, 7) === 'app.php')
|
if (substr($web_root_path, -8) === 'app.php/' && substr($path, 0, 7) === 'app.php')
|
||||||
{
|
{
|
||||||
$path = substr($path, 8);
|
$path = substr($path, 8);
|
||||||
|
@ -135,6 +135,43 @@ class phpbb_path_helper_test extends phpbb_test_case
|
|||||||
'/phpbb3-fork/phpBB/app.php',
|
'/phpbb3-fork/phpBB/app.php',
|
||||||
'./../',
|
'./../',
|
||||||
),
|
),
|
||||||
|
|
||||||
|
// No correction if the path is already prepend by the web root path
|
||||||
|
array(
|
||||||
|
'./../' . $this->phpbb_root_path . 'test.php',
|
||||||
|
'//',
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
'',
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'./../' . $this->phpbb_root_path . 'test.php',
|
||||||
|
'//',
|
||||||
|
'foo/bar.php',
|
||||||
|
'bar.php',
|
||||||
|
'',
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'./../../' . $this->phpbb_root_path . 'test.php',
|
||||||
|
'/foo/template',
|
||||||
|
'/phpbb3-fork/phpBB/app.php/foo/template',
|
||||||
|
'/phpbb3-fork/phpBB/app.php',
|
||||||
|
'',
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'./../' . $this->phpbb_root_path . 'test.php',
|
||||||
|
'/foo/template',
|
||||||
|
'/phpbb3-fork/phpBB/foo/template',
|
||||||
|
'/phpbb3-fork/phpBB/app.php',
|
||||||
|
'',
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'./../'.$this->phpbb_root_path . 'test.php',
|
||||||
|
'/',
|
||||||
|
'/phpbb3-fork/phpBB/app.php/',
|
||||||
|
'/phpbb3-fork/phpBB/app.php',
|
||||||
|
'',
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user