Allow padded authentication tokens (#305)

I honestly couldn't tell you why `NO_PAD` was chosen. It seems to have
happened somewhat arbitrarily when the `base64` major upgrade that
introduced the distinction landed in #253.

Time to fix that.

Fixes #299.
This commit is contained in:
Jon Gjengset 2025-02-08 14:44:56 -05:00 committed by GitHub
parent 6fe22ed11a
commit 70ed8f1709
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 4 additions and 4 deletions

2
Cargo.lock generated
View file

@ -405,7 +405,7 @@ dependencies = [
[[package]] [[package]]
name = "imap" name = "imap"
version = "3.0.0-alpha.14" version = "3.0.0-alpha.15"
dependencies = [ dependencies = [
"base64 0.22.0", "base64 0.22.0",
"bufstream", "bufstream",

View file

@ -1,6 +1,6 @@
[package] [package]
name = "imap" name = "imap"
version = "3.0.0-alpha.14" version = "3.0.0-alpha.15"
authors = ["Jon Gjengset <jon@thesquareplanet.com>", authors = ["Jon Gjengset <jon@thesquareplanet.com>",
"Matt McCoy <mattnenterprise@yahoo.com>"] "Matt McCoy <mattnenterprise@yahoo.com>"]
documentation = "https://docs.rs/imap/" documentation = "https://docs.rs/imap/"

View file

@ -501,7 +501,7 @@ impl<T: Read + Write> Client<T> {
let data = let data =
ok_or_unauth_client_err!(parse_authenticate_response(line_str), self); ok_or_unauth_client_err!(parse_authenticate_response(line_str), self);
ok_or_unauth_client_err!( ok_or_unauth_client_err!(
general_purpose::STANDARD_NO_PAD general_purpose::STANDARD
.decode(data) .decode(data)
.map_err(|e| Error::Parse(ParseError::Authentication( .map_err(|e| Error::Parse(ParseError::Authentication(
data.to_string(), data.to_string(),
@ -512,7 +512,7 @@ impl<T: Read + Write> Client<T> {
}; };
let raw_response = &authenticator.process(&challenge); let raw_response = &authenticator.process(&challenge);
let auth_response = general_purpose::STANDARD_NO_PAD.encode(raw_response); let auth_response = general_purpose::STANDARD.encode(raw_response);
ok_or_unauth_client_err!( ok_or_unauth_client_err!(
self.write_line(auth_response.into_bytes().as_slice()), self.write_line(auth_response.into_bytes().as_slice()),
self self