aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVincent Petry <pvince81@owncloud.com>2016-08-11 21:28:38 +0200
committerGitHub <noreply@github.com>2016-08-11 21:28:38 +0200
commit80e106f04a2874591de3bf3e68baa44c8bfb4d99 (patch)
tree6f79a2bbbb703b3fd53059b689aa5d061d1a7a8b
parent912aa4f82b0da2a05168091e78225b03b800ed1f (diff)
parenta32f50a5bfe83a3631c78d2803d38a46c548ec4d (diff)
downloadnextcloud-server-80e106f04a2874591de3bf3e68baa44c8bfb4d99.tar.gz
nextcloud-server-80e106f04a2874591de3bf3e68baa44c8bfb4d99.zip
Merge pull request #25737 from owncloud/stable9.1-99611d277521b84a943f68d48fe05f290127db7e
[stable9.1] getJailedPath expects $path to have a trailing / (#25703)
-rw-r--r--lib/private/Files/Cache/Wrapper/CacheJail.php3
-rw-r--r--tests/lib/Files/Cache/Wrapper/CacheJailTest.php13
2 files changed, 14 insertions, 2 deletions
diff --git a/lib/private/Files/Cache/Wrapper/CacheJail.php b/lib/private/Files/Cache/Wrapper/CacheJail.php
index 858132930f2..3443ad40d26 100644
--- a/lib/private/Files/Cache/Wrapper/CacheJail.php
+++ b/lib/private/Files/Cache/Wrapper/CacheJail.php
@@ -58,6 +58,9 @@ class CacheJail extends CacheWrapper {
* @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 '';
diff --git a/tests/lib/Files/Cache/Wrapper/CacheJailTest.php b/tests/lib/Files/Cache/Wrapper/CacheJailTest.php
index 6ef6716f721..e3043c50d57 100644
--- a/tests/lib/Files/Cache/Wrapper/CacheJailTest.php
+++ b/tests/lib/Files/Cache/Wrapper/CacheJailTest.php
@@ -63,8 +63,17 @@ class CacheJailTest extends CacheTest {
}
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() {