Skip to content

Commit 9dd5691

Browse files
Merge pull request #57368 from nextcloud/backport/57284/stable32
[stable32] fix: allow moving from of non-resharable to other share if the user has delete permissions
2 parents 3c59da6 + 2b1cfa5 commit 9dd5691

2 files changed

Lines changed: 37 additions & 3 deletions

File tree

apps/dav/lib/Connector/Sabre/SharesPlugin.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,14 @@ public function validateMoveOrCopy(string $source, string $target): bool {
262262
return true;
263263
}
264264
}
265+
266+
// if the share recipient is allow to delete from the share, they are allowed to move the file out of the share
267+
// the user moving the file out of the share to their home storage would give them share permissions and allow moving into the share
268+
//
269+
// since the 2-step move is allowed, we also allow both steps at once
270+
if ($sourceNode->isDeletable()) {
271+
return true;
272+
}
265273
}
266274

267275
throw new Forbidden('You cannot move a non-shareable node into a share');

build/integration/sharing_features/sharing-v1-part4.feature

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ Scenario: Cannot copy files from share without share permission into other share
193193
| path | share |
194194
| shareType | 0 |
195195
| shareWith | user1 |
196-
| permissions | 15 |
196+
| permissions | 7 |
197197
Then the HTTP status code should be "200"
198198
And the OCS status code should be "100"
199199
And User "user0" uploads file with content "test" to "/share/test.txt"
@@ -219,7 +219,7 @@ Scenario: Cannot move files from share without share permission into other share
219219
| path | share |
220220
| shareType | 0 |
221221
| shareWith | user1 |
222-
| permissions | 15 |
222+
| permissions | 7 |
223223
Then the HTTP status code should be "200"
224224
And the OCS status code should be "100"
225225
And User "user0" uploads file with content "test" to "/share/test.txt"
@@ -235,6 +235,32 @@ Scenario: Cannot move files from share without share permission into other share
235235
When User "user1" moves file "/share/test.txt" to "/re-share/movetest.txt"
236236
Then the HTTP status code should be "403"
237237

238+
Scenario: Can move files from share without share permission but with delete permissions into other share
239+
Given user "user0" exists
240+
Given user "user1" exists
241+
Given user "user2" exists
242+
And As an "user0"
243+
And user "user0" created a folder "/share"
244+
When creating a share with
245+
| path | share |
246+
| shareType | 0 |
247+
| shareWith | user1 |
248+
| permissions | 15 |
249+
Then the HTTP status code should be "200"
250+
And the OCS status code should be "100"
251+
And User "user0" uploads file with content "test" to "/share/test.txt"
252+
And As an "user1"
253+
And user "user1" created a folder "/re-share"
254+
When creating a share with
255+
| path | re-share |
256+
| shareType | 0 |
257+
| shareWith | user2 |
258+
| permissions | 31 |
259+
Then the HTTP status code should be "200"
260+
And the OCS status code should be "100"
261+
When User "user1" moves file "/share/test.txt" to "/re-share/movetest.txt"
262+
Then the HTTP status code should be "201"
263+
238264
Scenario: Cannot move folder containing share without share permission into other share
239265
Given user "user0" exists
240266
Given user "user1" exists
@@ -245,7 +271,7 @@ Scenario: Cannot move folder containing share without share permission into othe
245271
| path | share |
246272
| shareType | 0 |
247273
| shareWith | user1 |
248-
| permissions | 15 |
274+
| permissions | 7 |
249275
Then the HTTP status code should be "200"
250276
And the OCS status code should be "100"
251277
And User "user0" uploads file with content "test" to "/share/test.txt"

0 commit comments

Comments
 (0)