diff --git a/lib/Db/ShareWrapperRequest.php b/lib/Db/ShareWrapperRequest.php index 4e033fe72..dbfff3ba7 100644 --- a/lib/Db/ShareWrapperRequest.php +++ b/lib/Db/ShareWrapperRequest.php @@ -24,6 +24,7 @@ use OCP\Share\Exceptions\IllegalIDChangeException; use OCP\Share\IAttributes; use OCP\Share\IShare; +use function strlen; /** * Class ShareWrapperRequest @@ -383,10 +384,13 @@ public function getSharedWithByPath( $qb->limitNull('parent', false); $childAlias = $qb->leftJoinShareChild(CoreQueryBuilder::SHARE); + $userId = $federatedUser->getUserId(); + if (str_starts_with($path, '/' . $userId . '/files')) { + $path = substr($path, strlen('/' . $userId . '/files')); + } + $path = rtrim($path, '/'); + if ($forChildren) { - $userId = $federatedUser->getUserId(); - $path = str_replace('/' . $userId . '/files', '', $path); - $path = rtrim($path, '/'); $childPathTemplate = $this->getQueryBuilder()->getConnection()->escapeLikeParameter($path) . '/_%'; $qb->limitToFileTargetLike($childPathTemplate, $childAlias);