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
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
use OCP\AppFramework\Http\Attribute\OpenAPI;
use OCP\AppFramework\Http\Attribute\PublicPage;
use OCP\AppFramework\Http\JSONResponse;
use OCP\Constants;
use OCP\Federation\ICloudIdManager;
use OCP\HintException;
use OCP\Http\Client\IClientService;
Expand Down Expand Up @@ -107,9 +106,9 @@ public function createFederatedShare($shareWith, $token, $password = '') {
return $response;
}

if (($share->getPermissions() & Constants::PERMISSION_READ) === 0) {
if (!$share->canDownload()) {
$response = new JSONResponse(
['message' => 'Mounting file drop not supported'],
['message' => 'Mounting download restricted share is not allowed'],
Http::STATUS_BAD_REQUEST
);
$response->throttle();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ public function renderPage(IShare $share, string $token, string $path): Template

// Create the header action menu
$headerActions = [];
if ($view !== 'public-file-drop' && !$share->getHideDownload()) {
if ($share->canDownload() && !$share->getHideDownload()) {
// The download URL is used for the "download" header action as well as in some cases for the direct link
$downloadUrl = $this->urlGenerator->getAbsoluteURL('/public.php/dav/files/' . $token . '/?accept=zip');

Expand Down
14 changes: 14 additions & 0 deletions lib/private/Share20/Share.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
*/
namespace OC\Share20;

use OCP\Constants;
use OCP\Files\Cache\ICacheEntry;
use OCP\Files\File;
use OCP\Files\FileInfo;
Expand Down Expand Up @@ -622,4 +623,17 @@ public function setReminderSent(bool $reminderSent): IShare {
public function getReminderSent(): bool {
return $this->reminderSent;
}

public function canDownload(): bool {
if (($this->getPermissions() & Constants::PERMISSION_READ) === 0) {
return false;
}

$attributes = $this->getAttributes();
if ($attributes?->getAttribute('permissions', 'download') === false) {
return false;
}

return true;
}
}
7 changes: 7 additions & 0 deletions lib/public/Share/IShare.php
Original file line number Diff line number Diff line change
Expand Up @@ -633,4 +633,11 @@ public function setReminderSent(bool $reminderSent): IShare;
* @since 31.0.0
*/
public function getReminderSent(): bool;

/**
* Check if it is allowed to download this share.
*
* @since 31.0.15
*/
public function canDownload(): bool;
}
Loading