From 73c6b17fae9df158c478c4f6c17efa1e25e2c5bb Mon Sep 17 00:00:00 2001 From: Louis Chmn Date: Thu, 6 Nov 2025 10:57:19 +0100 Subject: [PATCH] fix(View): Normalize path in `getAbsolutePath` This allow to match files more consistently in HookConnector::getNodeForPath Signed-off-by: Louis Chmn --- lib/private/Files/View.php | 9 ++------- tests/lib/Files/ViewTest.php | 4 ++-- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/lib/private/Files/View.php b/lib/private/Files/View.php index ecf2f438edb..c1068d2349b 100644 --- a/lib/private/Files/View.php +++ b/lib/private/Files/View.php @@ -11,6 +11,7 @@ use Icewind\Streams\CallbackWrapper; use OC\Files\Mount\MoveableMount; use OC\Files\Storage\Storage; use OC\Files\Storage\Wrapper\Quota; +use OC\Files\Utils\PathHelper; use OC\Share\Share; use OC\User\LazyUser; use OC\User\Manager as UserManager; @@ -92,13 +93,7 @@ class View { return null; } $this->assertPathLength($path); - if ($path === '') { - $path = '/'; - } - if ($path[0] !== '/') { - $path = '/' . $path; - } - return $this->fakeRoot . $path; + return PathHelper::normalizePath($this->fakeRoot . '/' . $path); } /** diff --git a/tests/lib/Files/ViewTest.php b/tests/lib/Files/ViewTest.php index 57424107401..b9f6b1a7373 100644 --- a/tests/lib/Files/ViewTest.php +++ b/tests/lib/Files/ViewTest.php @@ -917,11 +917,11 @@ class ViewTest extends \Test\TestCase { public static function absolutePathProvider(): array { return [ - ['/files/', ''], + ['/files', ''], ['/files/0', '0'], ['/files/false', 'false'], ['/files/true', 'true'], - ['/files/', '/'], + ['/files', '/'], ['/files/test', 'test'], ['/files/test', '/test'], ];