Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
m---------3rdparty0
-rw-r--r--lib/private/Files/Storage/Wrapper/Encryption.php25
-rw-r--r--lib/private/Group/Database.php6
-rw-r--r--tests/lib/Files/Storage/Wrapper/EncryptionTest.php18
4 files changed, 31 insertions, 18 deletions
diff --git a/3rdparty b/3rdparty
-Subproject d60cb43400cd80f7657aefca77d76bf35313894
+Subproject b9519d3f7d57b17401ccf4eee98455570c494e6
diff --git a/lib/private/Files/Storage/Wrapper/Encryption.php b/lib/private/Files/Storage/Wrapper/Encryption.php
index d6143dccfb3..22201c9db83 100644
--- a/lib/private/Files/Storage/Wrapper/Encryption.php
+++ b/lib/private/Files/Storage/Wrapper/Encryption.php
@@ -923,21 +923,20 @@ class Encryption extends Wrapper {
$path = $realFile;
}
- $firstBlock = $this->readFirstBlock($path);
- $result = $this->parseRawHeader($firstBlock);
+ $result = [];
+
+ // first check if it is an encrypted file at all
+ // We would do query to filecache only if we know that entry in filecache exists
+
+ $info = $this->getCache()->get($path);
+ if (isset($info['encrypted']) && $info['encrypted'] === true) {
+ $firstBlock = $this->readFirstBlock($path);
+ $result = $this->parseRawHeader($firstBlock);
- // if the header doesn't contain a encryption module we check if it is a
- // legacy file. If true, we add the default encryption module
- if (!isset($result[Util::HEADER_ENCRYPTION_MODULE_KEY])) {
- if (!empty($result)) {
+ // if the header doesn't contain a encryption module we check if it is a
+ // legacy file. If true, we add the default encryption module
+ if (!isset($result[Util::HEADER_ENCRYPTION_MODULE_KEY]) && (!empty($result) || $exists)) {
$result[Util::HEADER_ENCRYPTION_MODULE_KEY] = 'OC_DEFAULT_MODULE';
- } elseif ($exists) {
- // if the header was empty we have to check first if it is a encrypted file at all
- // We would do query to filecache only if we know that entry in filecache exists
- $info = $this->getCache()->get($path);
- if (isset($info['encrypted']) && $info['encrypted'] === true) {
- $result[Util::HEADER_ENCRYPTION_MODULE_KEY] = 'OC_DEFAULT_MODULE';
- }
}
}
diff --git a/lib/private/Group/Database.php b/lib/private/Group/Database.php
index 97094c67728..a142c9f841b 100644
--- a/lib/private/Group/Database.php
+++ b/lib/private/Group/Database.php
@@ -456,7 +456,11 @@ class Database extends ABackend implements
public function getDisplayName(string $gid): string {
if (isset($this->groupCache[$gid])) {
- return $this->groupCache[$gid]['displayname'];
+ $displayName = $this->groupCache[$gid]['displayname'];
+
+ if (isset($displayName) && trim($displayName) !== '') {
+ return $displayName;
+ }
}
$this->fixDI();
diff --git a/tests/lib/Files/Storage/Wrapper/EncryptionTest.php b/tests/lib/Files/Storage/Wrapper/EncryptionTest.php
index eccec7c28d5..d152a51ed85 100644
--- a/tests/lib/Files/Storage/Wrapper/EncryptionTest.php
+++ b/tests/lib/Files/Storage/Wrapper/EncryptionTest.php
@@ -573,6 +573,14 @@ class EncryptionTest extends Storage {
$this->arrayCache
]
)->getMock();
+
+ $cache = $this->getMockBuilder('\OC\Files\Cache\Cache')
+ ->disableOriginalConstructor()->getMock();
+ $cache->expects($this->any())
+ ->method('get')
+ ->willReturnCallback(function ($path) {
+ return ['encrypted' => true, 'path' => $path];
+ });
$instance = $this->getMockBuilder('\OC\Files\Storage\Wrapper\Encryption')
->setConstructorArgs(
@@ -586,9 +594,11 @@ class EncryptionTest extends Storage {
$this->encryptionManager, $util, $this->logger, $this->file, null, $this->keyStore, $this->update, $this->mountManager, $this->arrayCache
]
)
- ->setMethods(['readFirstBlock', 'parseRawHeader'])
+ ->setMethods(['getCache','readFirstBlock', 'parseRawHeader'])
->getMock();
-
+
+ $instance->expects($this->once())->method('getCache')->willReturn($cache);
+
$instance->expects($this->once())->method(('parseRawHeader'))
->willReturn([Util::HEADER_ENCRYPTION_MODULE_KEY => 'OC_DEFAULT_MODULE']);
@@ -661,8 +671,8 @@ class EncryptionTest extends Storage {
->setMethods(['readFirstBlock', 'parseRawHeader', 'getCache'])
->getMock();
- $instance->expects($this->once())->method(('parseRawHeader'))->willReturn($header);
- $instance->expects($this->any())->method('getCache')->willReturn($cache);
+ $instance->expects($this->any())->method(('parseRawHeader'))->willReturn($header);
+ $instance->expects($this->once())->method('getCache')->willReturn($cache);
$result = $this->invokePrivate($instance, 'getHeader', ['test.txt']);
$this->assertSameSize($expected, $result);