Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[stable10] Fix check new dav rename target path name #28737

Merged
merged 4 commits into from
Aug 18, 2017
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
15 changes: 13 additions & 2 deletions apps/dav/lib/Connector/Sabre/Node.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,11 +126,22 @@ public function setName($name) {
throw new \Sabre\DAV\Exception\Forbidden();
}

// verify path of the source
$this->verifyPath();

list($parentPath,) = \Sabre\HTTP\URLUtil::splitPath($this->path);
list(, $newName) = \Sabre\HTTP\URLUtil::splitPath($name);

// verify path of the target
$this->verifyPath();
// verify path of target
if (\OC\Files\Filesystem::isForbiddenFileOrDir($parentPath . '/' . $newName)) {
throw new \Sabre\DAV\Exception\Forbidden();
}

try {
$this->fileView->verifyPath($parentPath, $newName);
} catch (\OCP\Files\InvalidPathException $ex) {
throw new InvalidPath($ex->getMessage());
}

$newPath = $parentPath . '/' . $newName;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ Feature: webdav-related-new-endpoint
When User "user0" moves file "/welcome.txt" to "/a\\a"
Then the HTTP status code should be "400"

@skip @issue-28441
Scenario: rename a file into a banned filename
Given using new dav path
And user "user0" exists
Expand Down Expand Up @@ -388,7 +387,6 @@ Feature: webdav-related-new-endpoint
When User "user0" moves folder "/testshare" to "/hola%5Chola"
Then the HTTP status code should be "400"

@skip @issue-28441
Scenario: Renaming a folder into a banned name
Given using new dav path
And user "user0" exists
Expand Down
7 changes: 6 additions & 1 deletion tests/ui/features/files/renameFiles.feature
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,17 @@ Feature: renameFiles

Scenario: Rename a file using forbidden characters
When I rename the file "data.zip" to one of these names
|.htaccess |
|lorem\txt |
|\\.txt |
Then notifications should be displayed with the text
|Could not rename "data.zip"|
|Could not rename "data.zip"|
And the file "data.zip" should be listed

Scenario: Rename a file to a forbidden name
When I rename the file "data.zip" to one of these names
|.htaccess |
Then notifications should be displayed with the text
|Could not rename "data.zip"|
And the file "data.zip" should be listed

Expand Down
7 changes: 6 additions & 1 deletion tests/ui/features/files/renameFolders.feature
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,17 @@ Feature: renameFolders

Scenario: Rename a folder using forbidden characters
When I rename the folder "simple-folder" to one of these names
|.htaccess |
|simple\folder |
|\\simple-folder |
Then notifications should be displayed with the text
|Could not rename "simple-folder"|
|Could not rename "simple-folder"|
And the folder "simple-folder" should be listed

Scenario: Rename a folder to a forbidden name
When I rename the folder "simple-folder" to one of these names
|.htaccess |
Then notifications should be displayed with the text
|Could not rename "simple-folder"|
And the folder "simple-folder" should be listed

Expand Down