Bug 1906992 - Ensure URLs are properly normalized for local folders and smart mailboxes. r=darktrojan,kaie
Differential Revision: https://phabricator.services.mozilla.com/D216314 --HG-- extra : rebase_source : 55877440017023ec33b578fd412b6c10176665b4 extra : amend_source : 4c30e1de5ff95e915b7c2e814b7ef6b036b012c5
This commit is contained in:
Родитель
fb4d6e2012
Коммит
8921e5dbdc
|
@ -1850,8 +1850,18 @@ nsresult nsMsgAccountManager::findServerInternal(
|
|||
nsCString hostname;
|
||||
nsCOMPtr<nsIIDNService> idnService =
|
||||
do_GetService("@mozilla.org/network/idn-service;1");
|
||||
|
||||
rv = idnService->ConvertToDisplayIDN(serverHostname, hostname);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsIURL> url;
|
||||
rv = NS_MutateURI(NS_STANDARDURLMUTATOR_CONTRACTID)
|
||||
.SetSpec("imap://"_ns + hostname)
|
||||
.Finalize(url);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
rv = url->GetHost(hostname);
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIIOService> ioService = mozilla::components::IO::Service();
|
||||
NS_ENSURE_TRUE(ioService, NS_ERROR_UNEXPECTED);
|
||||
|
||||
|
@ -1865,26 +1875,26 @@ nsresult nsMsgAccountManager::findServerInternal(
|
|||
rv = server->GetHostName(thisHostname);
|
||||
if (NS_FAILED(rv)) continue;
|
||||
|
||||
// URL mutation expects percent-escaping in the hostname, which
|
||||
// `ConvertToDisplayIDN` will do for us.
|
||||
nsCString normalizedHostname;
|
||||
rv = idnService->ConvertToDisplayIDN(thisHostname, normalizedHostname);
|
||||
if (NS_FAILED(rv)) continue;
|
||||
|
||||
// If the hostname will get normalized during URI mutation.
|
||||
// E.g. for IP with trailing dot, or hostname that's just a number.
|
||||
// We may well be here in findServerInternal to find a server from a folder
|
||||
// URI. We need to use the normalized version to find the server.
|
||||
// Create an imap url to see what it's normalized to. The normalization
|
||||
// is the same for all protocols.
|
||||
nsCOMPtr<nsIURL> url;
|
||||
rv = NS_MutateURI(NS_STANDARDURLMUTATOR_CONTRACTID)
|
||||
.SetSpec("imap://"_ns + thisHostname)
|
||||
.SetSpec("imap://"_ns + normalizedHostname)
|
||||
.Finalize(url);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
// Notably, this will fail for "Local Folders" which isn't a valid
|
||||
// hostname.
|
||||
rv = url->GetHost(thisHostname);
|
||||
rv = url->GetHost(normalizedHostname);
|
||||
if (NS_FAILED(rv)) continue;
|
||||
}
|
||||
|
||||
rv = idnService->ConvertToDisplayIDN(thisHostname, thisHostname);
|
||||
if (NS_FAILED(rv)) continue;
|
||||
|
||||
nsCString thisUsername;
|
||||
rv = server->GetUsername(thisUsername);
|
||||
if (NS_FAILED(rv)) continue;
|
||||
|
@ -1906,7 +1916,8 @@ nsresult nsMsgAccountManager::findServerInternal(
|
|||
// attribute treat it as a match
|
||||
if ((type.IsEmpty() || thisType.Equals(type)) &&
|
||||
(hostname.IsEmpty() ||
|
||||
thisHostname.Equals(hostname, nsCaseInsensitiveCStringComparator)) &&
|
||||
normalizedHostname.Equals(hostname,
|
||||
nsCaseInsensitiveCStringComparator)) &&
|
||||
(!(port != 0) || (port == thisPort)) &&
|
||||
(username.IsEmpty() || thisUsername.Equals(username))) {
|
||||
// stop on first find; cache for next time
|
||||
|
|
|
@ -54,7 +54,7 @@ gecko_logger = { path = "../../../xpcom/rust/gecko_logger" }
|
|||
geckoservo = { path = "../../../servo/ports/geckolib" }
|
||||
gkrust_utils = { path = "../../../xpcom/rust/gkrust_utils" }
|
||||
http_sfv = { path = "../../../netwerk/base/http-sfv" }
|
||||
idna_glue = { path = "../../../netwerk/base/idna_glue" }
|
||||
idna_glue = { path = "../../../netwerk/base/idna_glue", features = ['mailnews'] }
|
||||
jog = { path = "../../../toolkit/components/glean/bindings/jog" }
|
||||
jsrust_shared = { path = "../../../js/src/rust/shared" }
|
||||
kvstore = { path = "../../../toolkit/components/kvstore" }
|
||||
|
|
Загрузка…
Ссылка в новой задаче