Skip to content

Commit 678bf53

Browse files
committed
fix: drop readable check
This check was introduced in a previous PR, causing disruptive changes in PROPFIND responses in some cases. Signed-off-by: Salvatore Martire <[email protected]>
1 parent 22ca454 commit 678bf53

File tree

2 files changed

+9
-22
lines changed

2 files changed

+9
-22
lines changed

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

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -531,15 +531,6 @@ public function getNodeForPath($path): INode {
531531
throw new InvalidPath($ex->getMessage(), false, $ex);
532532
}
533533

534-
// if not in a public share with no read permissions, throw Forbidden
535-
if (!$allowDirectory && !$info->isReadable()) {
536-
if (Server::get(IAppManager::class)->isEnabledForAnyone('files_accesscontrol')) {
537-
throw new Forbidden('No read permissions. This might be caused by files_accesscontrol, check your configured rules');
538-
}
539-
540-
throw new Forbidden('No read permissions');
541-
}
542-
543534
if ($info->getMimeType() === FileInfo::MIMETYPE_FOLDER) {
544535
$node = new \OCA\DAV\Connector\Sabre\Directory($this->fileView, $info, $this->tree, $this->shareManager);
545536
} else {

apps/dav/tests/unit/Connector/Sabre/DirectoryTest.php

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -299,9 +299,6 @@ public function testGetNodeForPath(): void {
299299
$pathNode->expects($this->once())
300300
->method('getPath')
301301
->willReturn('/admin/files/my/deep/folder/');
302-
$pathNode->expects($this->once())
303-
->method('isReadable')
304-
->willReturn(true);
305302
$pathNode->expects($this->once())
306303
->method('getMimetype')
307304
->willReturn(FileInfo::MIMETYPE_FOLDER);
@@ -352,9 +349,6 @@ public function testGetNodeForPathFailsWithNoReadPermissionsForParent(): void {
352349
$pathNode->expects($this->once())
353350
->method('getPath')
354351
->willReturn('/admin/files/my/deep/folder/');
355-
$pathNode->expects($this->once())
356-
->method('isReadable')
357-
->willReturn(true);
358352
$pathNode->expects($this->once())
359353
->method('getMimetype')
360354
->willReturn(FileInfo::MIMETYPE_FOLDER);
@@ -393,21 +387,23 @@ public function testGetNodeForPathFailsWithNoReadPermissionsForPath(): void {
393387
->method('instanceOfStorage')
394388
->willReturn(false);
395389

396-
$directoryNode->expects($this->once())
390+
$invokedCount = $this->exactly(2);
391+
$directoryNode->expects($invokedCount)
397392
->method('isReadable')
398-
->willReturn(true);
393+
->willReturnCallback(function () use ($invokedCount) {
394+
return match ($invokedCount->numberOfInvocations()) {
395+
1 => true,
396+
2 => false,
397+
};
398+
});
399399
$directoryNode->expects($this->once())
400400
->method('getPath')
401401
->willReturn('/admin/files/');
402402
$directoryNode->expects($this->once())
403403
->method('get')
404404
->willReturn($pathNode);
405405

406-
$pathNode->expects($this->once())
407-
->method('isReadable')
408-
->willReturn(false);
409-
410-
$this->expectException(\Sabre\DAV\Exception\Forbidden::class);
406+
$this->expectException(\Sabre\DAV\Exception\NotFound::class);
411407

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

0 commit comments

Comments
 (0)