summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorVincent Petry <pvince81@owncloud.com>2015-01-08 19:43:02 +0100
committerVincent Petry <pvince81@owncloud.com>2015-01-08 19:43:02 +0100
commitaa821ecc00f11b6382f6e033db18445d9e51d6b9 (patch)
tree09cb5031a461f521b3b4dee29b4393962ef4ff60 /tests
parent10505bdb0db4d14ce86815b57d2bca2ef880a581 (diff)
downloadnextcloud-server-aa821ecc00f11b6382f6e033db18445d9e51d6b9.tar.gz
nextcloud-server-aa821ecc00f11b6382f6e033db18445d9e51d6b9.zip
Trim leading or trailing slashes in file cache paths
Diffstat (limited to 'tests')
-rw-r--r--tests/lib/files/cache/cache.php36
1 files changed, 36 insertions, 0 deletions
diff --git a/tests/lib/files/cache/cache.php b/tests/lib/files/cache/cache.php
index 81d7f3ce0bc..6df98ee531d 100644
--- a/tests/lib/files/cache/cache.php
+++ b/tests/lib/files/cache/cache.php
@@ -517,6 +517,42 @@ class Cache extends \Test\TestCase {
$this->assertEquals(1, count($this->cache->getFolderContents('folder')));
}
+ function bogusPathNamesProvider() {
+ return array(
+ array('/bogus.txt', 'bogus.txt'),
+ array('//bogus.txt', 'bogus.txt'),
+ array('bogus/', 'bogus'),
+ array('bogus//', 'bogus'),
+ );
+ }
+
+ /**
+ * Test bogus paths with leading or doubled slashes
+ *
+ * @dataProvider bogusPathNamesProvider
+ */
+ public function testBogusPaths($bogusPath, $fixedBogusPath) {
+ $data = array('size' => 100, 'mtime' => 50, 'mimetype' => 'httpd/unix-directory');
+
+ // put root folder
+ $this->assertFalse($this->cache->get(''));
+ $parentId = $this->cache->put('', $data);
+ $this->assertGreaterThan(0, $parentId);
+
+ $this->assertGreaterThan(0, $this->cache->put($bogusPath, $data));
+
+ $newData = $this->cache->get($fixedBogusPath);
+ $this->assertNotFalse($newData);
+
+ $this->assertEquals($fixedBogusPath, $newData['path']);
+ // parent is the correct one, resolved properly (they used to not be)
+ $this->assertEquals($parentId, $newData['parent']);
+
+ $newDataFromBogus = $this->cache->get($bogusPath);
+ // same entry
+ $this->assertEquals($newData, $newDataFromBogus);
+ }
+
protected function tearDown() {
if ($this->cache) {
$this->cache->clear();