summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVincent Petry <pvince81@owncloud.com>2016-04-29 11:19:00 +0200
committerVincent Petry <pvince81@owncloud.com>2016-04-29 16:19:53 +0200
commit4326d73ff6dc4514163dbbe4164342cef8deba0a (patch)
tree7af67c14d4119abdb62f25c7349ca14a6d79a3e2
parent61203eee0422bbb839356bfbfe196ef794fd91b3 (diff)
downloadnextcloud-server-4326d73ff6dc4514163dbbe4164342cef8deba0a.tar.gz
nextcloud-server-4326d73ff6dc4514163dbbe4164342cef8deba0a.zip
Fix SMB storage to not normalize UTF8
This makes sure that even if a NFD file name exists, it is found by the storage and will be visible to higher layers. Even though the file will be discarded anyway there, it gives the scanner a chance to display a warning at least.
-rw-r--r--apps/files_external/lib/storage/smb.php2
-rw-r--r--lib/private/Files/Filesystem.php21
2 files changed, 9 insertions, 14 deletions
diff --git a/apps/files_external/lib/storage/smb.php b/apps/files_external/lib/storage/smb.php
index 4249d13168c..868c52a63b4 100644
--- a/apps/files_external/lib/storage/smb.php
+++ b/apps/files_external/lib/storage/smb.php
@@ -100,7 +100,7 @@ class SMB extends \OC\Files\Storage\Common {
* @return string
*/
protected function buildPath($path) {
- return Filesystem::normalizePath($this->root . '/' . $path);
+ return Filesystem::normalizePath($this->root . '/' . $path, true, false, true);
}
/**
diff --git a/lib/private/Files/Filesystem.php b/lib/private/Files/Filesystem.php
index 7cd1f56071c..3a85d5fb9f1 100644
--- a/lib/private/Files/Filesystem.php
+++ b/lib/private/Files/Filesystem.php
@@ -790,11 +790,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();
}
@@ -818,19 +819,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;
@@ -856,7 +851,7 @@ class Filesystem {
$path = substr($path, 0, -2);
}
- $normalizedPath = $windows_drive_letter . $path;
+ $normalizedPath = $path;
self::$normalizedPathCache[$cacheKey] = $normalizedPath;
return $normalizedPath;