diff --git a/lib/Service/Daemon.php b/lib/Service/Daemon.php index c89dea83..4dc9d36f 100644 --- a/lib/Service/Daemon.php +++ b/lib/Service/Daemon.php @@ -159,9 +159,10 @@ class Daemon { if ($cwd === false) { return false; } - $path = substr($cwd, 1)."/".$path; + $path = explode("/", substr($cwd, 1)."/".$path); + } else { + $path = explode("/", substr($path, 1)); } - $path = explode("/", substr($path, 1)); $out = []; foreach ($path as $p) { if ($p === "..") { diff --git a/tests/cases/Service/TestDaemon.php b/tests/cases/Service/TestDaemon.php index 66317dfd..b0842132 100644 --- a/tests/cases/Service/TestDaemon.php +++ b/tests/cases/Service/TestDaemon.php @@ -41,12 +41,18 @@ class TestDaemon extends \JKingWeb\Arsse\Test\AbstractTest { public function providePathResolutions(): iterable { return [ - ["/", "/home/me", "/"], - ["/.", "/home/me", "/"], - ["/..", "/home/me", "/"], - ["/run", "/home/me", "/run"], - ["/./run", "/home/me", "/run"], - ["/../run", "/home/me", "/run"], + ["/", "/home/me", "/"], + ["/.", "/home/me", "/"], + ["/..", "/home/me", "/"], + ["/run", "/home/me", "/run"], + ["/./run", "/home/me", "/run"], + ["/../run", "/home/me", "/run"], + ["/run/../run", "/home/me", "/run"], + ["/run/./run", "/home/me", "/run/run"], + ["run", "/home/me", "/home/me/run"], + ["run/..", "/home/me", "/home/me"], + [".", "/", "/"], + [".", false, false], ]; }