diff options
author | Vincent Petry <pvince81@owncloud.com> | 2014-01-13 13:14:05 +0100 |
---|---|---|
committer | Vincent Petry <pvince81@owncloud.com> | 2014-02-18 17:54:32 +0100 |
commit | bd71a1b7b66f02b3630da44e24b48e29f3d02f17 (patch) | |
tree | caf60bd54c1155194101422d201a8083a3148799 /lib/private/connector/sabre/node.php | |
parent | 797e0a614cc44e627a54dfd39ce4047d176ebd9b (diff) | |
download | nextcloud-server-bd71a1b7b66f02b3630da44e24b48e29f3d02f17.tar.gz nextcloud-server-bd71a1b7b66f02b3630da44e24b48e29f3d02f17.zip |
Added file name check in webdav connector
- added file name check for the put, rename and setNames() methods which
throw a "Bad Request" whenever invalid characters are used
- replaced \OC\Filesystem usage with $this->getFS() to be able to write
unit tests
Diffstat (limited to 'lib/private/connector/sabre/node.php')
-rw-r--r-- | lib/private/connector/sabre/node.php | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/lib/private/connector/sabre/node.php b/lib/private/connector/sabre/node.php index 993aa73faeb..bf7a04f5b13 100644 --- a/lib/private/connector/sabre/node.php +++ b/lib/private/connector/sabre/node.php @@ -85,19 +85,24 @@ abstract class OC_Connector_Sabre_Node implements Sabre_DAV_INode, Sabre_DAV_IPr * @return void */ public function setName($name) { + $fs = $this->getFS(); // rename is only allowed if the update privilege is granted - if (!\OC\Files\Filesystem::isUpdatable($this->path)) { + if (!$fs->isUpdatable($this->path)) { throw new \Sabre_DAV_Exception_Forbidden(); } list($parentPath, ) = Sabre_DAV_URLUtil::splitPath($this->path); list(, $newName) = Sabre_DAV_URLUtil::splitPath($name); + if (!\OCP\Util::isValidFileName($newName)) { + throw new \Sabre_DAV_Exception_BadRequest(); + } + $newPath = $parentPath . '/' . $newName; $oldPath = $this->path; - \OC\Files\Filesystem::rename($this->path, $newPath); + $fs->rename($this->path, $newPath); $this->path = $newPath; |