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
8 changes: 8 additions & 0 deletions lib/private/Files/View.php
Original file line number Diff line number Diff line change
Expand Up @@ -1798,6 +1798,14 @@ public function verifyPath($path, $fileName) {
throw new InvalidPathException($l10n->t('Dot files are not allowed'));
}

$matches = [];

if (preg_match('/' . FileInfo::BLACKLIST_FILES_REGEX . '/', $fileName) !== 0) {
throw new InvalidPathException(
"Can`t upload files with extension {$matches[0]} because these extensions are reserved for internal use."
);
}

if (!\OC::$server->getDatabaseConnection()->allows4ByteCharacters()) {
// verify database - e.g. mysql only 3-byte chars
if (preg_match('%(?:
Expand Down
2 changes: 2 additions & 0 deletions tests/integration/features/bootstrap/WebDav.php
Original file line number Diff line number Diff line change
Expand Up @@ -833,6 +833,8 @@ public function userCreatedAFolder($user, $destination) {
} catch (\GuzzleHttp\Exception\ServerException $e) {
// 4xx and 5xx responses cause an exception
$this->response = $e->getResponse();
} catch (\GuzzleHttp\Exception\ClientException $ex) {
$this->response = $ex->getResponse();
}
}

Expand Down
31 changes: 31 additions & 0 deletions tests/integration/features/webdav-related-new-endpoint.feature
Original file line number Diff line number Diff line change
Expand Up @@ -612,3 +612,34 @@ Feature: webdav-related-new-endpoint
Then as "user0" gets properties of file "/somefile.txt" with
|{http://owncloud.org/ns}privatelink|
And the single response should contain a property "{http://owncloud.org/ns}privatelink" with value like "/(\/index.php\/f\/[0-9]*)/"

Scenario: Copying file to a path with extension .part should not be possible
Given using new dav path
And user "user0" exists
And as an "user0"
When user "user0" copies file "/welcome.txt" to "/welcome.part"
Then the HTTP status code should be "400"

Scenario: Uploading file to path with extension .part should not be possible
Given using new dav path
And user "user0" exists
And as an "user0"
And user "user0" uploads file "data/textfile.txt" to "/textfile.part"
Then the HTTP status code should be "400"

Scenario: Renaming a file to a path with extension .part should not be possible
Given using new dav path
And user "user0" exists
And as an "user0"
When user "user0" moves file "/welcome.txt" to "/welcome.part"
Then the HTTP status code should be "400"
And as an "user0"
When user "user0" moves file "/welcome.txt" to "/welcome.part"
Then the HTTP status code should be "400"

Scenario: Creating a directory which contains .part should not be possible
Given using new dav path
And user "user0" exists
And as an "user0"
When user "user0" created a folder "/folder.with.ext.part"
Then the HTTP status code should be "400"
29 changes: 28 additions & 1 deletion tests/integration/features/webdav-related-old-endpoint.feature
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,6 @@ Feature: webdav-related-old-endpoint
And as "user1" the folder "/folderB/ONE/TWO" exists
And user "user1" checks id of file "/folderB/ONE"


Scenario: Retrieving private link
Given using old dav path
And user "user0" exists
Expand All @@ -528,3 +527,31 @@ Feature: webdav-related-old-endpoint
|{http://owncloud.org/ns}privatelink|
And the single response should contain a property "{http://owncloud.org/ns}privatelink" with value like "/(\/index.php\/f\/[0-9]*)/"

Scenario: Copying file to a path with extension .part should not be possible
Given using old dav path
And user "user0" exists
And as an "user0"
When user "user0" copies file "/welcome.txt" to "/welcome.part"
Then the HTTP status code should be "400"

Scenario: Uploading file to path with extension .part should not be possible
Given using old dav path
And user "user0" exists
And as an "user0"
And user "user0" uploads file "data/textfile.txt" to "/textfile.part"
Then the HTTP status code should be "400"

Scenario: Renaming a file to a path with extension .part should not be possible
Given using old dav path
And user "user0" exists
And as an "user0"
When user "user0" moves file "/welcome.txt" to "/welcome.part"
Then the HTTP status code should be "400"

Scenario: Creating a directory which contains .part should not be possible
Given using new dav path
And user "user0" exists
And as an "user0"
When user "user0" created a folder "/folder.with.ext.part"
Then the HTTP status code should be "400"