Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions lib/private/files/cache/wrapper/cachejail.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@ protected function getSourcePath($path) {
* @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 '';
Expand Down
13 changes: 11 additions & 2 deletions tests/lib/files/cache/wrapper/cachejail.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,17 @@ function testClearKeepEntriesOutsideJail() {
}

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() {
Expand Down