diff --git a/lib/private/Share20/DefaultShareProvider.php b/lib/private/Share20/DefaultShareProvider.php index 17c6e9d572b1e..3a69c15eba509 100644 --- a/lib/private/Share20/DefaultShareProvider.php +++ b/lib/private/Share20/DefaultShareProvider.php @@ -47,6 +47,7 @@ use OCP\Util; use Psr\Log\LoggerInterface; use function str_starts_with; +use function strlen; /** * Class DefaultShareProvider @@ -869,7 +870,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 !== '') {