From ad287cb7340f3c5251c43b3ba607cc5e215873e8 Mon Sep 17 00:00:00 2001 From: Magnus Melin Date: Sun, 7 Mar 2021 12:56:42 +0200 Subject: [PATCH] Backed out changeset f1ca6ee69568 (bug 1695703) for test failures. rs=backout --- mailnews/base/src/nsMsgIncomingServer.cpp | 15 +++++---------- mailnews/compose/src/SmtpServer.jsm | 16 +++++++++------- mailnews/compose/src/nsSmtpServer.cpp | 7 +++---- 3 files changed, 17 insertions(+), 21 deletions(-) diff --git a/mailnews/base/src/nsMsgIncomingServer.cpp b/mailnews/base/src/nsMsgIncomingServer.cpp index a5af640e85..d7bc6e94a0 100644 --- a/mailnews/base/src/nsMsgIncomingServer.cpp +++ b/mailnews/base/src/nsMsgIncomingServer.cpp @@ -88,7 +88,7 @@ nsMsgIncomingServer::Observe(nsISupports* aSubject, const char* aTopic, nsresult rv; // When the state of the password manager changes we need to clear the - // password from the cache. + // password from the cache in case the user just removed it. if (strcmp(aTopic, "passwordmgr-storage-changed") == 0) { // Check that the notification is for this server. nsCOMPtr loginInfo = do_QueryInterface(aSubject); @@ -99,16 +99,11 @@ nsMsgIncomingServer::Observe(nsISupports* aSubject, const char* aTopic, GetHostName(hostname); nsAutoCString fullName; GetType(fullName); - if (fullName.EqualsLiteral("pop3")) { - fullName = "mailbox://"_ns + hostname; - } else { - fullName += "://"_ns + hostname; - } - if (fullName.Equals(NS_ConvertUTF16toUTF8(hostnameInfo))) { - rv = ForgetSessionPassword(); - NS_ENSURE_SUCCESS(rv, rv); - } + fullName += "://"_ns + hostname; + if (!fullName.Equals(NS_ConvertUTF16toUTF8(hostnameInfo))) return NS_OK; } + rv = ForgetSessionPassword(); + NS_ENSURE_SUCCESS(rv, rv); } else if (strcmp(aTopic, NS_XPCOM_SHUTDOWN_OBSERVER_ID) == 0) { // Now remove ourselves from the observer service as well. nsCOMPtr observerService = diff --git a/mailnews/compose/src/SmtpServer.jsm b/mailnews/compose/src/SmtpServer.jsm index 449c105786..06c0ef2ceb 100644 --- a/mailnews/compose/src/SmtpServer.jsm +++ b/mailnews/compose/src/SmtpServer.jsm @@ -26,14 +26,16 @@ SmtpServer.prototype = { classID: Components.ID("{3a75f5ea-651e-4696-9813-848c03da8bbd}"), observe(subject, topic, data) { - // When the state of the password manager changes we need to clear the - // password from the cache. - if ( - topic == "passwordmgr-storage-changed" && + if (topic == "passwordmgr-storage-changed") { // Check that the notification is for this server. - subject instanceof Ci.nsILoginInfo && - subject.hostname == "smtp://" + this.hostname - ) { + if ( + subject instanceof Ci.nsILoginInfo && + subject.hostname != "smtp://" + this.hostname + ) { + return; + } + // When the state of the password manager changes we need to clear the + // password from the cache in case the user just removed it. this.password = ""; } }, diff --git a/mailnews/compose/src/nsSmtpServer.cpp b/mailnews/compose/src/nsSmtpServer.cpp index 1b532d4151..2b87815c9c 100644 --- a/mailnews/compose/src/nsSmtpServer.cpp +++ b/mailnews/compose/src/nsSmtpServer.cpp @@ -52,7 +52,7 @@ NS_IMETHODIMP nsSmtpServer::Observe(nsISupports* aSubject, const char* aTopic, const char16_t* aData) { // When the state of the password manager changes we need to clear the - // password from the cache. + // password from the cache in case the user just removed it. if (strcmp(aTopic, "passwordmgr-storage-changed") == 0) { // Check that the notification is for this server. nsCOMPtr loginInfo = do_QueryInterface(aSubject); @@ -63,10 +63,9 @@ nsSmtpServer::Observe(nsISupports* aSubject, const char* aTopic, GetHostname(hostname); nsAutoCString fullName; fullName = "smtp://"_ns + hostname; - if (fullName.Equals(NS_ConvertUTF16toUTF8(hostnameInfo))) { - m_password.Truncate(); - } + if (!fullName.Equals(NS_ConvertUTF16toUTF8(hostnameInfo))) return NS_OK; } + m_password.Truncate(); } else if (strcmp(aTopic, NS_XPCOM_SHUTDOWN_OBSERVER_ID) == 0) { // Now remove ourselves from the observer service as well. nsCOMPtr observerService =