From f8d7ebed0bf132ef4c3801e7ed75a8d133fc9ef9 Mon Sep 17 00:00:00 2001 From: Daniel Seifert Date: Thu, 4 May 2023 15:03:37 +0200 Subject: [PATCH] minify url --- Application/fileman/php/functions.inc.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/Application/fileman/php/functions.inc.php b/Application/fileman/php/functions.inc.php index 8d2faed..4c7bcac 100755 --- a/Application/fileman/php/functions.inc.php +++ b/Application/fileman/php/functions.inc.php @@ -90,6 +90,12 @@ function verifyPath(string $path): void function fixPath(string $path): string { $path = dirname($_SERVER['SCRIPT_FILENAME']) . '/../../../../../../' . $path; + + $re = '/\/[^\/.]*\/\.\.\//mU'; + while(preg_match($re, $path)) { + $path = preg_replace($re, "/", $path); + } + $path = str_replace('\\', '/', $path); $path = RoxyFile::FixPath($path); return $path; @@ -166,7 +172,7 @@ class RoxyFile } /** - * @param $path + * @param string $path * @return bool */ public static function CreatePath(string $path): bool @@ -174,8 +180,9 @@ class RoxyFile if (is_dir($path)) { return true; } + $prev_path = substr($path, 0, strrpos($path, '/', -2) + 1); - $return = self::createPath($prev_path); + $return = self::CreatePath( $prev_path); return $return && is_writable($prev_path) && mkdir($path); }