summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorThomas Müller <thomas.mueller@tmit.eu>2013-11-14 11:40:21 -0800
committerThomas Müller <thomas.mueller@tmit.eu>2013-11-14 11:40:21 -0800
commit2bb4c266a6a3d2febe119054675f7d5ee8a9f46f (patch)
tree383f811eee1dcdf78ebc10fe853796fe91f34766 /lib
parent447e468d1ad5fbfe447d4b7446d6babba6802bbf (diff)
parentd9ab964ff980d495c8960a728fb082f006b6a1e6 (diff)
downloadnextcloud-server-2bb4c266a6a3d2febe119054675f7d5ee8a9f46f.tar.gz
nextcloud-server-2bb4c266a6a3d2febe119054675f7d5ee8a9f46f.zip
Merge pull request #5862 from owncloud/files-singledotdirs
Files singledotdirs
Diffstat (limited to 'lib')
-rw-r--r--lib/private/files/filesystem.php20
1 files changed, 17 insertions, 3 deletions
diff --git a/lib/private/files/filesystem.php b/lib/private/files/filesystem.php
index 899666f3e1a..8500b3c581b 100644
--- a/lib/private/files/filesystem.php
+++ b/lib/private/files/filesystem.php
@@ -689,18 +689,32 @@ class Filesystem {
}
//no windows style slashes
$path = str_replace('\\', '/', $path);
+
//add leading slash
if ($path[0] !== '/') {
$path = '/' . $path;
}
- //remove duplicate slashes
- while (strpos($path, '//') !== false) {
- $path = str_replace('//', '/', $path);
+
+ // remove '/./'
+ // ugly, but str_replace() can't replace them all in one go
+ // as the replacement itself is part of the search string
+ // which will only be found during the next iteration
+ while (strpos($path, '/./') !== false) {
+ $path = str_replace('/./', '/', $path);
}
+ // remove sequences of slashes
+ $path = preg_replace('#/{2,}#', '/', $path);
+
//remove trailing slash
if ($stripTrailingSlash and strlen($path) > 1 and substr($path, -1, 1) === '/') {
$path = substr($path, 0, -1);
}
+
+ // remove trailing '/.'
+ if (substr($path, -2) == '/.') {
+ $path = substr($path, 0, -2);
+ }
+
//normalize unicode if possible
$path = \OC_Util::normalizeUnicode($path);