diff --git a/lib/private/Share20/DefaultShareProvider.php b/lib/private/Share20/DefaultShareProvider.php index 8fc15fd8c0d54..d56086ec3ad0b 100644 --- a/lib/private/Share20/DefaultShareProvider.php +++ b/lib/private/Share20/DefaultShareProvider.php @@ -40,6 +40,7 @@ use OCP\Share\IShareProviderWithNotification; use Psr\Log\LoggerInterface; use function str_starts_with; +use function strlen; /** * Class DefaultShareProvider @@ -862,7 +863,10 @@ private function _getSharedWith( $nonChildPath = '/'; if ($path !== null) { - $path = str_replace('/' . $userId . '/files', '', $path); + $prefix = '/' . $userId . '/files'; + if (str_starts_with($path, $prefix)) { + $path = substr($path, strlen($prefix)); + } $path = rtrim($path, '/'); if ($path !== '') {