mirror of
https://github.com/chatmail/core.git
synced 2026-05-08 09:26:29 +03:00
fix: lowercase addr when it is set
Prevent users from creating new accounts with uppercase letters in the address.
This commit is contained in:
@@ -513,6 +513,11 @@ impl Context {
|
|||||||
);
|
);
|
||||||
self.sql.set_raw_config(key.as_ref(), value).await?;
|
self.sql.set_raw_config(key.as_ref(), value).await?;
|
||||||
}
|
}
|
||||||
|
Config::Addr => {
|
||||||
|
self.sql
|
||||||
|
.set_raw_config(key.as_ref(), value.map(|s| s.to_lowercase()).as_deref())
|
||||||
|
.await?;
|
||||||
|
}
|
||||||
_ => {
|
_ => {
|
||||||
self.sql.set_raw_config(key.as_ref(), value).await?;
|
self.sql.set_raw_config(key.as_ref(), value).await?;
|
||||||
}
|
}
|
||||||
@@ -662,6 +667,21 @@ mod tests {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
||||||
|
async fn test_set_config_addr() {
|
||||||
|
let t = TestContext::new().await;
|
||||||
|
|
||||||
|
// Test that uppercase address get lowercased.
|
||||||
|
assert!(t
|
||||||
|
.set_config(Config::Addr, Some("Foobar@eXample.oRg"))
|
||||||
|
.await
|
||||||
|
.is_ok());
|
||||||
|
assert_eq!(
|
||||||
|
t.get_config(Config::Addr).await.unwrap().unwrap(),
|
||||||
|
"foobar@example.org"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
/// Tests that "bot" config can only be set to "0" or "1".
|
/// Tests that "bot" config can only be set to "0" or "1".
|
||||||
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
||||||
async fn test_set_config_bot() {
|
async fn test_set_config_bot() {
|
||||||
|
|||||||
Reference in New Issue
Block a user