From 51107a7bb52f0d6d158020fe96ccdd94f458106b Mon Sep 17 00:00:00 2001 From: Vincent Petry Date: Thu, 10 Feb 2022 09:50:21 +0100 Subject: [PATCH] Fix path handling when transferring incoming shares When transferring incoming shares from a guest user without specifying a path, the $path is empty. The fix properly handles that situation to avoid looking for shares in a path with doubled slashes which failed to find shares to transfer. Signed-off-by: Vincent Petry --- apps/files/lib/Service/OwnershipTransferService.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/apps/files/lib/Service/OwnershipTransferService.php b/apps/files/lib/Service/OwnershipTransferService.php index 93a3a188399..670e6419d75 100644 --- a/apps/files/lib/Service/OwnershipTransferService.php +++ b/apps/files/lib/Service/OwnershipTransferService.php @@ -444,13 +444,17 @@ class OwnershipTransferService { $output->writeln("Restoring incoming shares ..."); $progress = new ProgressBar($output, count($sourceShares)); $prefix = "$destinationUid/files"; + $finalShareTarget = ''; if (substr($finalTarget, 0, strlen($prefix)) === $prefix) { $finalShareTarget = substr($finalTarget, strlen($prefix)); } foreach ($sourceShares as $share) { try { // Only restore if share is in given path. - $pathToCheck = '/' . trim($path) . '/'; + $pathToCheck = '/'; + if (trim($path, '/') !== '') { + $pathToCheck = '/' . trim($path) . '/'; + } if (substr($share->getTarget(), 0, strlen($pathToCheck)) !== $pathToCheck) { continue; } -- 2.39.5