aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/private/Share20/Manager.php3
-rw-r--r--tests/lib/Share20/ManagerTest.php9
2 files changed, 11 insertions, 1 deletions
diff --git a/lib/private/Share20/Manager.php b/lib/private/Share20/Manager.php
index 5485f049b2e..747960f3b10 100644
--- a/lib/private/Share20/Manager.php
+++ b/lib/private/Share20/Manager.php
@@ -1215,7 +1215,8 @@ class Manager implements IManager {
/* Ignore share of non-existing node */
continue;
}
- if (str_starts_with($path, $node->getPath() . '/') || ($path === $node->getPath())) {
+ if ($node->getRelativePath($path) !== null) {
+ /* If relative path is not null it means the shared node is the same or in a subfolder */
$reshareRecords[] = $share;
}
}
diff --git a/tests/lib/Share20/ManagerTest.php b/tests/lib/Share20/ManagerTest.php
index 2547bdec105..b021498d22e 100644
--- a/tests/lib/Share20/ManagerTest.php
+++ b/tests/lib/Share20/ManagerTest.php
@@ -23,6 +23,7 @@ namespace Test\Share20;
use DateTimeZone;
use OC\Files\Mount\MoveableMount;
+use OC\Files\Utils\PathHelper;
use OC\KnownUser\KnownUserService;
use OC\Share20\DefaultShareProvider;
use OC\Share20\Exception;
@@ -213,6 +214,14 @@ class ManagerTest extends \Test\TestCase {
]);
}
+ private function createFolderMock(string $folderPath): MockObject&Folder {
+ $folder = $this->createMock(Folder::class);
+ $folder->method('getPath')->willReturn($folderPath);
+ $folder->method('getRelativePath')->willReturnCallback(
+ fn (string $path): ?string => PathHelper::getRelativePath($folderPath, $path)
+ );
+ return $folder;
+ }
public function testDeleteNoShareId() {
$this->expectException(\InvalidArgumentException::class);