@@ -80,30 +80,26 @@ public function checkViewOnly(RequestInterface $request): bool {
8080 }
8181
8282 $ storage = $ node ->getStorage ();
83-
8483 if (!$ storage ->instanceOfStorage (ISharedStorage::class)) {
8584 return true ;
8685 }
8786
88- // Extract extra permissions
8987 /** @var ISharedStorage $storage */
9088 $ share = $ storage ->getShare ();
91- $ attributes = $ share ->getAttributes ();
92- if ($ attributes === null ) {
93- return true ;
94- }
95-
96- // We have two options here, if download is disabled, but viewing is allowed,
97- // we still allow the GET request to return the file content.
98- $ canDownload = $ attributes ->getAttribute ('permissions ' , 'download ' );
99- if (!$ share ->canSeeContent ()) {
100- throw new Forbidden ('Access to this shared resource has been denied because its download permission is disabled. ' );
101- }
102-
103- // If download is disabled, we disable the COPY and MOVE methods even if the
104- // shareapi_allow_view_without_download is set to true.
105- if ($ request ->getMethod () !== 'GET ' && ($ canDownload !== null && !$ canDownload )) {
106- throw new Forbidden ('Access to this shared resource has been denied because its download permission is disabled. ' );
89+ switch ($ request ->getMethod ()) {
90+ case 'GET ' :
91+ // If download is disabled, but viewing is allowed, we still allow the GET method to return the file content.
92+ if (!$ share ->canSeeContent ()) {
93+ throw new Forbidden ('Access to this shared resource has been denied because its download permission is disabled. ' );
94+ }
95+ break ;
96+ case 'COPY ' :
97+ case 'MOVE ' :
98+ // If download is disabled, we disable the COPY and MOVE methods even if the shareapi_allow_view_without_download is set to true.
99+ if (!$ share ->canDownload ()) {
100+ throw new Forbidden ('Access to this shared resource has been denied because its download permission is disabled. ' );
101+ }
102+ break ;
107103 }
108104 } catch (NotFound $ e ) {
109105 // File not found
0 commit comments