Skip to content
Snippets Groups Projects
Commit db17598a authored by Roeland Jago Douma's avatar Roeland Jago Douma
Browse files

Verify the src exists in webdav MOVE

* Unit test added
parent 0875a4a1
Branches
No related tags found
No related merge requests found
...@@ -132,6 +132,10 @@ class FilesPlugin extends \Sabre\DAV\ServerPlugin { ...@@ -132,6 +132,10 @@ class FilesPlugin extends \Sabre\DAV\ServerPlugin {
if ($sourceDir !== $destinationDir) { if ($sourceDir !== $destinationDir) {
$sourceFileInfo = $this->fileView->getFileInfo($source); $sourceFileInfo = $this->fileView->getFileInfo($source);
if ($sourceFileInfo === false) {
throw new \Sabre\DAV\Exception\NotFound($source . ' does not exist');
}
if (!$sourceFileInfo->isDeletable()) { if (!$sourceFileInfo->isDeletable()) {
throw new \Sabre\DAV\Exception\Forbidden($source . " cannot be deleted"); throw new \Sabre\DAV\Exception\Forbidden($source . " cannot be deleted");
} }
......
...@@ -251,4 +251,17 @@ class FilesPlugin extends \Test\TestCase { ...@@ -251,4 +251,17 @@ class FilesPlugin extends \Test\TestCase {
$this->plugin->checkMove('FolderA/test.txt', 'test.txt'); $this->plugin->checkMove('FolderA/test.txt', 'test.txt');
} }
/**
* @expectedException \Sabre\DAV\Exception\NotFound
* @expectedExceptionMessage FolderA/test.txt does not exist
*/
public function testMoveSrcNotExist() {
$this->view->expects($this->once())
->method('getFileInfo')
->with('FolderA/test.txt')
->willReturn(false);
$this->plugin->checkMove('FolderA/test.txt', 'test.txt');
}
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment