mirror of
https://github.com/nextcloud/server.git
synced 2026-02-24 18:37:44 -05:00
Merge pull request #52775 from nextcloud/nested-jail-root
fix unjailedroot of nested jails if there are other wrappers in between
This commit is contained in:
commit
14f79829f3
3 changed files with 20 additions and 6 deletions
|
|
@ -68,7 +68,7 @@ class Cache extends CacheJail {
|
|||
return $this->root;
|
||||
}
|
||||
|
||||
protected function getGetUnjailedRoot(): string {
|
||||
public function getGetUnjailedRoot(): string {
|
||||
return $this->sourceRootInfo->getPath();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -31,10 +31,13 @@ class CacheJail extends CacheWrapper {
|
|||
) {
|
||||
parent::__construct($cache, $dependencies);
|
||||
|
||||
if ($cache instanceof CacheJail) {
|
||||
$this->unjailedRoot = $cache->getSourcePath($root);
|
||||
} else {
|
||||
$this->unjailedRoot = $root;
|
||||
$this->unjailedRoot = $root;
|
||||
$parent = $cache;
|
||||
while ($parent instanceof CacheWrapper) {
|
||||
if ($parent instanceof CacheJail) {
|
||||
$this->unjailedRoot = $parent->getSourcePath($this->unjailedRoot);
|
||||
}
|
||||
$parent = $parent->getCache();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -50,7 +53,7 @@ class CacheJail extends CacheWrapper {
|
|||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function getGetUnjailedRoot() {
|
||||
public function getGetUnjailedRoot() {
|
||||
return $this->unjailedRoot;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@
|
|||
namespace Test\Files\Cache\Wrapper;
|
||||
|
||||
use OC\Files\Cache\Wrapper\CacheJail;
|
||||
use OC\Files\Cache\Wrapper\CacheWrapper;
|
||||
use OC\Files\Search\SearchComparison;
|
||||
use OC\Files\Search\SearchQuery;
|
||||
use OC\Files\Storage\Wrapper\Jail;
|
||||
|
|
@ -252,4 +253,14 @@ class CacheJailTest extends CacheTest {
|
|||
$storage->getWatcher()->update('bar', ['mimetype' => 'text/plain']);
|
||||
$this->assertTrue($this->cache->inCache('bar'));
|
||||
}
|
||||
|
||||
public function testUnJailedRoot(): void {
|
||||
$jail1 = new CacheJail($this->sourceCache, 'foo');
|
||||
$jail2 = new CacheJail($jail1, 'bar');
|
||||
$this->assertEquals('foo/bar', $jail2->getGetUnjailedRoot());
|
||||
|
||||
$middleWrapper = new CacheWrapper($jail1);
|
||||
$jail3 = new CacheJail($middleWrapper, 'bar');
|
||||
$this->assertEquals('foo/bar', $jail3->getGetUnjailedRoot());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue