mirror of
https://github.com/phpbb/phpbb.git
synced 2025-03-18 22:50:29 +01:00
[ticket/16639] Pass absolute paths to make_path_relative
PHPBB3-16639
This commit is contained in:
parent
c6a202bdb3
commit
3a5a19bd99
@ -600,7 +600,7 @@ class filesystem implements filesystem_interface
|
||||
*
|
||||
* @deprecated 3.3.0-a1 (To be removed: 4.0.0)
|
||||
*
|
||||
* @param string $path
|
||||
* @param ?string $path
|
||||
* @return bool|string
|
||||
*/
|
||||
protected function phpbb_own_realpath($path)
|
||||
|
@ -239,7 +239,7 @@ interface filesystem_interface
|
||||
* Try to resolve realpath when PHP's realpath is not available, or
|
||||
* known to be buggy.
|
||||
*
|
||||
* @param string $path Path to resolve
|
||||
* @param ?string $path Path to resolve
|
||||
*
|
||||
* @return string Resolved path
|
||||
*/
|
||||
|
@ -230,8 +230,9 @@ class local implements adapter_interface, stream_interface
|
||||
*/
|
||||
protected function ensure_directory_exists($path)
|
||||
{
|
||||
$path = dirname($this->root_path . $this->get_path($path) . $this->get_filename($path));
|
||||
$path = filesystem_helper::make_path_relative($path, $this->root_path);
|
||||
$absolute_root_path = filesystem_helper::realpath($this->root_path) . DIRECTORY_SEPARATOR;
|
||||
$path = dirname($absolute_root_path . $this->get_path($path) . $this->get_filename($path));
|
||||
$path = filesystem_helper::make_path_relative($path, $absolute_root_path);
|
||||
|
||||
if (!$this->exists($path))
|
||||
{
|
||||
@ -254,11 +255,11 @@ class local implements adapter_interface, stream_interface
|
||||
|
||||
do
|
||||
{
|
||||
$parts = explode('/', $path);
|
||||
$parts = explode(DIRECTORY_SEPARATOR, $path);
|
||||
$parts = array_slice($parts, 0, -1);
|
||||
$path = implode('/', $parts);
|
||||
$path = implode(DIRECTORY_SEPARATOR, $parts);
|
||||
}
|
||||
while ($path && @rmdir($dirpath . '/' . $path));
|
||||
while ($path && @rmdir($dirpath . DIRECTORY_SEPARATOR . $path));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -42,6 +42,7 @@ class phpbb_filesystem_realpath_test extends phpbb_test_case
|
||||
array(__DIR__ . '/../filesystem/../filesystem', __DIR__),
|
||||
array(__DIR__ . '/././', __DIR__),
|
||||
array(__DIR__ . '/non_existent', false),
|
||||
array(null, getcwd()),
|
||||
|
||||
array(__FILE__, __FILE__),
|
||||
array(__FILE__ . '../', false),
|
||||
|
Loading…
x
Reference in New Issue
Block a user