Merge pull request #52775 from nextcloud/nested-jail-root

fix unjailedroot of nested jails if there are other wrappers in between
pull/52544/head
Andy Scherzinger 5 months ago committed by GitHub
commit 14f79829f3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 2
      apps/files_sharing/lib/Cache.php
  2. 13
      lib/private/Files/Cache/Wrapper/CacheJail.php
  3. 11
      tests/lib/Files/Cache/Wrapper/CacheJailTest.php

@ -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…
Cancel
Save