Skip to content

Commit 272dc6a

Browse files
salmart-devbackportbot[bot]
authored andcommitted
fix: remove user part only at the beginning of path
Signed-off-by: Salvatore Martire <4652631+salmart-dev@users.noreply.github.com>
1 parent f49c755 commit 272dc6a

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

lib/Db/ShareWrapperRequest.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
use OCP\Share\Exceptions\IllegalIDChangeException;
2525
use OCP\Share\IAttributes;
2626
use OCP\Share\IShare;
27+
use function strlen;
2728

2829
/**
2930
* Class ShareWrapperRequest
@@ -383,10 +384,14 @@ public function getSharedWithByPath(
383384
$qb->limitNull('parent', false);
384385
$childAlias = $qb->leftJoinShareChild(CoreQueryBuilder::SHARE);
385386

387+
$userId = $federatedUser->getUserId();
388+
$prefix = '/' . $userId . '/files';
389+
if (str_starts_with($path, $prefix)) {
390+
$path = substr($path, strlen($prefix));
391+
}
392+
$path = rtrim($path, '/');
393+
386394
if ($forChildren) {
387-
$userId = $federatedUser->getUserId();
388-
$path = str_replace('/' . $userId . '/files', '', $path);
389-
$path = rtrim($path, '/');
390395
$childPathTemplate = $this->getQueryBuilder()->getConnection()->escapeLikeParameter($path) . '/_%';
391396

392397
$qb->limitToFileTargetLike($childPathTemplate, $childAlias);

0 commit comments

Comments
 (0)