From bb5c5a36910c6ef67c6cd7ad49784972ff9640bc Mon Sep 17 00:00:00 2001 From: Lukas Reschke Date: Wed, 18 Mar 2015 12:33:54 +0100 Subject: [PATCH 1/2] Remove unreqired backtick removal Without this files with a ` (backtick) in the beginning of the filenames where simply not correctly referenced as the ` got removed. This can lead to all possible havoc situations. Should get backported to stable8 and in future we might consider if it is really worth to backport such changes when it is just for SQLite :see_no_evil: Regression of https://github.com/owncloud/core/pull/14734 --- lib/private/files/cache/cache.php | 3 --- 1 file changed, 3 deletions(-) diff --git a/lib/private/files/cache/cache.php b/lib/private/files/cache/cache.php index 64661ca1157..670ac2ec524 100644 --- a/lib/private/files/cache/cache.php +++ b/lib/private/files/cache/cache.php @@ -245,9 +245,6 @@ class Cache { $queryParts[] = '`storage`'; $params[] = $this->getNumericStorageId(); - $params = array_map(function($item) { - return trim($item, "`"); - }, $params); $queryParts = array_map(function($item) { return trim($item, "`"); }, $queryParts); From f2f7f178a5dcf3c5cfbc7509692d47cca4a658f3 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Wed, 18 Mar 2015 13:29:39 +0100 Subject: [PATCH 2/2] Add test for backticks in path and etag --- tests/lib/files/cache/cache.php | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/tests/lib/files/cache/cache.php b/tests/lib/files/cache/cache.php index 15bcff24f36..1bf838351b6 100644 --- a/tests/lib/files/cache/cache.php +++ b/tests/lib/files/cache/cache.php @@ -260,6 +260,28 @@ class Cache extends \Test\TestCase { $this->assertEquals(\OC\Files\Cache\Cache::COMPLETE, $this->cache->getStatus('foo')); } + public function putWithAllKindOfQuotesData() { + return [ + ['`backtick`'], + ['´forward´'], + ['\'single\''], + ]; + } + + /** + * @dataProvider putWithAllKindOfQuotesData + * @param $fileName + */ + public function testPutWithAllKindOfQuotes($fileName) { + + $this->assertEquals(\OC\Files\Cache\Cache::NOT_FOUND, $this->cache->get($fileName)); + $this->cache->put($fileName, array('size' => 20, 'mtime' => 25, 'mimetype' => 'foo/file', 'etag' => $fileName)); + + $cacheEntry = $this->cache->get($fileName); + $this->assertEquals($fileName, $cacheEntry['etag']); + $this->assertEquals($fileName, $cacheEntry['path']); + } + function testSearch() { $file1 = 'folder'; $file2 = 'folder/foobar';