Merge pull request #44297 from nextcloud/fix/forbid-tagging-readonly-files

Forbid tagging readonly files

Signed-off-by: Louis Chemineau <louis@chmn.me>
pull/44362/head
Louis Chemineau 2 months ago
parent 67b9b34857
commit a15c0d6515
No known key found for this signature in database

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