diff options
author | Lukas Reschke <lukas@statuscode.ch> | 2016-08-10 16:03:55 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-08-10 16:03:55 +0200 |
commit | f222d6ea5f63138b883ee9ad0aeec93e0715ced3 (patch) | |
tree | 936618bf541330dc55a055dc34f30476bd4997db | |
parent | d1b7f50716d2374db584c4c8ff0a657c00d663c1 (diff) | |
parent | 6f3d9ec0243d241fe407c019427117de51e3c5be (diff) | |
download | nextcloud-server-f222d6ea5f63138b883ee9ad0aeec93e0715ced3.tar.gz nextcloud-server-f222d6ea5f63138b883ee9ad0aeec93e0715ced3.zip |
Merge pull request #818 from nextcloud/jail-root-stable9
getJailedPath expects to have a trailing /
-rw-r--r-- | lib/private/files/cache/wrapper/cachejail.php | 5 | ||||
-rw-r--r-- | tests/lib/files/cache/wrapper/cachejail.php | 13 |
2 files changed, 16 insertions, 2 deletions
diff --git a/lib/private/files/cache/wrapper/cachejail.php b/lib/private/files/cache/wrapper/cachejail.php index b889ace5c7d..82f62eb7fba 100644 --- a/lib/private/files/cache/wrapper/cachejail.php +++ b/lib/private/files/cache/wrapper/cachejail.php @@ -58,6 +58,11 @@ class CacheJail extends CacheWrapper { * @return null|string the jailed path or null if the path is outside the jail */ protected function getJailedPath($path) { + + if ($this->root === '') { + return $path; + } + $rootLength = strlen($this->root) + 1; if ($path === $this->root) { return ''; diff --git a/tests/lib/files/cache/wrapper/cachejail.php b/tests/lib/files/cache/wrapper/cachejail.php index 9ddf3e9c61c..9b51b494801 100644 --- a/tests/lib/files/cache/wrapper/cachejail.php +++ b/tests/lib/files/cache/wrapper/cachejail.php @@ -63,8 +63,17 @@ class CacheJail extends Cache { } function testGetById() { - //not supported - $this->assertTrue(true); + $data1 = array('size' => 100, 'mtime' => 50, 'mimetype' => 'httpd/unix-directory'); + $id = $this->sourceCache->put('foo/bar', $data1); + + // path from jailed foo of foo/bar is bar + $path = $this->cache->getPathById($id); + $this->assertEquals('bar', $path); + + // path from jailed '' of foo/bar is foo/bar + $this->cache = new \OC\Files\Cache\Wrapper\CacheJail($this->sourceCache, ''); + $path = $this->cache->getPathById($id); + $this->assertEquals('foo/bar', $path); } function testGetIncomplete() { |