1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-08-06 16:56:44 +02:00

[ticket/17201] Split off logic into function and add tests

PHPBB3-17201
This commit is contained in:
Marc Alexander
2023-10-23 21:10:53 +02:00
parent 607a2c483a
commit 593c4b875c
3 changed files with 94 additions and 14 deletions

View File

@@ -51,22 +51,10 @@ if (!defined('PHPBB_INSTALLED'))
$server_port = 443;
}
$script_name = (!empty($_SERVER['REQUEST_URI'])) ? $_SERVER['REQUEST_URI'] : getenv('REQUEST_URI');
if (!$script_name)
{
$script_name = (!empty($_SERVER['PHP_SELF'])) ? $_SERVER['PHP_SELF'] : getenv('PHP_SELF');
}
$script_name = substr($script_name, -1) === '/' ? $script_name . '.' : $script_name;
// $phpbb_root_path accounts for redirects from e.g. /adm
$script_path = trim(dirname($script_name)) . '/' . $phpbb_root_path . 'install/app.' . $phpEx;
// Replace any number of consecutive backslashes and/or slashes with a single slash
// (could happen on some proxy setups and/or Windows servers)
$script_path = preg_replace('#[\\\\/]{2,}#', '/', $script_path);
$script_path = phpbb_get_install_redirect($phpbb_root_path, $phpEx);
// Eliminate . and .. from the path
require($phpbb_root_path . 'phpbb/filesystem.' . $phpEx);
require($phpbb_root_path . 'phpbb/filesystem/filesystem.' . $phpEx);
$phpbb_filesystem = new phpbb\filesystem\filesystem();
$script_path = $phpbb_filesystem->clean_path($script_path);