From f6e177a89832ba36409ac845eb72522e051bb0f3 Mon Sep 17 00:00:00 2001 From: Christian Weiske Date: Fri, 4 Jul 2014 18:25:01 +0200 Subject: config file setup instructions --- src/phorkie/Tools.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src/phorkie/Tools.php') diff --git a/src/phorkie/Tools.php b/src/phorkie/Tools.php index 7c9c46e..7819cda 100644 --- a/src/phorkie/Tools.php +++ b/src/phorkie/Tools.php @@ -96,5 +96,17 @@ class Tools return '/'; } + + /** + * Resolves "/../" and "/./" in file paths without validating them. + */ + public static function foldPath($path) + { + $path = str_replace('/./', '/', $path); + $path = str_replace('/./', '/', $path); + $path = preg_replace('#/[^/]+/\.\./#', '/', $path); + $path = preg_replace('#/[^/]+/\.\./#', '/', $path); + return $path; + } } ?> -- cgit v1.2.3