Skip to content

Commit

Permalink
feat: lowercase addresses in Autocrypt and Autocrypt-Gossip
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
link2xt committed Nov 19, 2023
1 parent ab15165 commit 09d4b43
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/aheader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;")?;
}
Expand Down Expand Up @@ -262,5 +262,16 @@ mod tests {
)
)
.contains("prefer-encrypt"));

// Always lowercase the address in the header.
assert!(format!(
"{}",
Aheader::new(
"[email protected]".to_string(),
SignedPublicKey::from_base64(RAWKEY).unwrap(),
EncryptPreference::Mutual
)
)
.contains("[email protected]"));
}
}

0 comments on commit 09d4b43

Please sign in to comment.