Skip to content

Commit 754f4e5

Browse files
committed
fix: restore files_accesscontrol functionality within getNodeForPath
This commit adds a workaround to restore the functionality of apps that rely on descending the file-tree to check for access permissions, like files_accesscontrol. The navigation is done navigating the tree upwards, from the target node, to the root node. Signed-off-by: Salvatore Martire <[email protected]>
1 parent cf952ce commit 754f4e5

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

apps/dav/lib/Connector/Sabre/Directory.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -499,6 +499,7 @@ public function getNode(): Folder {
499499

500500
public function getNodeForPath($path) {
501501
$nodeIsRoot = $this->path === '/';
502+
$path = ltrim($path, '/');
502503
$fullPath = $nodeIsRoot ? $this->path . $path : $this->path . '/' . $path;
503504

504505
try {
@@ -518,6 +519,14 @@ public function getNodeForPath($path) {
518519
. ' could not be located');
519520
}
520521

522+
if (!$info->isReadable()) {
523+
if (Server::get(IAppManager::class)->isEnabledForAnyone('files_accesscontrol')) {
524+
throw new Forbidden('No read permissions. This might be caused by files_accesscontrol, check your configured rules');
525+
}
526+
527+
throw new Forbidden('No read permissions');
528+
}
529+
521530
if ($info->getMimeType() === FileInfo::MIMETYPE_FOLDER) {
522531
$node = new \OCA\DAV\Connector\Sabre\Directory($this->fileView, $info, $this->tree, $this->shareManager);
523532
} else {
@@ -529,6 +538,12 @@ public function getNodeForPath($path) {
529538
$node = new File($this->fileView, $info, $this->shareManager);
530539
}
531540
$this->tree?->cacheNode($node);
541+
542+
if ($destinationDir !== '') {
543+
// recurse upwards until the root (for backwards²-compatibility)
544+
$this->getNodeForPath($destinationDir);
545+
}
546+
532547
return $node;
533548
}
534549
}

0 commit comments

Comments
 (0)