Skip to content
Snippets Groups Projects
Commit b4ed4e15 authored by Lukas Reschke's avatar Lukas Reschke Committed by GitHub
Browse files

Merge pull request #746 from nextcloud/jail-root

getJailedPath expects $path to have a trailing /
parents 42770514 f1cd68d7
No related branches found
No related tags found
No related merge requests found
...@@ -59,6 +59,9 @@ class CacheJail extends CacheWrapper { ...@@ -59,6 +59,9 @@ class CacheJail extends CacheWrapper {
* @return null|string the jailed path or null if the path is outside the jail * @return null|string the jailed path or null if the path is outside the jail
*/ */
protected function getJailedPath($path) { protected function getJailedPath($path) {
if ($this->root === '') {
return $path;
}
$rootLength = strlen($this->root) + 1; $rootLength = strlen($this->root) + 1;
if ($path === $this->root) { if ($path === $this->root) {
return ''; return '';
......
...@@ -63,8 +63,17 @@ class CacheJailTest extends CacheTest { ...@@ -63,8 +63,17 @@ class CacheJailTest extends CacheTest {
} }
function testGetById() { function testGetById() {
//not supported $data1 = array('size' => 100, 'mtime' => 50, 'mimetype' => 'httpd/unix-directory');
$this->assertTrue(true); $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() { function testGetIncomplete() {
......
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