config file setup instructions
[phorkie.git] / src / phorkie / Tools.php
index 7c9c46eb84a540709c52cc6932b5329095c68204..7819cda77efb956bf6cf35ae58a20c9398c12a23 100644 (file)
@@ -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;
+    }
 }
 ?>