mirror of
https://github.com/phpbb/phpbb.git
synced 2025-07-28 20:40:24 +02:00
[ticket/11362] Move phpbb_clean_path into a simple filesystem service
PHPBB3-11362
This commit is contained in:
@@ -1046,36 +1046,6 @@ else
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Eliminates useless . and .. components from specified path.
|
||||
*
|
||||
* @param string $path Path to clean
|
||||
* @return string Cleaned path
|
||||
*/
|
||||
function phpbb_clean_path($path)
|
||||
{
|
||||
$exploded = explode('/', $path);
|
||||
$filtered = array();
|
||||
foreach ($exploded as $part)
|
||||
{
|
||||
if ($part === '.' && !empty($filtered))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($part === '..' && !empty($filtered) && $filtered[sizeof($filtered) - 1] !== '..')
|
||||
{
|
||||
array_pop($filtered);
|
||||
}
|
||||
else
|
||||
{
|
||||
$filtered[] = $part;
|
||||
}
|
||||
}
|
||||
$path = implode('/', $filtered);
|
||||
return $path;
|
||||
}
|
||||
|
||||
// functions used for building option fields
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user