Skip to content

Commit b6659e7

Browse files
Merge pull request #2367 from nextcloud/fix/58333/user-files-replace
2 parents f630acb + 705d6ec commit b6659e7

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)