summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVincent Petry <pvince81@owncloud.com>2016-06-02 15:18:13 +0200
committerVincent Petry <pvince81@owncloud.com>2016-06-02 15:18:13 +0200
commit1ab7ee5e231b85ffdb24c284e57cebdd030b8a3d (patch)
treef5ff7c4b171495337972e8595385819ed2937b5b
parent53398b5146b566e55874b86171643a8dfddd34c1 (diff)
parent5b1eb416d87c0e85e60547003f9b01847c81ec8a (diff)
downloadnextcloud-server-1ab7ee5e231b85ffdb24c284e57cebdd030b8a3d.tar.gz
nextcloud-server-1ab7ee5e231b85ffdb24c284e57cebdd030b8a3d.zip
Merge pull request #24940 from owncloud/fix-normalizedcachekey-keepunicode
Add keepUnicode value in the cache key of normalizedPathCache
-rw-r--r--lib/private/Files/Filesystem.php2
-rw-r--r--tests/lib/Files/FilesystemTest.php27
-rw-r--r--tests/lib/TestCase.php7
3 files changed, 34 insertions, 2 deletions
diff --git a/lib/private/Files/Filesystem.php b/lib/private/Files/Filesystem.php
index 08621d160be..3d3345a5c80 100644
--- a/lib/private/Files/Filesystem.php
+++ b/lib/private/Files/Filesystem.php
@@ -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];
diff --git a/tests/lib/Files/FilesystemTest.php b/tests/lib/Files/FilesystemTest.php
index a4a4345d2f9..76e3f471633 100644
--- a/tests/lib/Files/FilesystemTest.php
+++ b/tests/lib/Files/FilesystemTest.php
@@ -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),
diff --git a/tests/lib/TestCase.php b/tests/lib/TestCase.php
index 7ed121d3556..a1f65f8ac82 100644
--- a/tests/lib/TestCase.php
+++ b/tests/lib/TestCase.php
@@ -166,7 +166,12 @@ abstract class TestCase extends \PHPUnit_Framework_TestCase {
* @return mixed
*/
protected static function invokePrivate($object, $methodName, array $parameters = array()) {
- $reflection = new \ReflectionClass(get_class($object));
+ if (is_string($object)) {
+ $className = $object;
+ } else {
+ $className = get_class($object);
+ }
+ $reflection = new \ReflectionClass($className);
if ($reflection->hasMethod($methodName)) {
$method = $reflection->getMethod($methodName);