Skip to content

Commit a5871ea

Browse files
committed
[stable9] getJailedPath expects $path to have a trailing / (#25703)
* getJailedPath expects $path to have a trailing / - fixes #25464 * Adding test case for getPathById including a jailed cache where root is just empty
1 parent ac64fa8 commit a5871ea

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

lib/private/files/cache/wrapper/cachejail.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,9 @@ protected function getSourcePath($path) {
5656
* @return null|string the jailed path or null if the path is outside the jail
5757
*/
5858
protected function getJailedPath($path) {
59+
if ($this->root === '') {
60+
return $path;
61+
}
5962
$rootLength = strlen($this->root) + 1;
6063
if ($path === $this->root) {
6164
return '';

tests/lib/files/cache/wrapper/cachejail.php

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,17 @@ function testClearKeepEntriesOutsideJail() {
6363
}
6464

6565
function testGetById() {
66-
//not supported
67-
$this->assertTrue(true);
66+
$data1 = array('size' => 100, 'mtime' => 50, 'mimetype' => 'httpd/unix-directory');
67+
$id = $this->sourceCache->put('foo/bar', $data1);
68+
69+
// path from jailed foo of foo/bar is bar
70+
$path = $this->cache->getPathById($id);
71+
$this->assertEquals('bar', $path);
72+
73+
// path from jailed '' of foo/bar is foo/bar
74+
$this->cache = new \OC\Files\Cache\Wrapper\CacheJail($this->sourceCache, '');
75+
$path = $this->cache->getPathById($id);
76+
$this->assertEquals('foo/bar', $path);
6877
}
6978

7079
function testGetIncomplete() {

0 commit comments

Comments
 (0)