diff options
author | icewind1991 <robin@icewind.nl> | 2013-10-10 06:27:07 -0700 |
---|---|---|
committer | icewind1991 <robin@icewind.nl> | 2013-10-10 06:27:07 -0700 |
commit | 4c166fa361089f351b75a1ab92db327faf5d1a88 (patch) | |
tree | 86eba03e26c3df159871e7e43e6f6b97b121961e | |
parent | e276ffedd3d979c43067c53dd87e8024cd782352 (diff) | |
parent | 1378af838ced159f1070f869394dccbde8c21219 (diff) | |
download | nextcloud-server-4c166fa361089f351b75a1ab92db327faf5d1a88.tar.gz nextcloud-server-4c166fa361089f351b75a1ab92db327faf5d1a88.zip |
Merge pull request #5247 from owncloud/hooks-view-same-start
ensure the view's root is a subfolder of the the default root, not only ...
-rw-r--r-- | lib/private/files/view.php | 5 | ||||
-rw-r--r-- | tests/lib/files/view.php | 18 |
2 files changed, 22 insertions, 1 deletions
diff --git a/lib/private/files/view.php b/lib/private/files/view.php index f74b595c8da..8143b12d526 100644 --- a/lib/private/files/view.php +++ b/lib/private/files/view.php @@ -710,7 +710,10 @@ class View { return false; } $defaultRoot = Filesystem::getRoot(); - return (strlen($this->fakeRoot) >= strlen($defaultRoot)) && (substr($this->fakeRoot, 0, strlen($defaultRoot)) === $defaultRoot); + if($this->fakeRoot === $defaultRoot){ + return true; + } + return (strlen($this->fakeRoot) > strlen($defaultRoot)) && (substr($this->fakeRoot, 0, strlen($defaultRoot) + 1) === $defaultRoot . '/'); } private function runHooks($hooks, $path, $post = false) { diff --git a/tests/lib/files/view.php b/tests/lib/files/view.php index a5107c351f4..b2dd3963f1c 100644 --- a/tests/lib/files/view.php +++ b/tests/lib/files/view.php @@ -398,6 +398,24 @@ class View extends \PHPUnit_Framework_TestCase { $this->createHookPath = $params['path']; } + /** + * @medium + */ + function testViewHooksIfRootStartsTheSame() { + $storage1 = $this->getTestStorage(); + $storage2 = $this->getTestStorage(); + $defaultRoot = \OC\Files\Filesystem::getRoot(); + \OC\Files\Filesystem::mount($storage1, array(), '/'); + \OC\Files\Filesystem::mount($storage2, array(), $defaultRoot . '_substorage'); + \OC_Hook::connect('OC_Filesystem', 'post_write', $this, 'dummyHook'); + + $subView = new \OC\Files\View($defaultRoot . '_substorage'); + $this->hookPath = null; + + $subView->file_put_contents('/foo.txt', 'asd'); + $this->assertNull($this->hookPath); + } + public function testEditNoCreateHook() { $storage1 = $this->getTestStorage(); $storage2 = $this->getTestStorage(); |