Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorVincent Petry <pvince81@owncloud.com>2013-11-15 15:57:27 +0400
committerVincent Petry <pvince81@owncloud.com>2013-11-15 15:57:27 +0400
commit477e3a8b87f9a3df3bfd6f4e457971f32a3e5fe8 (patch)
treed808e6b828084391164495da121720bbfb14a219 /lib
parenta3a97cd6d85e02aa127e459d958af1b6b50f0a73 (diff)
parenta7a87d074bd6803da7def6b53a496e95b631ef12 (diff)
Merge pull request #5883 from owncloud/stable5-singledotdirs
Stable5 single dot dirs
Diffstat (limited to 'lib')
-rw-r--r--lib/files/filesystem.php20
1 files changed, 17 insertions, 3 deletions
diff --git a/lib/files/filesystem.php b/lib/files/filesystem.php
index 14ca882982e..1850d50f971 100644
--- a/lib/files/filesystem.php
+++ b/lib/files/filesystem.php
@@ -589,18 +589,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);
return $path;