Skip to content
Snippets Groups Projects
Commit 1ab7ee5e authored by Vincent Petry's avatar Vincent Petry
Browse files

Merge pull request #24940 from owncloud/fix-normalizedcachekey-keepunicode

Add keepUnicode value in the cache key of normalizedPathCache
parents 53398b51 5b1eb416
No related branches found
No related tags found
No related merge requests found
...@@ -781,7 +781,7 @@ class Filesystem { ...@@ -781,7 +781,7 @@ class Filesystem {
*/ */
$path = (string)$path; $path = (string)$path;
$cacheKey = json_encode([$path, $stripTrailingSlash, $isAbsolutePath]); $cacheKey = json_encode([$path, $stripTrailingSlash, $isAbsolutePath, $keepUnicode]);
if (isset(self::$normalizedPathCache[$cacheKey])) { if (isset(self::$normalizedPathCache[$cacheKey])) {
return self::$normalizedPathCache[$cacheKey]; return self::$normalizedPathCache[$cacheKey];
......
...@@ -92,6 +92,7 @@ class FilesystemTest extends \Test\TestCase { ...@@ -92,6 +92,7 @@ class FilesystemTest extends \Test\TestCase {
} }
$this->logout(); $this->logout();
$this->invokePrivate('\OC\Files\Filesystem', 'normalizedPathCache', [null]);
parent::tearDown(); parent::tearDown();
} }
...@@ -190,6 +191,32 @@ class FilesystemTest extends \Test\TestCase { ...@@ -190,6 +191,32 @@ class FilesystemTest extends \Test\TestCase {
$this->assertEquals($expected, \OC\Files\Filesystem::normalizePath($path, $stripTrailingSlash)); $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() { public function isValidPathData() {
return array( return array(
array('/', true), array('/', true),
......
...@@ -166,7 +166,12 @@ abstract class TestCase extends \PHPUnit_Framework_TestCase { ...@@ -166,7 +166,12 @@ abstract class TestCase extends \PHPUnit_Framework_TestCase {
* @return mixed * @return mixed
*/ */
protected static function invokePrivate($object, $methodName, array $parameters = array()) { 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)) { if ($reflection->hasMethod($methodName)) {
$method = $reflection->getMethod($methodName); $method = $reflection->getMethod($methodName);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment