mirror of
https://github.com/nextcloud/server.git
synced 2024-08-31 05:58:34 +02:00
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 ...
This commit is contained in:
commit
4c166fa361
@ -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) {
|
||||
|
@ -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();
|
||||
|
Loading…
Reference in New Issue
Block a user