Skip to content

Commit 50d07d6

Browse files
authored
Merge pull request #61067 from nextcloud/fix-public-link-mask-ext
fix: use correct permissions mask for non-home storage public links
2 parents 354e26d + 3ee5473 commit 50d07d6

3 files changed

Lines changed: 50 additions & 6 deletions

File tree

apps/dav/appinfo/v2/publicremote.php

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
*/
88
use OC\Files\Filesystem;
99
use OC\Files\Storage\Wrapper\DirPermissionsMask;
10+
use OC\Files\Storage\Wrapper\PermissionsMask;
1011
use OC\Files\View;
1112
use OCA\DAV\Connector\Sabre\PublicAuth;
1213
use OCA\DAV\Connector\Sabre\ServerFactory;
@@ -21,6 +22,7 @@
2122
use OCP\BeforeSabrePubliclyLoadedEvent;
2223
use OCP\Constants;
2324
use OCP\EventDispatcher\IEventDispatcher;
25+
use OCP\Files\IHomeStorage;
2426
use OCP\Files\IRootFolder;
2527
use OCP\Files\Mount\IMountManager;
2628
use OCP\ICacheFactory;
@@ -115,11 +117,15 @@
115117
$mask |= Constants::PERMISSION_READ | Constants::PERMISSION_DELETE;
116118
}
117119

118-
return new DirPermissionsMask([
119-
'storage' => $storage,
120-
'mask' => $mask,
121-
'path' => 'files',
122-
]);
120+
if ($storage instanceof IHomeStorage) {
121+
return new DirPermissionsMask([
122+
'storage' => $storage,
123+
'mask' => $mask,
124+
'path' => 'files',
125+
]);
126+
} else {
127+
return new PermissionsMask(['storage' => $storage, 'mask' => $mask]);
128+
}
123129
});
124130

125131
/** @psalm-suppress MissingClosureParamType */

build/integration/features/bootstrap/WebDav.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,23 @@ public function downloadedContentShouldStartWith($start) {
334334
}
335335
}
336336

337+
/**
338+
* @When Uploading public file :filename with content :content
339+
*/
340+
public function uploadingPublicFile(string $filename, string $content) {
341+
$token = $this->lastShareData->data->token;
342+
$fullUrl = substr($this->baseUrl, 0, -4) . "public.php/dav/files/$token/$filename";
343+
344+
$client = new GClient();
345+
try {
346+
$this->response = $client->request('PUT', $fullUrl, [
347+
'body' => $content
348+
]);
349+
} catch (\GuzzleHttp\Exception\ClientException $e) {
350+
$this->response = $e->getResponse();
351+
}
352+
}
353+
337354
/**
338355
* @Then /^as "([^"]*)" gets properties of (file|folder|entry) "([^"]*)" with$/
339356
* @param string $user

build/integration/sharing_features/sharing-v1.feature

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -556,7 +556,28 @@ Feature: sharing
556556
And Share fields of last share match with
557557
| expiration | +3 days |
558558

559-
Scenario: getting all shares of a user using that user
559+
Scenario: Writing to a read-only link share of an external storage
560+
Given user "user0" exists
561+
Then As an "user0"
562+
When creating a share with
563+
| path | local_storage |
564+
| shareType | 3 |
565+
And the OCS status code should be "100"
566+
And the HTTP status code should be "200"
567+
Then Uploading public file "foo.txt" with content "bar"
568+
And the HTTP status code should be "403"
569+
570+
Scenario: Writing to a read-write link share of an external storage
571+
Given user "user0" exists
572+
Then As an "user0"
573+
When creating a share with
574+
| path | local_storage |
575+
| shareType | 3 |
576+
| permissions | 7 |
577+
Then Uploading public file "foo.txt" with content "bar"
578+
And the HTTP status code should be "201"
579+
580+
Scenario: getting all shares of a user using that user
560581
Given user "user0" exists
561582
And user "user1" exists
562583
When User "user1" deletes file "/textfile0.txt"

0 commit comments

Comments
 (0)