mirror of
https://github.com/chatmail/core.git
synced 2026-04-20 06:56:29 +03:00
feat: lowercase addresses in Autocrypt and Autocrypt-Gossip
Email addresses should generally be compared case-insensitively, but there may be errors in comparison code. To reduce the chance of problems, encode addresses in Autocrypt and Autocrypt-Gossip in lowercase to avoid propagating uppercase characters over the network to other accounts potentially running buggy code.
This commit is contained in:
@@ -67,7 +67,7 @@ impl Aheader {
|
||||
|
||||
impl fmt::Display for Aheader {
|
||||
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
|
||||
write!(fmt, "addr={};", self.addr)?;
|
||||
write!(fmt, "addr={};", self.addr.to_lowercase())?;
|
||||
if self.prefer_encrypt == EncryptPreference::Mutual {
|
||||
write!(fmt, " prefer-encrypt=mutual;")?;
|
||||
}
|
||||
@@ -262,5 +262,16 @@ mod tests {
|
||||
)
|
||||
)
|
||||
.contains("prefer-encrypt"));
|
||||
|
||||
// Always lowercase the address in the header.
|
||||
assert!(format!(
|
||||
"{}",
|
||||
Aheader::new(
|
||||
"TeSt@eXaMpLe.cOm".to_string(),
|
||||
SignedPublicKey::from_base64(RAWKEY).unwrap(),
|
||||
EncryptPreference::Mutual
|
||||
)
|
||||
)
|
||||
.contains("test@example.com"));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user