summaryrefslogtreecommitdiffstats
path: root/lib/private
diff options
context:
space:
mode:
Diffstat (limited to 'lib/private')
-rw-r--r--lib/private/Accounts/AccountManager.php2
-rw-r--r--lib/private/Authentication/LoginCredentials/Store.php2
-rw-r--r--lib/private/Avatar/AvatarManager.php25
-rw-r--r--lib/private/Comments/Manager.php7
-rw-r--r--lib/private/ContactsManager.php3
-rw-r--r--lib/private/Encryption/HookManager.php38
-rw-r--r--lib/private/Federation/CloudFederationProviderManager.php3
-rw-r--r--lib/private/Files/ObjectStore/ObjectStoreStorage.php2
-rw-r--r--lib/private/Files/SetupManager.php14
-rw-r--r--lib/private/Files/Storage/Local.php14
-rw-r--r--lib/private/Files/Stream/SeekableHttpStream.php13
-rw-r--r--lib/private/IntegrityCheck/Checker.php3
-rw-r--r--lib/private/Repair/RepairMimeTypes.php13
-rw-r--r--lib/private/Template/JSConfigHelper.php4
-rw-r--r--lib/private/User/User.php8
15 files changed, 99 insertions, 52 deletions
diff --git a/lib/private/Accounts/AccountManager.php b/lib/private/Accounts/AccountManager.php
index b80c7887591..bdf33d73c29 100644
--- a/lib/private/Accounts/AccountManager.php
+++ b/lib/private/Accounts/AccountManager.php
@@ -220,7 +220,7 @@ class AccountManager implements IAccountManager {
foreach ($properties as $property) {
if (strlen($property->getValue()) > 2048) {
if ($throwOnData) {
- throw new InvalidArgumentException();
+ throw new InvalidArgumentException($property->getName());
} else {
$property->setValue('');
}
diff --git a/lib/private/Authentication/LoginCredentials/Store.php b/lib/private/Authentication/LoginCredentials/Store.php
index 0ab4c9a37cc..d3db0444664 100644
--- a/lib/private/Authentication/LoginCredentials/Store.php
+++ b/lib/private/Authentication/LoginCredentials/Store.php
@@ -100,7 +100,7 @@ class Store implements IStore {
} catch (SessionNotAvailableException $ex) {
$this->logger->debug('could not get login credentials because session is unavailable', ['app' => 'core', 'exception' => $ex]);
} catch (InvalidTokenException $ex) {
- $this->logger->debug('could not get login credentials because the token is invalid: ' . $ex->getMessage(), ['app' => 'core', 'exception' => $ex]);
+ $this->logger->debug('could not get login credentials because the token is invalid: ' . $ex->getMessage(), ['app' => 'core']);
$trySession = true;
} catch (PasswordlessTokenException $ex) {
$this->logger->debug('could not get login credentials because the token has no password', ['app' => 'core', 'exception' => $ex]);
diff --git a/lib/private/Avatar/AvatarManager.php b/lib/private/Avatar/AvatarManager.php
index 77138085dc9..ec9bed40850 100644
--- a/lib/private/Avatar/AvatarManager.php
+++ b/lib/private/Avatar/AvatarManager.php
@@ -136,20 +136,23 @@ class AvatarManager implements IAvatarManager {
$avatarScope = '';
}
- if (
+ switch ($avatarScope) {
// v2-private scope hides the avatar from public access and from unknown users
- $avatarScope === IAccountManager::SCOPE_PRIVATE
- && (
- // accessing from public link
- $requestingUser === null
- // logged in, but unknown to user
- || !$this->knownUserService->isKnownToUser($requestingUser->getUID(), $userId)
- )) {
- // use a placeholder avatar which caches the generated images
- return new PlaceholderAvatar($folder, $user, $this->logger);
+ case IAccountManager::SCOPE_PRIVATE:
+ if ($requestingUser !== null && $this->knownUserService->isKnownToUser($requestingUser->getUID(), $userId)) {
+ return new UserAvatar($folder, $this->l, $user, $this->logger, $this->config);
+ }
+ break;
+ case IAccountManager::SCOPE_LOCAL:
+ case IAccountManager::SCOPE_FEDERATED:
+ case IAccountManager::SCOPE_PUBLISHED:
+ return new UserAvatar($folder, $this->l, $user, $this->logger, $this->config);
+ default:
+ // use a placeholder avatar which caches the generated images
+ return new PlaceholderAvatar($folder, $user, $this->logger);
}
- return new UserAvatar($folder, $this->l, $user, $this->logger, $this->config);
+ return new PlaceholderAvatar($folder, $user, $this->logger);
}
/**
diff --git a/lib/private/Comments/Manager.php b/lib/private/Comments/Manager.php
index 4a06ac62f1e..b7532222c33 100644
--- a/lib/private/Comments/Manager.php
+++ b/lib/private/Comments/Manager.php
@@ -1258,8 +1258,6 @@ class Manager implements ICommentsManager {
}
private function sumReactions(string $parentId): void {
- $qb = $this->dbConn->getQueryBuilder();
-
$totalQuery = $this->dbConn->getQueryBuilder();
$totalQuery
->selectAlias(
@@ -1273,7 +1271,7 @@ class Manager implements ICommentsManager {
)
->selectAlias($totalQuery->func()->count('id'), 'total')
->from('reactions', 'r')
- ->where($totalQuery->expr()->eq('r.parent_id', $qb->createNamedParameter($parentId)))
+ ->where($totalQuery->expr()->eq('r.parent_id', $totalQuery->createNamedParameter($parentId)))
->groupBy('r.reaction')
->orderBy('total', 'DESC')
->addOrderBy('r.reaction', 'ASC')
@@ -1291,9 +1289,10 @@ class Manager implements ICommentsManager {
)
->from($jsonQuery->createFunction('(' . $totalQuery->getSQL() . ')'), 'json');
+ $qb = $this->dbConn->getQueryBuilder();
$qb
->update('comments')
- ->set('reactions', $jsonQuery->createFunction('(' . $jsonQuery->getSQL() . ')'))
+ ->set('reactions', $qb->createFunction('(' . $jsonQuery->getSQL() . ')'))
->where($qb->expr()->eq('id', $qb->createNamedParameter($parentId)))
->executeStatement();
}
diff --git a/lib/private/ContactsManager.php b/lib/private/ContactsManager.php
index 937fb94a09a..68783e3f79b 100644
--- a/lib/private/ContactsManager.php
+++ b/lib/private/ContactsManager.php
@@ -6,6 +6,7 @@
* @author Joas Schilling <coding@schilljs.com>
* @author John Molakvoæ <skjnldsv@protonmail.com>
* @author Morris Jobke <hey@morrisjobke.de>
+ * @author Thomas Citharel <nextcloud@tcit.fr>
* @author Thomas Müller <thomas.mueller@tmit.eu>
* @author Tobia De Koninck <tobia@ledfan.be>
*
@@ -85,7 +86,7 @@ class ContactsManager implements IManager {
/**
* This function can be used to delete the contact identified by the given id
*
- * @param object $id the unique identifier to a contact
+ * @param int $id the unique identifier to a contact
* @param string $address_book_key identifier of the address book in which the contact shall be deleted
* @return bool successful or not
*/
diff --git a/lib/private/Encryption/HookManager.php b/lib/private/Encryption/HookManager.php
index a2d6b990a88..5081bcccf94 100644
--- a/lib/private/Encryption/HookManager.php
+++ b/lib/private/Encryption/HookManager.php
@@ -25,39 +25,51 @@ namespace OC\Encryption;
use OC\Files\Filesystem;
use OC\Files\View;
+use OC\Files\SetupManager;
use Psr\Log\LoggerInterface;
class HookManager {
- /**
- * @var Update
- */
- private static $updater;
+ private static ?Update $updater = null;
- public static function postShared($params) {
+ public static function postShared($params): void {
self::getUpdate()->postShared($params);
}
- public static function postUnshared($params) {
- self::getUpdate()->postUnshared($params);
+ public static function postUnshared($params): void {
+ // In case the unsharing happens in a background job, we don't have
+ // a session and we load instead the user from the UserManager
+ $path = Filesystem::getPath($params['fileSource']);
+ $owner = Filesystem::getOwner($path);
+ self::getUpdate($owner)->postUnshared($params);
}
- public static function postRename($params) {
+ public static function postRename($params): void {
self::getUpdate()->postRename($params);
}
- public static function postRestore($params) {
+ public static function postRestore($params): void {
self::getUpdate()->postRestore($params);
}
- /**
- * @return Update
- */
- private static function getUpdate() {
+ private static function getUpdate(?string $owner = null): Update {
if (is_null(self::$updater)) {
$user = \OC::$server->getUserSession()->getUser();
+ if (!$user && $owner) {
+ $user = \OC::$server->getUserManager()->get($owner);
+ }
+ if (!$user) {
+ throw new \Exception("Inconsistent data, File unshared, but owner not found. Should not happen");
+ }
+
$uid = '';
if ($user) {
$uid = $user->getUID();
}
+
+ $setupManager = \OC::$server->get(SetupManager::class);
+ if (!$setupManager->isSetupComplete($user)) {
+ $setupManager->setupForUser($user);
+ }
+
self::$updater = new Update(
new View(),
new Util(
diff --git a/lib/private/Federation/CloudFederationProviderManager.php b/lib/private/Federation/CloudFederationProviderManager.php
index c25d4a40363..f077e36d97d 100644
--- a/lib/private/Federation/CloudFederationProviderManager.php
+++ b/lib/private/Federation/CloudFederationProviderManager.php
@@ -150,11 +150,12 @@ class CloudFederationProviderManager implements ICloudFederationProviderManager
return (is_array($result)) ? $result : [];
}
} catch (\Exception $e) {
+ $this->logger->debug($e->getMessage(), ['exception' => $e]);
+
// if flat re-sharing is not supported by the remote server
// we re-throw the exception and fall back to the old behaviour.
// (flat re-shares has been introduced in Nextcloud 9.1)
if ($e->getCode() === Http::STATUS_INTERNAL_SERVER_ERROR) {
- $this->logger->debug($e->getMessage(), ['exception' => $e]);
throw $e;
}
}
diff --git a/lib/private/Files/ObjectStore/ObjectStoreStorage.php b/lib/private/Files/ObjectStore/ObjectStoreStorage.php
index adb3928b28a..898f64d97c2 100644
--- a/lib/private/Files/ObjectStore/ObjectStoreStorage.php
+++ b/lib/private/Files/ObjectStore/ObjectStoreStorage.php
@@ -335,6 +335,7 @@ class ObjectStoreStorage extends \OC\Files\Storage\Common {
$handle = fopen($tmpFile, $mode);
return CallbackWrapper::wrap($handle, null, null, function () use ($path, $tmpFile) {
$this->writeBack($tmpFile, $path);
+ unlink($tmpFile);
});
case 'a':
case 'ab':
@@ -352,6 +353,7 @@ class ObjectStoreStorage extends \OC\Files\Storage\Common {
$handle = fopen($tmpFile, $mode);
return CallbackWrapper::wrap($handle, null, null, function () use ($path, $tmpFile) {
$this->writeBack($tmpFile, $path);
+ unlink($tmpFile);
});
}
return false;
diff --git a/lib/private/Files/SetupManager.php b/lib/private/Files/SetupManager.php
index 040ba6b898f..876514b473c 100644
--- a/lib/private/Files/SetupManager.php
+++ b/lib/private/Files/SetupManager.php
@@ -380,13 +380,9 @@ class SetupManager {
return;
}
- // for the user's home folder, it's always the home mount
- if (rtrim($path) === "/" . $user->getUID() . "/files") {
- if ($includeChildren) {
- $this->setupForUser($user);
- } else {
- $this->oneTimeUserSetup($user);
- }
+ // for the user's home folder, and includes children we need everything always
+ if (rtrim($path) === "/" . $user->getUID() . "/files" && $includeChildren) {
+ $this->setupForUser($user);
return;
}
@@ -403,6 +399,10 @@ class SetupManager {
return;
}
+ if (!$this->isSetupStarted($user)) {
+ $this->oneTimeUserSetup($user);
+ }
+
$mounts = [];
if (!in_array($cachedMount->getMountProvider(), $setupProviders)) {
$setupProviders[] = $cachedMount->getMountProvider();
diff --git a/lib/private/Files/Storage/Local.php b/lib/private/Files/Storage/Local.php
index ee8a8c7d161..4996572a40e 100644
--- a/lib/private/Files/Storage/Local.php
+++ b/lib/private/Files/Storage/Local.php
@@ -15,6 +15,7 @@
* @author Jörn Friedrich Dreyer <jfd@butonic.de>
* @author Klaas Freitag <freitag@owncloud.com>
* @author Lukas Reschke <lukas@statuscode.ch>
+ * @author Martin Brugnara <martin@0x6d62.eu>
* @author Michael Gapczynski <GapczynskiM@gmail.com>
* @author Morris Jobke <hey@morrisjobke.de>
* @author Robin Appelman <robin@icewind.nl>
@@ -66,6 +67,8 @@ class Local extends \OC\Files\Storage\Common {
private IMimeTypeDetector $mimeTypeDetector;
+ private $defUMask;
+
public function __construct($arguments) {
if (!isset($arguments['datadir']) || !is_string($arguments['datadir'])) {
throw new \InvalidArgumentException('No data directory set for local storage');
@@ -84,6 +87,7 @@ class Local extends \OC\Files\Storage\Common {
$this->dataDirLength = strlen($this->realDataDir);
$this->config = \OC::$server->get(IConfig::class);
$this->mimeTypeDetector = \OC::$server->get(IMimeTypeDetector::class);
+ $this->defUMask = $this->config->getSystemValue('localstorage.umask', 0022);
}
public function __destruct() {
@@ -95,7 +99,7 @@ class Local extends \OC\Files\Storage\Common {
public function mkdir($path) {
$sourcePath = $this->getSourcePath($path);
- $oldMask = umask(022);
+ $oldMask = umask($this->defUMask);
$result = @mkdir($sourcePath, 0777, true);
umask($oldMask);
return $result;
@@ -273,7 +277,7 @@ class Local extends \OC\Files\Storage\Common {
if ($this->file_exists($path) and !$this->isUpdatable($path)) {
return false;
}
- $oldMask = umask(022);
+ $oldMask = umask($this->defUMask);
if (!is_null($mtime)) {
$result = @touch($this->getSourcePath($path), $mtime);
} else {
@@ -292,7 +296,7 @@ class Local extends \OC\Files\Storage\Common {
}
public function file_put_contents($path, $data) {
- $oldMask = umask(022);
+ $oldMask = umask($this->defUMask);
$result = file_put_contents($this->getSourcePath($path), $data);
umask($oldMask);
return $result;
@@ -365,7 +369,7 @@ class Local extends \OC\Files\Storage\Common {
if ($this->is_dir($path1)) {
return parent::copy($path1, $path2);
} else {
- $oldMask = umask(022);
+ $oldMask = umask($this->defUMask);
$result = copy($this->getSourcePath($path1), $this->getSourcePath($path2));
umask($oldMask);
return $result;
@@ -373,7 +377,7 @@ class Local extends \OC\Files\Storage\Common {
}
public function fopen($path, $mode) {
- $oldMask = umask(022);
+ $oldMask = umask($this->defUMask);
$result = fopen($this->getSourcePath($path), $mode);
umask($oldMask);
return $result;
diff --git a/lib/private/Files/Stream/SeekableHttpStream.php b/lib/private/Files/Stream/SeekableHttpStream.php
index af797c7720d..820a681bd07 100644
--- a/lib/private/Files/Stream/SeekableHttpStream.php
+++ b/lib/private/Files/Stream/SeekableHttpStream.php
@@ -24,6 +24,7 @@
namespace OC\Files\Stream;
use Icewind\Streams\File;
+use Icewind\Streams\Wrapper;
/**
* A stream wrapper that uses http range requests to provide a seekable stream for http reading
@@ -92,6 +93,18 @@ class SeekableHttpStream implements File {
}
$responseHead = stream_get_meta_data($this->current)['wrapper_data'];
+
+ while ($responseHead instanceof Wrapper) {
+ $wrapperOptions = stream_context_get_options($responseHead->context);
+ foreach ($wrapperOptions as $options) {
+ if (isset($options['source']) && is_resource($options['source'])) {
+ $responseHead = stream_get_meta_data($options['source'])['wrapper_data'];
+ continue 2;
+ }
+ }
+ throw new \Exception("Failed to get source stream from stream wrapper of " . get_class($responseHead));
+ }
+
$rangeHeaders = array_values(array_filter($responseHead, function ($v) {
return preg_match('#^content-range:#i', $v) === 1;
}));
diff --git a/lib/private/IntegrityCheck/Checker.php b/lib/private/IntegrityCheck/Checker.php
index 273eba35446..ba555cff438 100644
--- a/lib/private/IntegrityCheck/Checker.php
+++ b/lib/private/IntegrityCheck/Checker.php
@@ -201,7 +201,8 @@ class Checker {
if ($filename === $this->environmentHelper->getServerRoot() . '/core/js/mimetypelist.js') {
$oldMimetypeList = new GenerateMimetypeFileBuilder();
$newFile = $oldMimetypeList->generateFile($this->mimeTypeDetector->getAllAliases());
- if ($newFile === file_get_contents($filename)) {
+ $oldFile = $this->fileAccessHelper->file_get_contents($filename);
+ if ($newFile === $oldFile) {
$hashes[$relativeFileName] = hash('sha512', $oldMimetypeList->generateFile($this->mimeTypeDetector->getOnlyDefaultAliases()));
continue;
}
diff --git a/lib/private/Repair/RepairMimeTypes.php b/lib/private/Repair/RepairMimeTypes.php
index 61512627258..5b216331dc7 100644
--- a/lib/private/Repair/RepairMimeTypes.php
+++ b/lib/private/Repair/RepairMimeTypes.php
@@ -211,6 +211,15 @@ class RepairMimeTypes implements IRepairStep {
return $this->updateMimetypes($updatedMimetypes);
}
+ private function introduceOnlyofficeFormType() {
+ $updatedMimetypes = [
+ "oform" => "application/vnd.openxmlformats-officedocument.wordprocessingml.document.oform",
+ "docxf" => "application/vnd.openxmlformats-officedocument.wordprocessingml.document.docxf",
+ ];
+
+ return $this->updateMimetypes($updatedMimetypes);
+ }
+
/**
* Fix mime types
@@ -260,5 +269,9 @@ class RepairMimeTypes implements IRepairStep {
if (version_compare($ocVersionFromBeforeUpdate, '23.0.0.2', '<') && $this->introduceFlatOpenDocumentType()) {
$out->info('Fixed Flat OpenDocument mime types');
}
+
+ if (version_compare($ocVersionFromBeforeUpdate, '25.0.0.2', '<') && $this->introduceOnlyofficeFormType()) {
+ $out->info('Fixed ONLYOFFICE Forms OpenXML mime types');
+ }
}
}
diff --git a/lib/private/Template/JSConfigHelper.php b/lib/private/Template/JSConfigHelper.php
index a7b9fd35fd8..5f23b471837 100644
--- a/lib/private/Template/JSConfigHelper.php
+++ b/lib/private/Template/JSConfigHelper.php
@@ -47,6 +47,7 @@ use OCP\IInitialStateService;
use OCP\IL10N;
use OCP\ISession;
use OCP\IURLGenerator;
+use OCP\ILogger;
use OCP\IUser;
use OCP\User\Backend\IPasswordConfirmationBackend;
use OCP\Util;
@@ -176,6 +177,9 @@ class JSConfigHelper {
'sharing.maxAutocompleteResults' => max(0, $this->config->getSystemValueInt('sharing.maxAutocompleteResults', Constants::SHARING_MAX_AUTOCOMPLETE_RESULTS_DEFAULT)),
'sharing.minSearchStringLength' => $this->config->getSystemValueInt('sharing.minSearchStringLength', 0),
'blacklist_files_regex' => FileInfo::BLACKLIST_FILES_REGEX,
+ 'loglevel' => $this->config->getSystemValue('loglevel_frontend',
+ $this->config->getSystemValue('loglevel', ILogger::WARN)
+ ),
];
$array = [
diff --git a/lib/private/User/User.php b/lib/private/User/User.php
index de9af35f541..c5306d1df27 100644
--- a/lib/private/User/User.php
+++ b/lib/private/User/User.php
@@ -555,15 +555,9 @@ class User implements IUser {
return $uid . '@' . $server;
}
- /**
- * @param string $url
- * @return string
- */
- private function removeProtocolFromUrl($url) {
+ private function removeProtocolFromUrl(string $url): string {
if (strpos($url, 'https://') === 0) {
return substr($url, strlen('https://'));
- } elseif (strpos($url, 'http://') === 0) {
- return substr($url, strlen('http://'));
}
return $url;