aboutsummaryrefslogtreecommitdiffstats
path: root/lib/files/storage
diff options
context:
space:
mode:
authorLukas Reschke <lukas@statuscode.ch>2013-02-10 05:06:00 -0800
committerLukas Reschke <lukas@statuscode.ch>2013-02-10 05:06:00 -0800
commit6f785e211ba4f5d1f9c85b86913195f56a15a88f (patch)
tree1ab6d708ec1a54d322cd84ae911af21f11331525 /lib/files/storage
parent1c56539c01c162676a05d90e3598b7d68394ac73 (diff)
parent421bacc33ac1625a920e71cbb065894ee39ed930 (diff)
downloadnextcloud-server-6f785e211ba4f5d1f9c85b86913195f56a15a88f.tar.gz
nextcloud-server-6f785e211ba4f5d1f9c85b86913195f56a15a88f.zip
Merge pull request #1030 from hkjolhede/master
SFTP support in files_external app
Diffstat (limited to 'lib/files/storage')
-rw-r--r--lib/files/storage/common.php23
1 files changed, 23 insertions, 0 deletions
diff --git a/lib/files/storage/common.php b/lib/files/storage/common.php
index 591803f0440..ce9e7ead6d1 100644
--- a/lib/files/storage/common.php
+++ b/lib/files/storage/common.php
@@ -277,4 +277,27 @@ abstract class Common implements \OC\Files\Storage\Storage {
return uniqid();
}
}
+
+ /**
+ * clean a path, i.e. remove all redundant '.' and '..'
+ * making sure that it can't point to higher than '/'
+ * @param $path The path to clean
+ * @return string cleaned path
+ */
+ public function cleanPath($path) {
+ if (strlen($path) == 0 or $path[0] != '/') {
+ $path = '/' . $path;
+ }
+
+ $output = array();
+ foreach (explode('/', $path) as $chunk) {
+ if ($chunk == '..') {
+ array_pop($output);
+ } else if ($chunk == '.') {
+ } else {
+ $output[] = $chunk;
+ }
+ }
+ return implode('/', $output);
+ }
}