Change ProviderAutoconfigUrlProvider
to match Thunderbird's behavior
See <https://searchfox.org/comm-central/rev/f1c212acd8e3c3c2d1f5e2d442bb66e1407243b5/mail/components/accountcreation/FetchConfig.jsm#94-154>
This commit is contained in:
parent
c585e05bc2
commit
686bba8b9c
2 changed files with 16 additions and 11 deletions
|
@ -9,29 +9,33 @@ class ProviderAutoconfigUrlProvider : AutoconfigUrlProvider {
|
|||
requireNotNull(domain) { "Couldn't extract domain from email address: $email" }
|
||||
|
||||
return listOf(
|
||||
createProviderUrl(domain, email),
|
||||
createDomainUrl(scheme = "https", domain),
|
||||
createDomainUrl(scheme = "http", domain),
|
||||
createProviderUrl(domain, email, useHttps = true),
|
||||
createDomainUrl(domain, email, useHttps = true),
|
||||
|
||||
createProviderUrl(domain, email, useHttps = false),
|
||||
createDomainUrl(domain, email, useHttps = false),
|
||||
)
|
||||
}
|
||||
|
||||
private fun createProviderUrl(domain: String?, email: String): HttpUrl {
|
||||
private fun createProviderUrl(domain: String, email: String, useHttps: Boolean): HttpUrl {
|
||||
// https://autoconfig.{domain}/mail/config-v1.1.xml?emailaddress={email}
|
||||
// http://autoconfig.{domain}/mail/config-v1.1.xml?emailaddress={email}
|
||||
return HttpUrl.Builder()
|
||||
.scheme("https")
|
||||
.scheme(if (useHttps) "https" else "http")
|
||||
.host("autoconfig.$domain")
|
||||
.addEncodedPathSegments("mail/config-v1.1.xml")
|
||||
.addQueryParameter("emailaddress", email)
|
||||
.build()
|
||||
}
|
||||
|
||||
private fun createDomainUrl(scheme: String, domain: String): HttpUrl {
|
||||
// https://{domain}/.well-known/autoconfig/mail/config-v1.1.xml
|
||||
// http://{domain}/.well-known/autoconfig/mail/config-v1.1.xml
|
||||
private fun createDomainUrl(domain: String, email: String, useHttps: Boolean): HttpUrl {
|
||||
// https://{domain}/.well-known/autoconfig/mail/config-v1.1.xml?emailaddress={email}
|
||||
// http://{domain}/.well-known/autoconfig/mail/config-v1.1.xml?emailaddress={email}
|
||||
return HttpUrl.Builder()
|
||||
.scheme(scheme)
|
||||
.scheme(if (useHttps) "https" else "http")
|
||||
.host(domain)
|
||||
.addEncodedPathSegments(".well-known/autoconfig/mail/config-v1.1.xml")
|
||||
.addQueryParameter("emailaddress", email)
|
||||
.build()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,8 +13,9 @@ class ProviderAutoconfigUrlProviderTest {
|
|||
|
||||
assertThat(autoconfigUrls.map { it.toString() }).containsExactly(
|
||||
"https://autoconfig.domain.example/mail/config-v1.1.xml?emailaddress=test%40domain.example",
|
||||
"https://domain.example/.well-known/autoconfig/mail/config-v1.1.xml",
|
||||
"http://domain.example/.well-known/autoconfig/mail/config-v1.1.xml",
|
||||
"https://domain.example/.well-known/autoconfig/mail/config-v1.1.xml?emailaddress=test%40domain.example",
|
||||
"http://autoconfig.domain.example/mail/config-v1.1.xml?emailaddress=test%40domain.example",
|
||||
"http://domain.example/.well-known/autoconfig/mail/config-v1.1.xml?emailaddress=test%40domain.example",
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue