Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Revert "Check share attributes on preview endpoints"
This reverts commit d7c237c.
  • Loading branch information
Jerome-Herbinet committed Oct 28, 2022
commit c7ce8e93df09faaf7f5a64b381535f1df6ba43f9
10 changes: 0 additions & 10 deletions apps/files_sharing/lib/Controller/PublicPreviewController.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,6 @@ public function getPreview(
return new DataResponse([], Http::STATUS_FORBIDDEN);
}

$attributes = $share->getAttributes();
if ($attributes !== null && $attributes->getAttribute('permissions', 'download') === false) {
return new DataResponse([], Http::STATUS_FORBIDDEN);
}

try {
$node = $share->getNode();
if ($node instanceof Folder) {
Expand Down Expand Up @@ -164,11 +159,6 @@ public function directLink(string $token) {
return new DataResponse([], Http::STATUS_FORBIDDEN);
}

$attributes = $share->getAttributes();
if ($attributes !== null && $attributes->getAttribute('permissions', 'download') === false) {
return new DataResponse([], Http::STATUS_FORBIDDEN);
}

try {
$node = $share->getNode();
if ($node instanceof Folder) {
Expand Down
11 changes: 0 additions & 11 deletions core/Controller/PreviewController.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
*/
namespace OC\Core\Controller;

use OCA\Files_Sharing\SharedStorage;
use OCP\AppFramework\Controller;
use OCP\AppFramework\Http;
use OCP\AppFramework\Http\DataResponse;
Expand Down Expand Up @@ -130,16 +129,6 @@ private function fetchPreview(
return new DataResponse([], Http::STATUS_FORBIDDEN);
}

$storage = $node->getStorage();
if ($storage->instanceOfStorage(SharedStorage::class)) {
/** @var SharedStorage $storage */
$share = $storage->getShare();
$attributes = $share->getAttributes();
if ($attributes !== null && $attributes->getAttribute('permissions', 'download') === false) {
return new DataResponse([], Http::STATUS_FORBIDDEN);
}
}

try {
$f = $this->preview->getPreview($node, $x, $y, !$a, $mode);
$response = new FileDisplayResponse($f, Http::STATUS_OK, [
Expand Down
9 changes: 0 additions & 9 deletions tests/Core/Controller/PreviewControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
use OCP\Files\IRootFolder;
use OCP\Files\NotFoundException;
use OCP\Files\SimpleFS\ISimpleFile;
use OCP\Files\Storage\IStorage;
use OCP\IPreview;
use OCP\IRequest;

Expand Down Expand Up @@ -177,10 +176,6 @@ public function testNoPreview() {
->with($this->equalTo('file'))
->willReturn($file);

$storage = $this->createMock(IStorage::class);
$file->method('getStorage')
->willReturn($storage);

$this->previewManager->method('isAvailable')
->with($this->equalTo($file))
->willReturn(true);
Expand Down Expand Up @@ -216,10 +211,6 @@ public function testValidPreview() {
$file->method('isReadable')
->willReturn(true);

$storage = $this->createMock(IStorage::class);
$file->method('getStorage')
->willReturn($storage);

$preview = $this->createMock(ISimpleFile::class);
$preview->method('getName')->willReturn('my name');
$preview->method('getMTime')->willReturn(42);
Expand Down