Merge pull request #44362 from nextcloud/artonge/feat/check_permissions_of_all_nodes_for_versions

Check permissions of all accessible file for versions
pull/44427/head
Louis 2 months ago committed by GitHub
commit ddb84f9738
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -275,15 +275,23 @@ class LegacyVersionsBackend implements IVersionBackend, IDeletableVersionBackend
throw new NotFoundException("No user logged in");
}
if ($sourceFile->getOwner()?->getUID() !== $currentUserId) {
$nodes = $this->rootFolder->getUserFolder($currentUserId)->getById($sourceFile->getId());
$sourceFile = array_pop($nodes);
if (!$sourceFile) {
throw new NotFoundException("Version file not accessible by current user");
if ($sourceFile->getOwner()?->getUID() === $currentUserId) {
return ($sourceFile->getPermissions() & $permissions) === $permissions;
}
$nodes = $this->rootFolder->getUserFolder($currentUserId)->getById($sourceFile->getId());
if (count($nodes) === 0) {
throw new NotFoundException("Version file not accessible by current user");
}
foreach ($nodes as $node) {
if (($node->getPermissions() & $permissions) === $permissions) {
return true;
}
}
return ($sourceFile->getPermissions() & $permissions) === $permissions;
return false;
}
public function setMetadataValue(Node $node, int $revision, string $key, string $value): void {

Loading…
Cancel
Save