summaryrefslogtreecommitdiffstats
path: root/lib/private/Files/Filesystem.php
diff options
context:
space:
mode:
authorMorris Jobke <hey@morrisjobke.de>2016-05-02 09:41:12 +0200
committerMorris Jobke <hey@morrisjobke.de>2016-05-02 09:41:12 +0200
commit6b12f96b14ef4c560ae9be436caf2619739d74ae (patch)
tree8e147ec99cd933595acb0ee77ca86e8c097338e5 /lib/private/Files/Filesystem.php
parenta323111bd1285f74aa405c240be86b5de5d0c502 (diff)
parent4326d73ff6dc4514163dbbe4164342cef8deba0a (diff)
downloadnextcloud-server-6b12f96b14ef4c560ae9be436caf2619739d74ae.tar.gz
nextcloud-server-6b12f96b14ef4c560ae9be436caf2619739d74ae.zip
Merge pull request #24341 from owncloud/scan-nfd-showwarning
Add files:scan warning when NFD or incompatible encoding found
Diffstat (limited to 'lib/private/Files/Filesystem.php')
-rw-r--r--lib/private/Files/Filesystem.php21
1 files changed, 8 insertions, 13 deletions
diff --git a/lib/private/Files/Filesystem.php b/lib/private/Files/Filesystem.php
index 39c5fd3ab4a..99c123ad1a1 100644
--- a/lib/private/Files/Filesystem.php
+++ b/lib/private/Files/Filesystem.php
@@ -789,11 +789,12 @@ class Filesystem {
* Fix common problems with a file path
*
* @param string $path
- * @param bool $stripTrailingSlash
- * @param bool $isAbsolutePath
+ * @param bool $stripTrailingSlash whether to strip the trailing slash
+ * @param bool $isAbsolutePath whether the given path is absolute
+ * @param bool $keepUnicode true to disable unicode normalization
* @return string
*/
- public static function normalizePath($path, $stripTrailingSlash = true, $isAbsolutePath = false) {
+ public static function normalizePath($path, $stripTrailingSlash = true, $isAbsolutePath = false, $keepUnicode = false) {
if (is_null(self::$normalizedPathCache)) {
self::$normalizedPathCache = new CappedMemoryCache();
}
@@ -817,19 +818,13 @@ class Filesystem {
}
//normalize unicode if possible
- $path = \OC_Util::normalizeUnicode($path);
+ if (!$keepUnicode) {
+ $path = \OC_Util::normalizeUnicode($path);
+ }
//no windows style slashes
$path = str_replace('\\', '/', $path);
- // When normalizing an absolute path, we need to ensure that the drive-letter
- // is still at the beginning on windows
- $windows_drive_letter = '';
- if ($isAbsolutePath && \OC_Util::runningOnWindows() && preg_match('#^([a-zA-Z])$#', $path[0]) && $path[1] == ':' && $path[2] == '/') {
- $windows_drive_letter = substr($path, 0, 2);
- $path = substr($path, 2);
- }
-
//add leading slash
if ($path[0] !== '/') {
$path = '/' . $path;
@@ -855,7 +850,7 @@ class Filesystem {
$path = substr($path, 0, -2);
}
- $normalizedPath = $windows_drive_letter . $path;
+ $normalizedPath = $path;
self::$normalizedPathCache[$cacheKey] = $normalizedPath;
return $normalizedPath;