Merge pull request #5124 from nextcloud/allow-dirlisting-with-unreadable-items

Allow dir-listing also when one child is blocked by access control
This commit is contained in:
Joas Schilling 2017-06-16 10:47:08 +02:00 committed by GitHub
commit 698a7cb7f0
2 changed files with 11 additions and 4 deletions

View File

@ -288,10 +288,16 @@ class FilesPlugin extends ServerPlugin {
$httpRequest = $this->server->httpRequest; $httpRequest = $this->server->httpRequest;
if ($node instanceof \OCA\DAV\Connector\Sabre\Node) { if ($node instanceof \OCA\DAV\Connector\Sabre\Node) {
/**
* This was disabled, because it made dir listing throw an exception,
* so users were unable to navigate into folders where one subitem
* is blocked by the files_accesscontrol app, see:
* https://github.com/nextcloud/files_accesscontrol/issues/65
if (!$node->getFileInfo()->isReadable()) { if (!$node->getFileInfo()->isReadable()) {
// avoid detecting files through this means // avoid detecting files through this means
throw new NotFound(); throw new NotFound();
} }
*/
$propFind->handle(self::FILEID_PROPERTYNAME, function() use ($node) { $propFind->handle(self::FILEID_PROPERTYNAME, function() use ($node) {
return $node->getFileId(); return $node->getFileId();

View File

@ -341,11 +341,12 @@ class FilesPluginTest extends TestCase {
$this->assertEquals('my_fingerprint', $propFind->get(self::DATA_FINGERPRINT_PROPERTYNAME)); $this->assertEquals('my_fingerprint', $propFind->get(self::DATA_FINGERPRINT_PROPERTYNAME));
} }
/**
* @expectedException \Sabre\DAV\Exception\NotFound
*/
public function testGetPropertiesWhenNoPermission() { public function testGetPropertiesWhenNoPermission() {
/** @var \OCA\DAV\Connector\Sabre\Directory | \PHPUnit_Framework_MockObject_MockObject $node */ // No read permissions can be caused by files access control.
// But we still want to load the directory list, so this is okay for us.
// $this->expectException(\Sabre\DAV\Exception\NotFound::class);
/** @var \OCA\DAV\Connector\Sabre\Directory|\PHPUnit_Framework_MockObject_MockObject $node */
$node = $this->getMockBuilder('\OCA\DAV\Connector\Sabre\Directory') $node = $this->getMockBuilder('\OCA\DAV\Connector\Sabre\Directory')
->disableOriginalConstructor() ->disableOriginalConstructor()
->getMock(); ->getMock();