Skip to content

Commit 0dc754b

Browse files
icewind1991solracsf
authored andcommitted
fix: block moving files to it's own parent with dav
Signed-off-by: Robin Appelman <robin@icewind.nl>
1 parent 9196d47 commit 0dc754b

File tree

3 files changed

+25
-0
lines changed

3 files changed

+25
-0
lines changed

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,11 @@ public function checkMove($source, $destination) {
199199
throw new Forbidden($source . " cannot be deleted");
200200
}
201201
}
202+
203+
// The source is not allowed to be the parent of the target
204+
if (str_starts_with($source, $destination . '/')) {
205+
throw new Forbidden($source . ' cannot be moved to it\'s parent');
206+
}
202207
}
203208

204209
/**

build/integration/dav_features/dav-v2.feature

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,16 @@ Feature: dav-v2
99
When User "user0" moves file "/textfile0.txt" to "/FOLDER/textfile0.txt"
1010
Then the HTTP status code should be "201"
1111

12+
Scenario: Moving and overwriting it's parent
13+
Given using new dav path
14+
And As an "admin"
15+
And user "user0" exists
16+
And As an "user0"
17+
And user "user0" created a folder "/test"
18+
And user "user0" created a folder "/test/test"
19+
When User "user0" moves file "/test/test" to "/test"
20+
Then the HTTP status code should be "403"
21+
1222
Scenario: download a file with range using new endpoint
1323
Given using new dav path
1424
And As an "admin"

build/integration/dav_features/webdav-related.feature

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,16 @@ Feature: webdav-related
3636
Then the HTTP status code should be "204"
3737
And Downloaded content when downloading file "/textfile0.txt" with range "bytes=0-6" should be "Welcome"
3838

39+
Scenario: Moving and overwriting it's parent
40+
Given using old dav path
41+
And As an "admin"
42+
And user "user0" exists
43+
And As an "user0"
44+
And user "user0" created a folder "/test"
45+
And user "user0" created a folder "/test/test"
46+
When User "user0" moves file "/test/test" to "/test"
47+
Then the HTTP status code should be "403"
48+
3949
Scenario: Moving a file to a folder with no permissions
4050
Given using old dav path
4151
And As an "admin"

0 commit comments

Comments
 (0)