]> source.dussan.org Git - nextcloud-server.git/commitdiff
Add keepUnicode value in the cache key of normalizedPathCache
authorVincent Petry <pvince81@owncloud.com>
Wed, 1 Jun 2016 10:20:38 +0000 (12:20 +0200)
committerVincent Petry <pvince81@owncloud.com>
Wed, 1 Jun 2016 12:28:59 +0000 (14:28 +0200)
lib/private/Files/Filesystem.php
tests/lib/Files/FilesystemTest.php

index 08621d160be67b2a295c33d6e8b3565d50432481..3d3345a5c80fa0e1df43cb43dd30d37445129501 100644 (file)
@@ -781,7 +781,7 @@ class Filesystem {
                 */
                $path = (string)$path;
 
-               $cacheKey = json_encode([$path, $stripTrailingSlash, $isAbsolutePath]);
+               $cacheKey = json_encode([$path, $stripTrailingSlash, $isAbsolutePath, $keepUnicode]);
 
                if (isset(self::$normalizedPathCache[$cacheKey])) {
                        return self::$normalizedPathCache[$cacheKey];
index a4a4345d2f93935c9ccac222e72ca913a829e3d8..76e3f4716335c54c27f27abd600f6f51d8847ac8 100644 (file)
@@ -92,6 +92,7 @@ class FilesystemTest extends \Test\TestCase {
                }
 
                $this->logout();
+               $this->invokePrivate('\OC\Files\Filesystem', 'normalizedPathCache', [null]);
                parent::tearDown();
        }
 
@@ -190,6 +191,32 @@ class FilesystemTest extends \Test\TestCase {
                $this->assertEquals($expected, \OC\Files\Filesystem::normalizePath($path, $stripTrailingSlash));
        }
 
+       public function normalizePathKeepUnicodeData() {
+               $nfdName = 'ümlaut';
+               $nfcName = 'ümlaut';
+               return [
+                       ['/' . $nfcName, $nfcName, true],
+                       ['/' . $nfcName, $nfcName, false],
+                       ['/' . $nfdName, $nfdName, true],
+                       ['/' . $nfcName, $nfdName, false],
+               ];
+       }
+
+       /**
+        * @dataProvider normalizePathKeepUnicodeData
+        */
+       public function testNormalizePathKeepUnicode($expected, $path, $keepUnicode = false) {
+               $this->assertEquals($expected, \OC\Files\Filesystem::normalizePath($path, true, false, $keepUnicode));
+       }
+
+       public function testNormalizePathKeepUnicodeCache() {
+               $nfdName = 'ümlaut';
+               $nfcName = 'ümlaut';
+               // call in succession due to cache
+               $this->assertEquals('/' . $nfcName, \OC\Files\Filesystem::normalizePath($nfdName, true, false, false));
+               $this->assertEquals('/' . $nfdName, \OC\Files\Filesystem::normalizePath($nfdName, true, false, true));
+       }
+
        public function isValidPathData() {
                return array(
                        array('/', true),