Skip to content

Commit 923a73d

Browse files
authored
Merge pull request #63383 from nextcloud/backport/63241/stable33
[stable33] fix: Public link with multiple mounts
2 parents 41d5f5e + 12c935d commit 923a73d

3 files changed

Lines changed: 52 additions & 0 deletions

File tree

apps/dav/appinfo/v1/publicwebdav.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,17 @@ function (\Sabre\DAV\Server $server) use (
115115
if (!$node) {
116116
throw new \Sabre\DAV\Exception\NotFound();
117117
}
118+
119+
// getFirstNodeById might return a node without share permission -> try to find a node which is shareable
120+
if (!$node->isShareable()) {
121+
foreach ($userFolder->getById($fileId) as $candidate) {
122+
if ($candidate->isShareable()) {
123+
$node = $candidate;
124+
break;
125+
}
126+
}
127+
}
128+
118129
$linkCheckPlugin->setFileInfo($node);
119130

120131
// If not readable (files_drop) enable the filesdrop plugin

apps/dav/appinfo/v2/publicremote.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,17 @@
149149
if (!$node) {
150150
throw new NotFound();
151151
}
152+
153+
// getFirstNodeById might return a node without share permission -> try to find a node which is shareable
154+
if (!$node->isShareable()) {
155+
foreach ($userFolder->getById($fileId) as $candidate) {
156+
if ($candidate->isShareable()) {
157+
$node = $candidate;
158+
break;
159+
}
160+
}
161+
}
162+
152163
$linkCheckPlugin->setFileInfo($node);
153164

154165
// If not readable (files_drop) enable the filesdrop plugin

build/integration/dav_features/dav-v2-public.feature

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,3 +110,33 @@ Feature: dav-v2-public
110110
Then the downloaded zip file contains a folder named "testFolder/"
111111
And the downloaded zip file contains a file named "testFolder/text.txt" with the contents of "/testshare/testFolder/text.txt" from "user0" data
112112
And the downloaded zip file contains a file named "testFolder/image.png" with the contents of "/testshare/testFolder/image.png" from "user0" data
113+
114+
# After the link share was created the initiator gets a second, read-only path to the
115+
# shared folder. Nodes are ordered by path descending, so "/z-child" is found before
116+
# "/parent/z-child" and the shareable path has to be picked explicitly.
117+
Scenario: Downloading a file from a public share of a folder the initiator can also reach without share permission
118+
Given using new dav path
119+
And As an "admin"
120+
And user "user0" exists
121+
And user "user1" exists
122+
And As an "user0"
123+
And user "user0" created a folder "/parent"
124+
And user "user0" created a folder "/parent/z-child"
125+
And User "user0" uploads file with content "shared content" to "/parent/z-child/text.txt"
126+
And folder "/parent" of user "user0" is shared with user "user1" with permissions 31
127+
And user "user1" accepts last share
128+
And as "user1" creating a share with
129+
| path | parent/z-child |
130+
| shareType | 3 |
131+
| permissions | 1 |
132+
Then the OCS status code should be "100"
133+
And the HTTP status code should be "200"
134+
And save the last share data as "publicLink"
135+
And folder "/parent/z-child" of user "user0" is shared with user "user1" with permissions 1
136+
And user "user1" accepts last share
137+
And restore the last share data from "publicLink"
138+
And As an "user0"
139+
Given using new public dav path
140+
When Downloading public file "/text.txt"
141+
Then the HTTP status code should be "200"
142+
And Downloaded content should be "shared content"

0 commit comments

Comments
 (0)