Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 0 additions & 9 deletions apps/dav/lib/Connector/Sabre/Directory.php
Original file line number Diff line number Diff line change
Expand Up @@ -531,15 +531,6 @@ public function getNodeForPath($path): INode {
throw new InvalidPath($ex->getMessage(), false, $ex);
}

// if not in a public share with no read permissions, throw Forbidden
if (!$allowDirectory && !$info->isReadable()) {
if (Server::get(IAppManager::class)->isEnabledForAnyone('files_accesscontrol')) {
throw new Forbidden('No read permissions. This might be caused by files_accesscontrol, check your configured rules');
}

throw new Forbidden('No read permissions');
}

if ($info->getMimeType() === FileInfo::MIMETYPE_FOLDER) {
$node = new \OCA\DAV\Connector\Sabre\Directory($this->fileView, $info, $this->tree, $this->shareManager);
} else {
Expand Down
22 changes: 9 additions & 13 deletions apps/dav/tests/unit/Connector/Sabre/DirectoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -299,9 +299,6 @@ public function testGetNodeForPath(): void {
$pathNode->expects($this->once())
->method('getPath')
->willReturn('/admin/files/my/deep/folder/');
$pathNode->expects($this->once())
->method('isReadable')
->willReturn(true);
$pathNode->expects($this->once())
->method('getMimetype')
->willReturn(FileInfo::MIMETYPE_FOLDER);
Expand Down Expand Up @@ -352,9 +349,6 @@ public function testGetNodeForPathFailsWithNoReadPermissionsForParent(): void {
$pathNode->expects($this->once())
->method('getPath')
->willReturn('/admin/files/my/deep/folder/');
$pathNode->expects($this->once())
->method('isReadable')
->willReturn(true);
$pathNode->expects($this->once())
->method('getMimetype')
->willReturn(FileInfo::MIMETYPE_FOLDER);
Expand Down Expand Up @@ -393,21 +387,23 @@ public function testGetNodeForPathFailsWithNoReadPermissionsForPath(): void {
->method('instanceOfStorage')
->willReturn(false);

$directoryNode->expects($this->once())
$invokedCount = $this->exactly(2);
$directoryNode->expects($invokedCount)
->method('isReadable')
->willReturn(true);
->willReturnCallback(function () use ($invokedCount) {
return match ($invokedCount->numberOfInvocations()) {
1 => true,
2 => false,
};
});
$directoryNode->expects($this->once())
->method('getPath')
->willReturn('/admin/files/');
$directoryNode->expects($this->once())
->method('get')
->willReturn($pathNode);

$pathNode->expects($this->once())
->method('isReadable')
->willReturn(false);

$this->expectException(\Sabre\DAV\Exception\Forbidden::class);
$this->expectException(\Sabre\DAV\Exception\NotFound::class);

$dir = new Directory($this->view, $directoryNode);
$dir->getNodeForPath('/my/deep/folder/');
Expand Down
Loading