Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
fix: block moving files to it's own parent with dav
Signed-off-by: Robin Appelman <[email protected]>
  • Loading branch information
icewind1991 authored and solracsf committed Jan 9, 2025
commit 0dc754bb000499a39b8d2ae82b9d775899dc3fe0
5 changes: 5 additions & 0 deletions apps/dav/lib/Connector/Sabre/FilesPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,11 @@ public function checkMove($source, $destination) {
throw new Forbidden($source . " cannot be deleted");
}
}

// The source is not allowed to be the parent of the target
if (str_starts_with($source, $destination . '/')) {
throw new Forbidden($source . ' cannot be moved to it\'s parent');
}
}

/**
Expand Down
10 changes: 10 additions & 0 deletions build/integration/dav_features/dav-v2.feature
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,16 @@ Feature: dav-v2
When User "user0" moves file "/textfile0.txt" to "/FOLDER/textfile0.txt"
Then the HTTP status code should be "201"

Scenario: Moving and overwriting it's parent
Given using new dav path
And As an "admin"
And user "user0" exists
And As an "user0"
And user "user0" created a folder "/test"
And user "user0" created a folder "/test/test"
When User "user0" moves file "/test/test" to "/test"
Then the HTTP status code should be "403"

Scenario: download a file with range using new endpoint
Given using new dav path
And As an "admin"
Expand Down
10 changes: 10 additions & 0 deletions build/integration/dav_features/webdav-related.feature
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,16 @@ Feature: webdav-related
Then the HTTP status code should be "204"
And Downloaded content when downloading file "/textfile0.txt" with range "bytes=0-6" should be "Welcome"

Scenario: Moving and overwriting it's parent
Given using old dav path
And As an "admin"
And user "user0" exists
And As an "user0"
And user "user0" created a folder "/test"
And user "user0" created a folder "/test/test"
When User "user0" moves file "/test/test" to "/test"
Then the HTTP status code should be "403"

Scenario: Moving a file to a folder with no permissions
Given using old dav path
And As an "admin"
Expand Down
Loading