summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/l10n/fr.js1
-rw-r--r--lib/l10n/fr.json1
-rw-r--r--lib/l10n/sq.js3
-rw-r--r--lib/l10n/sq.json3
-rw-r--r--lib/private/App/CodeChecker/CodeChecker.php2
-rw-r--r--lib/private/AppFramework/Middleware/Security/SecurityMiddleware.php2
-rw-r--r--lib/private/Authentication/TwoFactorAuth/Db/ProviderUserAssignmentDao.php25
-rw-r--r--lib/private/Authentication/TwoFactorAuth/Manager.php17
-rw-r--r--lib/private/Authentication/TwoFactorAuth/ProviderSet.php11
-rw-r--r--lib/private/Avatar.php2
-rw-r--r--lib/private/DB/MigrationService.php3
-rw-r--r--lib/private/Files/Storage/DAV.php2
-rw-r--r--lib/private/Files/Stream/Encryption.php19
-rw-r--r--lib/private/Files/Type/Loader.php21
-rw-r--r--lib/private/Share/Constants.php3
-rw-r--r--lib/private/Share20/Manager.php10
-rw-r--r--lib/private/Share20/ProviderFactory.php34
-rw-r--r--lib/private/Template/IconsCacher.php2
-rw-r--r--lib/private/legacy/util.php4
19 files changed, 132 insertions, 33 deletions
diff --git a/lib/l10n/fr.js b/lib/l10n/fr.js
index 68a65f66f53..ad429ac3741 100644
--- a/lib/l10n/fr.js
+++ b/lib/l10n/fr.js
@@ -234,6 +234,7 @@ OC.L10N.register(
"Action \"%s\" not supported or implemented." : "Action \"%s\" non supportée ou implémentée.",
"Authentication failed, wrong token or provider ID given" : "Échec de l'authentification, jeton erroné ou identification du fournisseur donnée",
"Parameters missing in order to complete the request. Missing Parameters: \"%s\"" : "Paramètres manquants pour compléter la requête. Paramètres manquants : \"%s\"",
+ "ID \"%s\" already used by cloud federation provider \"%s\"" : "L'identifiant \"%s\" est déjà utilisé par le fournisseur de cloud \"%s\"",
"Cloud Federation Provider with ID: \"%s\" does not exist." : "Le fournisseur de cloud avec l'identifiant \"%s\" n'existe pas.",
"Could not obtain lock type %d on \"%s\"." : "Impossible d'obtenir le verrouillage de type %d sur \"%s\".",
"Storage unauthorized. %s" : "Espace de stockage non autorisé. %s",
diff --git a/lib/l10n/fr.json b/lib/l10n/fr.json
index e5d1654ab37..7f410a69896 100644
--- a/lib/l10n/fr.json
+++ b/lib/l10n/fr.json
@@ -232,6 +232,7 @@
"Action \"%s\" not supported or implemented." : "Action \"%s\" non supportée ou implémentée.",
"Authentication failed, wrong token or provider ID given" : "Échec de l'authentification, jeton erroné ou identification du fournisseur donnée",
"Parameters missing in order to complete the request. Missing Parameters: \"%s\"" : "Paramètres manquants pour compléter la requête. Paramètres manquants : \"%s\"",
+ "ID \"%s\" already used by cloud federation provider \"%s\"" : "L'identifiant \"%s\" est déjà utilisé par le fournisseur de cloud \"%s\"",
"Cloud Federation Provider with ID: \"%s\" does not exist." : "Le fournisseur de cloud avec l'identifiant \"%s\" n'existe pas.",
"Could not obtain lock type %d on \"%s\"." : "Impossible d'obtenir le verrouillage de type %d sur \"%s\".",
"Storage unauthorized. %s" : "Espace de stockage non autorisé. %s",
diff --git a/lib/l10n/sq.js b/lib/l10n/sq.js
index 896594115bd..326f427b029 100644
--- a/lib/l10n/sq.js
+++ b/lib/l10n/sq.js
@@ -213,10 +213,13 @@ OC.L10N.register(
"Storage connection error. %s" : "Gabim lidhje te depozita. %s",
"Storage is temporarily not available" : "Hapsira ruajtëse nuk është në dispozicion përkohësisht",
"Storage connection timeout. %s" : "Mbarim kohe lidhjeje për depozitën. %s",
+ "Personal" : "Personale",
+ "Admin" : "Administrator",
"APCu" : "APCu",
"Redis" : "Redis",
"Encryption" : "Enkriptimi",
"Tips & tricks" : "Këshilla dhe rrengje",
+ "App '%s' could not be installed!" : "Aplikacioni '%s' nuk mund të instalohet!",
"Sync clients" : "Klientë të sikronizuar"
},
"nplurals=2; plural=(n != 1);");
diff --git a/lib/l10n/sq.json b/lib/l10n/sq.json
index 6e6aa1c57bc..20731b2db31 100644
--- a/lib/l10n/sq.json
+++ b/lib/l10n/sq.json
@@ -211,10 +211,13 @@
"Storage connection error. %s" : "Gabim lidhje te depozita. %s",
"Storage is temporarily not available" : "Hapsira ruajtëse nuk është në dispozicion përkohësisht",
"Storage connection timeout. %s" : "Mbarim kohe lidhjeje për depozitën. %s",
+ "Personal" : "Personale",
+ "Admin" : "Administrator",
"APCu" : "APCu",
"Redis" : "Redis",
"Encryption" : "Enkriptimi",
"Tips & tricks" : "Këshilla dhe rrengje",
+ "App '%s' could not be installed!" : "Aplikacioni '%s' nuk mund të instalohet!",
"Sync clients" : "Klientë të sikronizuar"
},"pluralForm" :"nplurals=2; plural=(n != 1);"
} \ No newline at end of file
diff --git a/lib/private/App/CodeChecker/CodeChecker.php b/lib/private/App/CodeChecker/CodeChecker.php
index 456a78aa122..d2f6d7451b4 100644
--- a/lib/private/App/CodeChecker/CodeChecker.php
+++ b/lib/private/App/CodeChecker/CodeChecker.php
@@ -82,7 +82,7 @@ class CodeChecker extends BasicEmitter {
public function analyseFolder(string $appId, string $folder): array {
$errors = [];
- $excludedDirectories = ['vendor', '3rdparty', '.git', 'l10n', 'tests', 'test'];
+ $excludedDirectories = ['vendor', '3rdparty', '.git', 'l10n', 'tests', 'test', 'build'];
if ($appId === 'password_policy') {
$excludedDirectories[] = 'lists';
}
diff --git a/lib/private/AppFramework/Middleware/Security/SecurityMiddleware.php b/lib/private/AppFramework/Middleware/Security/SecurityMiddleware.php
index 2eedc39c3ab..87954ccc1cb 100644
--- a/lib/private/AppFramework/Middleware/Security/SecurityMiddleware.php
+++ b/lib/private/AppFramework/Middleware/Security/SecurityMiddleware.php
@@ -249,7 +249,7 @@ class SecurityMiddleware extends Middleware {
$url = $this->urlGenerator->linkToRoute('core.login.showLoginForm', $params);
$response = new RedirectResponse($url);
} else {
- $response = new TemplateResponse('core', '403', ['file' => $exception->getMessage()], 'guest');
+ $response = new TemplateResponse('core', '403', ['message' => $exception->getMessage()], 'guest');
$response->setStatus($exception->getCode());
}
}
diff --git a/lib/private/Authentication/TwoFactorAuth/Db/ProviderUserAssignmentDao.php b/lib/private/Authentication/TwoFactorAuth/Db/ProviderUserAssignmentDao.php
index 0e9cd8045cd..e04512b8575 100644
--- a/lib/private/Authentication/TwoFactorAuth/Db/ProviderUserAssignmentDao.php
+++ b/lib/private/Authentication/TwoFactorAuth/Db/ProviderUserAssignmentDao.php
@@ -72,15 +72,26 @@ class ProviderUserAssignmentDao {
public function persist(string $providerId, string $uid, int $enabled) {
$qb = $this->conn->getQueryBuilder();
- // First, try to update an existing entry
- $updateQuery = $qb->update(self::TABLE_NAME)
- ->set('enabled', $qb->createNamedParameter($enabled))
+ $this->conn->beginTransaction();
+ // To prevent duplicate primary key, we have to first check if an INSERT
+ // or UPDATE is required
+ $query = $qb->select('*')
+ ->from(self::TABLE_NAME)
->where($qb->expr()->eq('provider_id', $qb->createNamedParameter($providerId)))
->andWhere($qb->expr()->eq('uid', $qb->createNamedParameter($uid)));
- $updatedRows = $updateQuery->execute();
+ $result = $query->execute();
+ $rowCount = count($result->fetchAll());
+ $result->closeCursor();
- // If this (providerId, UID) key tuple is new, we have to insert it
- if (0 === (int)$updatedRows) {
+ if ($rowCount > 0) {
+ // There is an entry -> update it
+ $updateQuery = $qb->update(self::TABLE_NAME)
+ ->set('enabled', $qb->createNamedParameter($enabled))
+ ->where($qb->expr()->eq('provider_id', $qb->createNamedParameter($providerId)))
+ ->andWhere($qb->expr()->eq('uid', $qb->createNamedParameter($uid)));
+ $updateQuery->execute();
+ } else {
+ // Insert a new entry
$insertQuery = $qb->insert(self::TABLE_NAME)->values([
'provider_id' => $qb->createNamedParameter($providerId),
'uid' => $qb->createNamedParameter($uid),
@@ -89,6 +100,8 @@ class ProviderUserAssignmentDao {
$insertQuery->execute();
}
+ $this->conn->commit();
+
}
}
diff --git a/lib/private/Authentication/TwoFactorAuth/Manager.php b/lib/private/Authentication/TwoFactorAuth/Manager.php
index 0837ec339a5..6fa41897e1e 100644
--- a/lib/private/Authentication/TwoFactorAuth/Manager.php
+++ b/lib/private/Authentication/TwoFactorAuth/Manager.php
@@ -27,6 +27,8 @@ declare(strict_types = 1);
namespace OC\Authentication\TwoFactorAuth;
+use function array_diff;
+use function array_filter;
use BadMethodCallException;
use Exception;
use OC\Authentication\Exceptions\InvalidTokenException;
@@ -47,6 +49,7 @@ class Manager {
const SESSION_UID_KEY = 'two_factor_auth_uid';
const SESSION_UID_DONE = 'two_factor_auth_passed';
const REMEMBER_LOGIN = 'two_factor_remember_login';
+ const BACKUP_CODES_PROVIDER_ID = 'backup_codes';
/** @var ProviderLoader */
private $providerLoader;
@@ -76,9 +79,9 @@ class Manager {
private $dispatcher;
public function __construct(ProviderLoader $providerLoader,
- IRegistry $providerRegistry, ISession $session, IConfig $config,
- IManager $activityManager, ILogger $logger, TokenProvider $tokenProvider,
- ITimeFactory $timeFactory, EventDispatcherInterface $eventDispatcher) {
+ IRegistry $providerRegistry, ISession $session, IConfig $config,
+ IManager $activityManager, ILogger $logger, TokenProvider $tokenProvider,
+ ITimeFactory $timeFactory, EventDispatcherInterface $eventDispatcher) {
$this->providerLoader = $providerLoader;
$this->session = $session;
$this->config = $config;
@@ -104,9 +107,13 @@ class Manager {
}
$providerStates = $this->providerRegistry->getProviderStates($user);
- $enabled = array_filter($providerStates);
+ $providers = $this->providerLoader->getProviders($user);
+ $fixedStates = $this->fixMissingProviderStates($providerStates, $providers, $user);
+ $enabled = array_filter($fixedStates);
+ $providerIds = array_keys($enabled);
+ $providerIdsWithoutBackupCodes = array_diff($providerIds, [self::BACKUP_CODES_PROVIDER_ID]);
- return $twoFactorEnabled && !empty($enabled);
+ return $twoFactorEnabled && !empty($providerIdsWithoutBackupCodes);
}
/**
diff --git a/lib/private/Authentication/TwoFactorAuth/ProviderSet.php b/lib/private/Authentication/TwoFactorAuth/ProviderSet.php
index bbb9467798b..91a00a0bf8e 100644
--- a/lib/private/Authentication/TwoFactorAuth/ProviderSet.php
+++ b/lib/private/Authentication/TwoFactorAuth/ProviderSet.php
@@ -25,6 +25,8 @@ declare(strict_types=1);
namespace OC\Authentication\TwoFactorAuth;
+use function array_filter;
+use OCA\TwoFactorBackupCodes\Provider\BackupCodesProvider;
use OCP\Authentication\TwoFactorAuth\IProvider;
/**
@@ -65,6 +67,15 @@ class ProviderSet {
return $this->providers;
}
+ /**
+ * @return IProvider[]
+ */
+ public function getPrimaryProviders(): array {
+ return array_filter($this->providers, function(IProvider $provider) {
+ return !($provider instanceof BackupCodesProvider);
+ });
+ }
+
public function isProviderMissing(): bool {
return $this->providerMissing;
}
diff --git a/lib/private/Avatar.php b/lib/private/Avatar.php
index 116f8368e71..d107bb47c52 100644
--- a/lib/private/Avatar.php
+++ b/lib/private/Avatar.php
@@ -125,7 +125,7 @@ class Avatar implements IAvatar {
* @return bool
*/
public function isCustomAvatar(): bool {
- return !$this->folder->fileExists('generated');
+ return $this->config->getUserValue($this->user->getUID(), 'avatar', 'generated', 'false') !== 'true';
}
/**
diff --git a/lib/private/DB/MigrationService.php b/lib/private/DB/MigrationService.php
index 412bb61a086..f584cb351d2 100644
--- a/lib/private/DB/MigrationService.php
+++ b/lib/private/DB/MigrationService.php
@@ -457,7 +457,8 @@ class MigrationService {
if ($toSchema instanceof SchemaWrapper) {
$targetSchema = $toSchema->getWrappedSchema();
- $this->ensureOracleIdentifierLengthLimit($targetSchema, strlen($this->connection->getPrefix()));
+ // TODO re-enable once stable14 is branched of: https://github.com/nextcloud/server/issues/10518
+ // $this->ensureOracleIdentifierLengthLimit($targetSchema, strlen($this->connection->getPrefix()));
$this->connection->migrateToSchema($targetSchema);
$toSchema->performDropTableCalls();
}
diff --git a/lib/private/Files/Storage/DAV.php b/lib/private/Files/Storage/DAV.php
index b5537b65747..abb76660ca8 100644
--- a/lib/private/Files/Storage/DAV.php
+++ b/lib/private/Files/Storage/DAV.php
@@ -827,7 +827,7 @@ class DAV extends Common {
* which might be temporary
*/
protected function convertException(Exception $e, $path = '') {
- \OC::$server->getLogger()->logException($e, ['app' => 'files_external']);
+ \OC::$server->getLogger()->logException($e, ['app' => 'files_external', 'level' => ILogger::DEBUG]);
if ($e instanceof ClientHttpException) {
if ($e->getHttpStatus() === Http::STATUS_LOCKED) {
throw new \OCP\Lock\LockedException($path);
diff --git a/lib/private/Files/Stream/Encryption.php b/lib/private/Files/Stream/Encryption.php
index 65d379c0289..3c884a99ae7 100644
--- a/lib/private/Files/Stream/Encryption.php
+++ b/lib/private/Files/Stream/Encryption.php
@@ -102,6 +102,9 @@ class Encryption extends Wrapper {
/** @var array */
protected $expectedContextProperties;
+ /** @var bool */
+ protected $fileUpdated;
+
public function __construct() {
$this->expectedContextProperties = array(
'source',
@@ -235,6 +238,7 @@ class Encryption extends Wrapper {
$this->position = 0;
$this->cache = '';
$this->writeFlag = false;
+ $this->fileUpdated = false;
$this->unencryptedBlockSize = $this->encryptionModule->getUnencryptedBlockSize($this->signed);
if (
@@ -313,7 +317,6 @@ class Encryption extends Wrapper {
}
public function stream_write($data) {
-
$length = 0;
// loop over $data to fit it in 6126 sized unencrypted blocks
while (isset($data[0])) {
@@ -333,6 +336,7 @@ class Encryption extends Wrapper {
// switch the writeFlag so flush() will write the block
$this->writeFlag = true;
+ $this->fileUpdated = true;
// determine the relative position in the current block
$blockPosition = ($this->position % $this->unencryptedBlockSize);
@@ -414,7 +418,18 @@ class Encryption extends Wrapper {
}
$this->encryptionStorage->updateUnencryptedSize($this->fullPath, $this->unencryptedSize);
}
- return parent::stream_close();
+ $result = parent::stream_close();
+
+ if ($this->fileUpdated) {
+ $cache = $this->storage->getCache();
+ $cacheEntry = $cache->get($this->internalPath);
+ if ($cacheEntry) {
+ $version = $cacheEntry['encryptedVersion'] + 1;
+ $cache->update($cacheEntry->getId(), ['encrypted' => $version, 'encryptedVersion' => $version]);
+ }
+ }
+
+ return $result;
}
/**
diff --git a/lib/private/Files/Type/Loader.php b/lib/private/Files/Type/Loader.php
index 2b15c9b6e13..41c561dcd22 100644
--- a/lib/private/Files/Type/Loader.php
+++ b/lib/private/Files/Type/Loader.php
@@ -114,20 +114,9 @@ class Loader implements IMimeTypeLoader {
* @param int inserted ID
*/
protected function store($mimetype) {
- try {
- $qb = $this->dbConnection->getQueryBuilder();
- $qb->insert('mimetypes')
- ->values([
- 'mimetype' => $qb->createNamedParameter($mimetype)
- ]);
- $qb->execute();
- } catch (UniqueConstraintViolationException $e) {
- if ($this->dbConnection->inTransaction()) {
- // if we're inside a transaction we can't recover safely
- throw $e;
- }
- // something inserted it before us
- }
+ $this->dbConnection->insertIfNotExist('*PREFIX*mimetypes', [
+ 'mimetype' => $mimetype
+ ]);
$fetch = $this->dbConnection->getQueryBuilder();
$fetch->select('id')
@@ -137,6 +126,10 @@ class Loader implements IMimeTypeLoader {
));
$row = $fetch->execute()->fetch();
+ if (!$row) {
+ throw new \Exception("Failed to get mimetype id for $mimetype after trying to store it");
+ }
+
$this->mimetypes[$row['id']] = $mimetype;
$this->mimetypeIds[$mimetype] = $row['id'];
return $row['id'];
diff --git a/lib/private/Share/Constants.php b/lib/private/Share/Constants.php
index 4eb79734c06..72dc5cd43be 100644
--- a/lib/private/Share/Constants.php
+++ b/lib/private/Share/Constants.php
@@ -31,6 +31,7 @@ class Constants {
const SHARE_TYPE_USER = 0;
const SHARE_TYPE_GROUP = 1;
+ // const SHARE_TYPE_USERGROUP = 2; // Internal type used by DefaultShareProvider
const SHARE_TYPE_LINK = 3;
const SHARE_TYPE_EMAIL = 4;
const SHARE_TYPE_CONTACT = 5; // ToDo Check if it is still in use otherwise remove it
@@ -38,6 +39,8 @@ class Constants {
const SHARE_TYPE_CIRCLE = 7;
const SHARE_TYPE_GUEST = 8;
const SHARE_TYPE_REMOTE_GROUP = 9;
+ const SHARE_TYPE_ROOM = 10;
+ // const SHARE_TYPE_USERROOM = 11; // Internal type used by RoomShareProvider
const FORMAT_NONE = -1;
const FORMAT_STATUSES = -2;
diff --git a/lib/private/Share20/Manager.php b/lib/private/Share20/Manager.php
index d0316b44c1a..037ea53048a 100644
--- a/lib/private/Share20/Manager.php
+++ b/lib/private/Share20/Manager.php
@@ -239,6 +239,7 @@ class Manager implements IManager {
if ($circle === null) {
throw new \InvalidArgumentException('SharedWith is not a valid circle');
}
+ } else if ($share->getShareType() === \OCP\Share::SHARE_TYPE_ROOM) {
} else {
// We can't handle other types yet
throw new \InvalidArgumentException('unknown share type');
@@ -1247,6 +1248,15 @@ class Manager implements IManager {
}
}
+ if ($share === null && $this->shareProviderExists(\OCP\Share::SHARE_TYPE_ROOM)) {
+ try {
+ $provider = $this->factory->getProviderForType(\OCP\Share::SHARE_TYPE_ROOM);
+ $share = $provider->getShareByToken($token);
+ } catch (ProviderException $e) {
+ } catch (ShareNotFound $e) {
+ }
+ }
+
if ($share === null) {
throw new ShareNotFound($this->l->t('The requested share does not exist anymore'));
}
diff --git a/lib/private/Share20/ProviderFactory.php b/lib/private/Share20/ProviderFactory.php
index 0aacca409d1..6cb6c082df5 100644
--- a/lib/private/Share20/ProviderFactory.php
+++ b/lib/private/Share20/ProviderFactory.php
@@ -60,6 +60,8 @@ class ProviderFactory implements IProviderFactory {
private $shareByCircleProvider = null;
/** @var bool */
private $circlesAreNotAvailable = false;
+ /** @var \OCA\Spreed\Share\RoomShareProvider */
+ private $roomShareProvider = null;
/**
* IProviderFactory constructor.
@@ -221,6 +223,30 @@ class ProviderFactory implements IProviderFactory {
return $this->shareByCircleProvider;
}
+ /**
+ * Create the room share provider
+ *
+ * @return RoomShareProvider
+ */
+ protected function getRoomShareProvider() {
+ if ($this->roomShareProvider === null) {
+ /*
+ * Check if the app is enabled
+ */
+ $appManager = $this->serverContainer->getAppManager();
+ if (!$appManager->isEnabledForUser('spreed')) {
+ return null;
+ }
+
+ try {
+ $this->roomShareProvider = $this->serverContainer->query('\OCA\Spreed\Share\RoomShareProvider');
+ } catch (\OCP\AppFramework\QueryException $e) {
+ return null;
+ }
+ }
+
+ return $this->roomShareProvider;
+ }
/**
* @inheritdoc
@@ -235,6 +261,8 @@ class ProviderFactory implements IProviderFactory {
$provider = $this->getShareByMailProvider();
} else if ($id === 'ocCircleShare') {
$provider = $this->getShareByCircleProvider();
+ } else if ($id === 'ocRoomShare') {
+ $provider = $this->getRoomShareProvider();
}
if ($provider === null) {
@@ -261,6 +289,8 @@ class ProviderFactory implements IProviderFactory {
$provider = $this->getShareByMailProvider();
} else if ($shareType === \OCP\Share::SHARE_TYPE_CIRCLE) {
$provider = $this->getShareByCircleProvider();
+ } else if ($shareType === \OCP\Share::SHARE_TYPE_ROOM) {
+ $provider = $this->getRoomShareProvider();
}
@@ -281,6 +311,10 @@ class ProviderFactory implements IProviderFactory {
if ($shareByCircle !== null) {
$shares[] = $shareByCircle;
}
+ $roomShare = $this->getRoomShareProvider();
+ if ($roomShare !== null) {
+ $shares[] = $roomShare;
+ }
return $shares;
}
diff --git a/lib/private/Template/IconsCacher.php b/lib/private/Template/IconsCacher.php
index e5ea1b33815..070c7c3da51 100644
--- a/lib/private/Template/IconsCacher.php
+++ b/lib/private/Template/IconsCacher.php
@@ -140,7 +140,7 @@ class IconsCacher {
return;
}
}
- $linkToCSS = substr($this->urlGenerator->linkToRoute('core.Css.getCss', ['appName' => 'icons', 'fileName' => $this->fileName]), strlen(\OC::$WEBROOT));
+ $linkToCSS = $this->urlGenerator->linkToRoute('core.Css.getCss', ['appName' => 'icons', 'fileName' => $this->fileName]);
\OC_Util::addHeader('link', ['rel' => 'stylesheet', 'href' => $linkToCSS], null, true);
}
diff --git a/lib/private/legacy/util.php b/lib/private/legacy/util.php
index a581397212a..1b9f52008fd 100644
--- a/lib/private/legacy/util.php
+++ b/lib/private/legacy/util.php
@@ -1535,6 +1535,10 @@ class OC_Util {
* @return boolean
*/
public static function isIe() {
+ if (!isset($_SERVER['HTTP_USER_AGENT'])) {
+ return false;
+ }
+
return preg_match(Request::USER_AGENT_IE, $_SERVER['HTTP_USER_AGENT']) === 1;
}