[Pkg-owncloud-commits] [owncloud] 01/205: emit hooks from a view as long as the path is inside the default root

David Prévot taffit at moszumanska.debian.org
Thu Jul 2 17:36:47 UTC 2015


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch stable8
in repository owncloud.

commit 4b48dd424f37446dd78f4589d2474fbe47097b1f
Author: Robin Appelman <icewind at owncloud.com>
Date:   Mon Jun 1 14:08:14 2015 +0200

    emit hooks from a view as long as the path is inside the default root
---
 lib/private/files/view.php |  3 ++-
 tests/lib/files/view.php   | 29 +++++++++++++++++++++++++++++
 2 files changed, 31 insertions(+), 1 deletion(-)

diff --git a/lib/private/files/view.php b/lib/private/files/view.php
index b98842f..b47fa43 100644
--- a/lib/private/files/view.php
+++ b/lib/private/files/view.php
@@ -1063,7 +1063,8 @@ class View {
 		if ($this->fakeRoot === $defaultRoot) {
 			return true;
 		}
-		return (strlen($this->fakeRoot) > strlen($defaultRoot)) && (substr($this->fakeRoot, 0, strlen($defaultRoot) + 1) === $defaultRoot . '/');
+		$fullPath = $this->getAbsolutePath($path);
+		return (strlen($fullPath) > strlen($defaultRoot)) && (substr($fullPath, 0, strlen($defaultRoot) + 1) === $defaultRoot . '/');
 	}
 
 	/**
diff --git a/tests/lib/files/view.php b/tests/lib/files/view.php
index 06a42d6..9e4da40 100644
--- a/tests/lib/files/view.php
+++ b/tests/lib/files/view.php
@@ -1107,4 +1107,33 @@ class View extends \Test\TestCase {
 		$view->lockFile('/foo/bar', ILockingProvider::LOCK_SHARED);
 		$view->lockFile('/foo/bar', ILockingProvider::LOCK_EXCLUSIVE);
 	}
+
+	public function hookPathProvider() {
+		return [
+			['/foo/files', '/foo', true],
+			['/foo/files/bar', '/foo', true],
+			['/foo', '/foo', false],
+			['/foo', '/files/foo', true],
+			['/foo', 'filesfoo', false]
+		];
+	}
+
+	/**
+	 * @dataProvider hookPathProvider
+	 * @param $root
+	 * @param $path
+	 * @param $shouldEmit
+	 */
+	public function testHookPaths($root, $path, $shouldEmit) {
+		$filesystemReflection = new \ReflectionClass('\OC\Files\Filesystem');
+		$defaultRootValue = $filesystemReflection->getProperty('defaultInstance');
+		$defaultRootValue->setAccessible(true);
+		$oldRoot = $defaultRootValue->getValue();
+		$defaultView = new \OC\Files\View('/foo/files');
+		$defaultRootValue->setValue($defaultView);
+		$view = new \OC\Files\View($root);
+		$result = \Test_Helper::invokePrivate($view, 'shouldEmitHooks', [$path]);
+		$defaultRootValue->setValue($oldRoot);
+		$this->assertEquals($shouldEmit, $result);
+	}
 }

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud.git



More information about the Pkg-owncloud-commits mailing list