Skip to content

Commit

Permalink
[stable9.1] getJailedPath expects $path to have a trailing / (#25703)
Browse files Browse the repository at this point in the history
* getJailedPath expects $path to have a trailing / - fixes #25464

* Adding test case for getPathById including a jailed cache where root is just empty
  • Loading branch information
DeepDiver1975 committed Aug 9, 2016
1 parent ee72c9b commit a32f50a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
3 changes: 3 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,9 @@ 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/CacheJailTest.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

0 comments on commit a32f50a

Please sign in to comment.