diff options
author | Vincent Petry <pvince81@owncloud.com> | 2016-08-18 12:00:52 +0200 |
---|---|---|
committer | Thomas Müller <DeepDiver1975@users.noreply.github.com> | 2016-08-18 12:00:52 +0200 |
commit | fb9576df9e9ce3cb1d67e40a95f614c4c8dc6510 (patch) | |
tree | ddd381c233fe7314bb2c7b90326b12bc1f27eaf7 | |
parent | d4ec50c6374809635d6bc36b797a36b099d13654 (diff) | |
download | nextcloud-server-fb9576df9e9ce3cb1d67e40a95f614c4c8dc6510.tar.gz nextcloud-server-fb9576df9e9ce3cb1d67e40a95f614c4c8dc6510.zip |
[stable9.1] Dont decrypt shared files (#25831)
* Take from https://github.com/nextcloud/server/pull/608/commits/351cab6bce41b53f9efd4ba9aed4e7435f843691 - THX @schiessle
* Fix unit tests
-rw-r--r-- | lib/private/Encryption/DecryptAll.php | 4 | ||||
-rw-r--r-- | tests/lib/Encryption/DecryptAllTest.php | 10 |
2 files changed, 11 insertions, 3 deletions
diff --git a/lib/private/Encryption/DecryptAll.php b/lib/private/Encryption/DecryptAll.php index 34a3e1bff91..376cdd3d5aa 100644 --- a/lib/private/Encryption/DecryptAll.php +++ b/lib/private/Encryption/DecryptAll.php @@ -206,6 +206,10 @@ class DecryptAll { while ($root = array_pop($directories)) { $content = $this->rootView->getDirectoryContent($root); foreach ($content as $file) { + // only decrypt files owned by the user + if($file->getStorage()->instanceOfStorage('OC\Files\Storage\Shared')) { + continue; + } $path = $root . '/' . $file['name']; if ($this->rootView->is_dir($path)) { $directories[] = $path; diff --git a/tests/lib/Encryption/DecryptAllTest.php b/tests/lib/Encryption/DecryptAllTest.php index d7cf2fb7baf..3f7cb59c8f4 100644 --- a/tests/lib/Encryption/DecryptAllTest.php +++ b/tests/lib/Encryption/DecryptAllTest.php @@ -239,6 +239,10 @@ class DecryptAllTest extends TestCase { } public function testDecryptUsersFiles() { + $storage = $this->getMockBuilder('OC\Files\Storage\Shared') + ->disableOriginalConstructor() + ->getMock(); + /** @var DecryptAll | \PHPUnit_Framework_MockObject_MockObject $instance */ $instance = $this->getMockBuilder('OC\Encryption\DecryptAll') ->setConstructorArgs( @@ -254,15 +258,15 @@ class DecryptAllTest extends TestCase { $this->view->expects($this->at(0))->method('getDirectoryContent') ->with('/user1/files')->willReturn( [ - new FileInfo('path', null, 'intPath', ['name' => 'foo', 'type'=>'dir'], null), - new FileInfo('path', null, 'intPath', ['name' => 'bar', 'type'=>'file', 'encrypted'=>true], null) + new FileInfo('path', $storage, 'intPath', ['name' => 'foo', 'type'=>'dir'], null), + new FileInfo('path', $storage, 'intPath', ['name' => 'bar', 'type'=>'file', 'encrypted'=>true], null) ] ); $this->view->expects($this->at(3))->method('getDirectoryContent') ->with('/user1/files/foo')->willReturn( [ - new FileInfo('path', null, 'intPath', ['name' => 'subfile', 'type'=>'file', 'encrypted'=>true], null) + new FileInfo('path', $storage, 'intPath', ['name' => 'subfile', 'type'=>'file', 'encrypted'=>true], null) ] ); |