summaryrefslogtreecommitdiffstats
path: root/lib/public
diff options
context:
space:
mode:
authorLukas Reschke <lukas@owncloud.com>2015-03-10 11:02:47 +0100
committerLukas Reschke <lukas@owncloud.com>2015-03-10 11:02:47 +0100
commit6dc59019af78f580f2854a98e5f1d59649d510db (patch)
tree6d1e957d7249445c5bbb87b57c5ca4a85af6bf5f /lib/public
parent214fa44400be2b3f68566f54feff389f20f3a445 (diff)
parent3623f14e73046a51953872fe49853bc200ac736d (diff)
downloadnextcloud-server-6dc59019af78f580f2854a98e5f1d59649d510db.tar.gz
nextcloud-server-6dc59019af78f580f2854a98e5f1d59649d510db.zip
Merge pull request #14346 from owncloud/storage-based-path-validation
adding storage specific filename verification
Diffstat (limited to 'lib/public')
-rw-r--r--lib/public/files/invalidcharacterinpathexception.php37
-rw-r--r--lib/public/files/reservedwordexception.php37
-rw-r--r--lib/public/files/storage.php9
-rw-r--r--lib/public/util.php1
4 files changed, 84 insertions, 0 deletions
diff --git a/lib/public/files/invalidcharacterinpathexception.php b/lib/public/files/invalidcharacterinpathexception.php
new file mode 100644
index 00000000000..4ae2eb01c19
--- /dev/null
+++ b/lib/public/files/invalidcharacterinpathexception.php
@@ -0,0 +1,37 @@
+<?php
+/**
+ * ownCloud
+ *
+ * @author Thomas Müller
+ * @copyright 2013 Thomas Müller deepdiver@owncloud.com
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+/**
+ * Public interface of ownCloud for apps to use.
+ * Files/InvalidCharacterInPathException class
+ */
+
+// use OCP namespace for all classes that are considered public.
+// This means that they should be used by apps instead of the internal ownCloud classes
+namespace OCP\Files;
+
+/**
+ * Exception for invalid path
+ */
+class InvalidCharacterInPathException extends InvalidPathException {
+
+}
diff --git a/lib/public/files/reservedwordexception.php b/lib/public/files/reservedwordexception.php
new file mode 100644
index 00000000000..25c618a8ded
--- /dev/null
+++ b/lib/public/files/reservedwordexception.php
@@ -0,0 +1,37 @@
+<?php
+/**
+ * ownCloud
+ *
+ * @author Thomas Müller
+ * @copyright 2013 Thomas Müller deepdiver@owncloud.com
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+/**
+ * Public interface of ownCloud for apps to use.
+ * Files/ReservedWordException class
+ */
+
+// use OCP namespace for all classes that are considered public.
+// This means that they should be used by apps instead of the internal ownCloud classes
+namespace OCP\Files;
+
+/**
+ * Exception for invalid path
+ */
+class ReservedWordException extends InvalidPathException {
+
+}
diff --git a/lib/public/files/storage.php b/lib/public/files/storage.php
index 3e6559c28f7..388ba5fa6ac 100644
--- a/lib/public/files/storage.php
+++ b/lib/public/files/storage.php
@@ -28,6 +28,7 @@
// use OCP namespace for all classes that are considered public.
// This means that they should be used by apps instead of the internal ownCloud classes
namespace OCP\Files;
+use OCP\Files\InvalidPathException;
/**
* Provide a common interface to all different storage options
@@ -345,4 +346,12 @@ interface Storage {
* @return array|false
*/
public function getDirectDownload($path);
+
+ /**
+ * @param string $path the path of the target folder
+ * @param string $fileName the name of the file itself
+ * @return void
+ * @throws InvalidPathException
+ */
+ public function verifyPath($path, $fileName);
}
diff --git a/lib/public/util.php b/lib/public/util.php
index e6e14a26e01..aa6cd5ba012 100644
--- a/lib/public/util.php
+++ b/lib/public/util.php
@@ -497,6 +497,7 @@ class Util {
* Returns whether the given file name is valid
* @param string $file file name to check
* @return bool true if the file name is valid, false otherwise
+ * @deprecated use \OC\Files\View::verifyPath()
*/
public static function isValidFileName($file) {
return \OC_Util::isValidFileName($file);