mirror of
https://github.com/Karaka-Management/phpOMS.git
synced 2026-01-11 17:58:41 +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
|
||||
{
|
||||
if (\realpath($origPath) !== false) {
|
||||
if (\file_exists($origPath) !== false) {
|
||||
return \realpath($origPath);
|
||||
}
|
||||
|
||||
$startsWithSlash = \strpos($origPath, '/') === 0 ? '/' : '';
|
||||
$startsWithSlash = \strpos($origPath, '/') === 0 || \strpos($origPath, '\\') === 0 ? '/' : '';
|
||||
|
||||
$path = [];
|
||||
$parts = \explode('/', $origPath);
|
||||
|
|
@ -123,7 +123,7 @@ final class FileUtils
|
|||
continue;
|
||||
}
|
||||
|
||||
if ($part !== '..') {
|
||||
if ($part !== '..' || empty($path)) {
|
||||
$path[] = $part;
|
||||
} elseif (!empty($path)) {
|
||||
\array_pop($path);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user