diff options
author | Lars Wirzenius <liw@sequoia-pgp.org> | 2022-06-12 12:41:27 +0300 |
---|---|---|
committer | Lars Wirzenius <liw@sequoia-pgp.org> | 2022-06-12 12:47:19 +0300 |
commit | 41569b7560ecab1277eb06b7fcf937c33f3df28d (patch) | |
tree | eded2ce911829bdb1daa9dfd60dd7c1efad79129 /net/src/wkd.rs | |
parent | 956f6247ace267c6d14c6c71157c3fbd0bfb2c25 (diff) |
net: fix WKD URL generation
In WKD, when a URL is generated for an email, the local part is added
to the URL as a query parameter exactly as it's in the input. Sequoia
was previously converting it to lower case. This fixes it to avoid the
change.
However, the local part still needs to be converted to lower case for
hash computation, so we do that when we compute the hash.
Fixes #874
Sponsored-by: pep.foundation
Diffstat (limited to 'net/src/wkd.rs')
-rw-r--r-- | net/src/wkd.rs | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/net/src/wkd.rs b/net/src/wkd.rs index cfd326e8..0289508d 100644 --- a/net/src/wkd.rs +++ b/net/src/wkd.rs @@ -93,11 +93,13 @@ impl EmailAddress { return Err(Error::MalformedEmail(email_address.into()).into()) }; - // Convert to lowercase without tailoring, i.e. without taking any + // Convert domain to lowercase without tailoring, i.e. without taking any // locale into account. See: // https://doc.rust-lang.org/std/primitive.str.html#method.to_lowercase + // + // Keep the local part as-is as we'll need that to generate WKD URLs. let email = EmailAddress { - local_part: v[0].to_lowercase(), + local_part: v[0].to_string(), domain: v[1].to_lowercase() }; Ok(email) @@ -126,7 +128,7 @@ impl Url { /// Returns a [`Url`] from an email address string. pub fn from<S: AsRef<str>>(email_address: S) -> Result<Self> { let email = EmailAddress::from(email_address)?; - let local_encoded = encode_local_part(&email.local_part); + let local_encoded = encode_local_part(&email.local_part.to_lowercase()); let url = Url { domain : email.domain, local_encoded, |