Merge pull request #31203 from nextcloud/backport/31097/stable22

[stable22] Fix path handling when transferring incoming shares
This commit is contained in:
Louis 2022-02-16 12:31:52 +01:00 committed by GitHub
commit 4cd26d47c3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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;
}