aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Steinmetz <richard@steinmetz.cloud>2025-06-24 11:46:45 +0200
committerRichard Steinmetz <richard@steinmetz.cloud>2025-06-24 11:46:45 +0200
commit6d2b11f166d0859b2baaee68fcaa376d9274d3c0 (patch)
tree9be2dfb0328d9f3a1ffedf15b7492122cc1e580f
parent80f474c343cef6f766989755c2edd36a5c0b1b6e (diff)
downloadnextcloud-server-fix/revive-lowercase-email.tar.gz
nextcloud-server-fix/revive-lowercase-email.zip
fixup! fix: revive always storing lowercased email addresses in AllConfigfix/revive-lowercase-email
-rw-r--r--lib/private/AllConfig.php4
-rw-r--r--lib/private/Config/UserConfig.php5
-rw-r--r--tests/lib/Config/UserConfigTest.php13
3 files changed, 18 insertions, 4 deletions
diff --git a/lib/private/AllConfig.php b/lib/private/AllConfig.php
index d96157a08af..72af6c960a5 100644
--- a/lib/private/AllConfig.php
+++ b/lib/private/AllConfig.php
@@ -253,10 +253,6 @@ class AllConfig implements IConfig {
}
}
- if ($appName === 'settings' && $key === 'email') {
- $value = strtolower((string)$value);
- }
-
$userPreferences->setValueMixed($userId, $appName, $key, (string)$value);
}
diff --git a/lib/private/Config/UserConfig.php b/lib/private/Config/UserConfig.php
index 77a86a5e1c7..1fdcfaa53a7 100644
--- a/lib/private/Config/UserConfig.php
+++ b/lib/private/Config/UserConfig.php
@@ -1045,6 +1045,11 @@ class UserConfig implements IUserConfig {
int $flags,
ValueType $type,
): bool {
+ // Primary email addresses are always(!) expected to be lowercase
+ if ($app === 'settings' && $key === 'email') {
+ $value = strtolower($value);
+ }
+
$this->assertParams($userId, $app, $key);
if (!$this->matchAndApplyLexiconDefinition($userId, $app, $key, $lazy, $type, $flags)) {
// returns false as database is not updated
diff --git a/tests/lib/Config/UserConfigTest.php b/tests/lib/Config/UserConfigTest.php
index 865575374d8..e27e831f425 100644
--- a/tests/lib/Config/UserConfigTest.php
+++ b/tests/lib/Config/UserConfigTest.php
@@ -1241,6 +1241,19 @@ class UserConfigTest extends TestCase {
}
}
+ /**
+ * This test needs to stay! Emails are expected to be lowercase due to performance reasons.
+ * This way we can skip the expensive casing change on the database.
+ */
+ public function testSetValueMixedWithSettingsEmail(): void {
+ $userConfig = $this->generateUserConfig();
+
+ $edited = $userConfig->setValueMixed('user1', 'settings', 'email', 'mixed.CASE@Nextcloud.com');
+ $this->assertTrue($edited);
+
+ $actual = $userConfig->getValueMixed('user1', 'settings', 'email');
+ $this->assertEquals('mixed.case@nextcloud.com', $actual);
+ }
public static function providerSetValueString(): array {
return [