mirror of
https://github.com/Karaka-Management/phpOMS.git
synced 2026-02-10 22:18:40 +00:00
fix handling .. and \ in path string
This commit is contained in:
parent
8e8b40c70e
commit
122d48d493
|
|
@ -109,11 +109,11 @@ final class FileUtils
|
||||||
*/
|
*/
|
||||||
public static function absolute(string $origPath) : string
|
public static function absolute(string $origPath) : string
|
||||||
{
|
{
|
||||||
if (\realpath($origPath) !== false) {
|
if (\file_exists($origPath) !== false) {
|
||||||
return \realpath($origPath);
|
return \realpath($origPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
$startsWithSlash = \strpos($origPath, '/') === 0 ? '/' : '';
|
$startsWithSlash = \strpos($origPath, '/') === 0 || \strpos($origPath, '\\') === 0 ? '/' : '';
|
||||||
|
|
||||||
$path = [];
|
$path = [];
|
||||||
$parts = \explode('/', $origPath);
|
$parts = \explode('/', $origPath);
|
||||||
|
|
@ -123,7 +123,7 @@ final class FileUtils
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($part !== '..') {
|
if ($part !== '..' || empty($path)) {
|
||||||
$path[] = $part;
|
$path[] = $part;
|
||||||
} elseif (!empty($path)) {
|
} elseif (!empty($path)) {
|
||||||
\array_pop($path);
|
\array_pop($path);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user