diff options
-rw-r--r-- | apps/encryption/lib/migration.php | 2 | ||||
-rw-r--r-- | apps/files/js/filelist.js | 8 | ||||
-rw-r--r-- | apps/files/tests/js/filelistSpec.js | 11 | ||||
-rw-r--r-- | core/command/upgrade.php | 3 | ||||
-rw-r--r-- | lib/private/files/storage/wrapper/encryption.php | 8 | ||||
-rw-r--r-- | lib/private/updater.php | 1 | ||||
-rw-r--r-- | settings/js/apps.js | 2 | ||||
-rw-r--r-- | tests/lib/files/storage/wrapper/encryption.php | 63 |
8 files changed, 90 insertions, 8 deletions
diff --git a/apps/encryption/lib/migration.php b/apps/encryption/lib/migration.php index e4e5595efa1..3acf77e4c44 100644 --- a/apps/encryption/lib/migration.php +++ b/apps/encryption/lib/migration.php @@ -54,6 +54,7 @@ class Migration { public function __destruct() { $this->view->deleteAll('files_encryption/public_keys'); $this->updateFileCache(); + $this->config->deleteAppValue('files_encryption', 'installed_version'); } /** @@ -139,7 +140,6 @@ class Migration { public function updateDB() { // delete left-over from old encryption which is no longer needed - $this->config->deleteAppValue('files_encryption', 'installed_version'); $this->config->deleteAppValue('files_encryption', 'ocsid'); $this->config->deleteAppValue('files_encryption', 'types'); $this->config->deleteAppValue('files_encryption', 'enabled'); diff --git a/apps/files/js/filelist.js b/apps/files/js/filelist.js index ed83c2be9df..5fc444e6121 100644 --- a/apps/files/js/filelist.js +++ b/apps/files/js/filelist.js @@ -1123,6 +1123,14 @@ return false; } + // Firewall Blocked request? + if (result.status === 403) { + // Go home + this.changeDirectory('/'); + OC.Notification.show(t('files', 'This operation is forbidden')); + return false; + } + if (result.status === 404) { // go back home this.changeDirectory('/'); diff --git a/apps/files/tests/js/filelistSpec.js b/apps/files/tests/js/filelistSpec.js index aa44c92792d..6bcef8b6f4f 100644 --- a/apps/files/tests/js/filelistSpec.js +++ b/apps/files/tests/js/filelistSpec.js @@ -1279,6 +1279,17 @@ describe('OCA.Files.FileList tests', function() { fakeServer.respond(); expect(fileList.getCurrentDirectory()).toEqual('/'); }); + it('switches to root dir when current directory is forbidden', function() { + fakeServer.respondWith(/\/index\.php\/apps\/files\/ajax\/list.php\?dir=%2funexist/, [ + 403, { + "Content-Type": "application/json" + }, + '' + ]); + fileList.changeDirectory('/unexist'); + fakeServer.respond(); + expect(fileList.getCurrentDirectory()).toEqual('/'); + }); it('shows mask before loading file list then hides it at the end', function() { var showMaskStub = sinon.stub(fileList, 'showMask'); var hideMaskStub = sinon.stub(fileList, 'hideMask'); diff --git a/core/command/upgrade.php b/core/command/upgrade.php index 6d87f0a9891..cf376148a00 100644 --- a/core/command/upgrade.php +++ b/core/command/upgrade.php @@ -158,6 +158,9 @@ class Upgrade extends Command { $updater->listen('\OC\Updater', 'appUpgradeCheck', function () use ($output) { $output->writeln('<info>Checked database schema update for apps</info>'); }); + $updater->listen('\OC\Updater', 'appUpgradeStarted', function ($app, $version) use ($output) { + $output->writeln("<info>Updating <$app> ...</info>"); + }); $updater->listen('\OC\Updater', 'appUpgrade', function ($app, $version) use ($output) { $output->writeln("<info>Updated <$app> to $version</info>"); }); diff --git a/lib/private/files/storage/wrapper/encryption.php b/lib/private/files/storage/wrapper/encryption.php index 056f823c18b..8d1f80c53c0 100644 --- a/lib/private/files/storage/wrapper/encryption.php +++ b/lib/private/files/storage/wrapper/encryption.php @@ -349,7 +349,8 @@ class Encryption extends Wrapper { if ($this->util->isExcluded($fullPath) === false) { $size = $unencryptedSize = 0; - $targetExists = $this->file_exists($path); + $realFile = $this->util->stripPartialFileExtension($path); + $targetExists = $this->file_exists($realFile); $targetIsEncrypted = false; if ($targetExists) { // in case the file exists we require the explicit module as @@ -605,8 +606,9 @@ class Encryption extends Wrapper { */ protected function getHeader($path) { $header = ''; - if ($this->storage->file_exists($path)) { - $handle = $this->storage->fopen($path, 'r'); + $realFile = $this->util->stripPartialFileExtension($path); + if ($this->storage->file_exists($realFile)) { + $handle = $this->storage->fopen($realFile, 'r'); $firstBlock = fread($handle, $this->util->getHeaderSize()); fclose($handle); if (substr($firstBlock, 0, strlen(Util::HEADER_START)) === Util::HEADER_START) { diff --git a/lib/private/updater.php b/lib/private/updater.php index 72998c4b3d2..00c6569a52f 100644 --- a/lib/private/updater.php +++ b/lib/private/updater.php @@ -391,6 +391,7 @@ class Updater extends BasicEmitter { foreach ($stacks as $type => $stack) { foreach ($stack as $appId) { if (\OC_App::shouldUpgrade($appId)) { + $this->emit('\OC\Updater', 'appUpgradeStarted', array($appId, \OC_App::getAppVersion($appId))); \OC_App::updateApp($appId); $this->emit('\OC\Updater', 'appUpgrade', array($appId, \OC_App::getAppVersion($appId))); } diff --git a/settings/js/apps.js b/settings/js/apps.js index 2863e86dba8..7849e1b7573 100644 --- a/settings/js/apps.js +++ b/settings/js/apps.js @@ -119,7 +119,7 @@ OC.Settings.Apps = OC.Settings.Apps || { $('.app-level .official').tipsy({fallback: t('settings', 'Official apps are developed by and within the ownCloud community. They offer functionality central to ownCloud and are ready for production use.')}); $('.app-level .approved').tipsy({fallback: t('settings', 'Approved apps are developed by trusted developers and have passed a cursory security check. They are actively maintained in an open code repository and their maintainers deem them to be stable for casual to normal use.')}); - $('.app-level .experimental').tipsy({fallback: t('settings', 'This app is not checked for security issues and is new or known to be unstable. Install on your own risk.')}); + $('.app-level .experimental').tipsy({fallback: t('settings', 'This app is not checked for security issues and is new or known to be unstable. Install at your own risk.')}); }, complete: function() { $('#apps-list').removeClass('icon-loading'); diff --git a/tests/lib/files/storage/wrapper/encryption.php b/tests/lib/files/storage/wrapper/encryption.php index 520091df42d..175713de497 100644 --- a/tests/lib/files/storage/wrapper/encryption.php +++ b/tests/lib/files/storage/wrapper/encryption.php @@ -68,6 +68,17 @@ class Encryption extends \Test\Files\Storage\Storage { */ private $mountManager; + /** + * @var \OC\Group\Manager | \PHPUnit_Framework_MockObject_MockObject + */ + private $groupManager; + + /** + * @var \OCP\IConfig | \PHPUnit_Framework_MockObject_MockObject + */ + private $config; + + /** @var integer dummy unencrypted size */ private $dummySize = -1; @@ -84,14 +95,16 @@ class Encryption extends \Test\Files\Storage\Storage { ->method('getEncryptionModule') ->willReturn($mockModule); - $config = $this->getMockBuilder('\OCP\IConfig') + $this->config = $this->getMockBuilder('\OCP\IConfig') ->disableOriginalConstructor() ->getMock(); - $groupManager = $this->getMockBuilder('\OC\Group\Manager') + $this->groupManager = $this->getMockBuilder('\OC\Group\Manager') ->disableOriginalConstructor() ->getMock(); - $this->util = $this->getMock('\OC\Encryption\Util', ['getUidAndFilename', 'isFile', 'isExcluded'], [new View(), new \OC\User\Manager(), $groupManager, $config]); + $this->util = $this->getMock('\OC\Encryption\Util', + ['getUidAndFilename', 'isFile', 'isExcluded'], + [new View(), new \OC\User\Manager(), $this->groupManager, $this->config]); $this->util->expects($this->any()) ->method('getUidAndFilename') ->willReturnCallback(function ($path) { @@ -365,4 +378,48 @@ class Encryption extends \Test\Files\Storage\Storage { array(false, true), ); } + + /** + * @dataProvider dataTestGetHeader + * @param $path + * @param $strippedPath + */ + public function testGetHeader($path, $strippedPath) { + + $sourceStorage = $this->getMockBuilder('\OC\Files\Storage\Storage') + ->disableOriginalConstructor()->getMock(); + + $util = $this->getMockBuilder('\OC\Encryption\Util') + ->setConstructorArgs([new View(), new \OC\User\Manager(), $this->groupManager, $this->config]) + ->getMock(); + + $instance = $this->getMockBuilder('\OC\Files\Storage\Wrapper\Encryption') + ->setConstructorArgs( + [ + [ + 'storage' => $sourceStorage, + 'root' => 'foo', + 'mountPoint' => '/', + 'mount' => $this->mount + ], + $this->encryptionManager, $util, $this->logger, $this->file, null, $this->keyStore, $this->update, $this->mountManager + ] + ) + ->getMock(); + + $util->expects($this->once())->method('stripPartialFileExtension') + ->with($path)->willReturn($strippedPath); + $sourceStorage->expects($this->once())->method('file_exists') + ->with($strippedPath)->willReturn(false); + + $this->invokePrivate($instance, 'getHeader', [$path]); + } + + public function dataTestGetHeader() { + return array( + array('/foo/bar.txt', '/foo/bar.txt'), + array('/foo/bar.txt.part', '/foo/bar.txt'), + array('/foo/bar.txt.ocTransferId7437493.part', '/foo/bar.txt'), + ); + } } |