1
0
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:
Joas Schilling
2013-04-17 17:45:49 +02:00
parent 1fd5be859e
commit 869e00a23b
4 changed files with 68 additions and 38 deletions

View File

@@ -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
/**