Skip to content

Commit cbca510

Browse files
committed
fix: do not percent-encode dot when passing to autoconfig server
The server should decode the URL and according to RFC 3986 query parameters may or may not be URL-encoded, but at some servers don't decode the dot correctly. `@` is decoded correctly by autoconfig.murena.io
1 parent 88278fc commit cbca510

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

src/configure.rs

+11-2
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,12 @@ use auto_outlook::outlk_autodiscover;
1919
use deltachat_contact_tools::EmailAddress;
2020
use futures::FutureExt;
2121
use futures_lite::FutureExt as _;
22-
use percent_encoding::{utf8_percent_encode, NON_ALPHANUMERIC};
22+
use percent_encoding::utf8_percent_encode;
2323
use server_params::{expand_param_vector, ServerParams};
2424
use tokio::task;
2525

2626
use crate::config::{self, Config};
27+
use crate::constants::NON_ALPHANUMERIC_WITHOUT_DOT;
2728
use crate::context::Context;
2829
use crate::imap::Imap;
2930
use crate::log::LogExt;
@@ -498,7 +499,15 @@ async fn get_autoconfig(
498499
param: &EnteredLoginParam,
499500
param_domain: &str,
500501
) -> Option<Vec<ServerParams>> {
501-
let param_addr_urlencoded = utf8_percent_encode(&param.addr, NON_ALPHANUMERIC).to_string();
502+
// Make sure to not encode `.` as `%2E` here.
503+
// Some servers like murena.io on 2024-11-01 produce incorrect autoconfig XML
504+
// when address is encoded.
505+
// E.g.
506+
// <https://autoconfig.murena.io/mail/config-v1.1.xml?emailaddress=foobar%40example%2Eorg>
507+
// produced XML file with `<username>foobar@example%2Eorg</username>`
508+
// resulting in failure to log in.
509+
let param_addr_urlencoded =
510+
utf8_percent_encode(&param.addr, NON_ALPHANUMERIC_WITHOUT_DOT).to_string();
502511

503512
if let Ok(res) = moz_autoconfigure(
504513
ctx,

0 commit comments

Comments
 (0)