diff options
author | Ferdinand Thiessen <opensource@fthiessen.de> | 2024-07-15 17:32:11 +0200 |
---|---|---|
committer | Ferdinand Thiessen <opensource@fthiessen.de> | 2024-07-16 12:57:11 +0200 |
commit | 322b3946d9b67de69792b70d9250d5285fe56954 (patch) | |
tree | fe962c325774d8e01e69aa7dbecbb6c97315a6da /apps/dav/lib | |
parent | f4ede27cdbbb4f55bb963130295a28a89a833d94 (diff) | |
download | nextcloud-server-322b3946d9b67de69792b70d9250d5285fe56954.tar.gz nextcloud-server-322b3946d9b67de69792b70d9250d5285fe56954.zip |
fix(dav): Verify target path in `setName` instead of source path
Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
Diffstat (limited to 'apps/dav/lib')
-rw-r--r-- | apps/dav/lib/Connector/Sabre/Node.php | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/apps/dav/lib/Connector/Sabre/Node.php b/apps/dav/lib/Connector/Sabre/Node.php index 63e453c86af..379574b30d6 100644 --- a/apps/dav/lib/Connector/Sabre/Node.php +++ b/apps/dav/lib/Connector/Sabre/Node.php @@ -122,11 +122,11 @@ abstract class Node implements \Sabre\DAV\INode { [$parentPath,] = \Sabre\Uri\split($this->path); [, $newName] = \Sabre\Uri\split($name); + $newPath = $parentPath . '/' . $newName; // verify path of the target - $this->verifyPath(); + $this->verifyPath($newPath); - $newPath = $parentPath . '/' . $newName; if (!$this->fileView->rename($this->path, $newPath)) { throw new \Sabre\DAV\Exception('Failed to rename '. $this->path . ' to ' . $newPath); @@ -355,10 +355,13 @@ abstract class Node implements \Sabre\DAV\INode { return $this->info->getOwner(); } - protected function verifyPath() { + protected function verifyPath(?string $path = null): void { try { - $fileName = basename($this->info->getPath()); - $this->fileView->verifyPath($this->path, $fileName); + $path = $path ?? $this->info->getPath(); + $this->fileView->verifyPath( + dirname($path), + basename($path), + ); } catch (\OCP\Files\InvalidPathException $ex) { throw new InvalidPath($ex->getMessage()); } |