From 5ed5139c5f91824fb9471e4a8e950048bae31d1e Mon Sep 17 00:00:00 2001 From: Martin Giger Date: Tue, 18 Jun 2024 22:13:53 +0000 Subject: [PATCH] Bug 1902611 - Improve resiliency with corrupted chat buddy list. r=vineet Differential Revision: https://phabricator.services.mozilla.com/D213764 --HG-- extra : moz-landing-system : lando --- .../about-support/content/accounts.js | 40 ++++++++++++------- mailnews/base/prefs/content/AccountManager.js | 4 +- 2 files changed, 29 insertions(+), 15 deletions(-) diff --git a/mail/components/about-support/content/accounts.js b/mail/components/about-support/content/accounts.js index 534cd0556d..95fa5ccad9 100644 --- a/mail/components/about-support/content/accounts.js +++ b/mail/components/about-support/content/accounts.js @@ -96,20 +96,32 @@ var AboutSupport = { const accountDetails = []; for (const account of MailServices.accounts.accounts) { - const server = account.incomingServer; - accountDetails.push({ - key: account.key, - name: server.prettyName, - hostDetails: - "(" + - server.type + - ") " + - server.hostName + - (server.port != -1 ? ":" + server.port : ""), - socketType: server.socketType, - authMethod: server.authMethod, - smtpServers: this._getSMTPDetails(account), - }); + try { + const server = account.incomingServer; + accountDetails.push({ + key: account.key, + name: server.prettyName, + hostDetails: + "(" + + server.type + + ") " + + server.hostName + + (server.port != -1 ? ":" + server.port : ""), + socketType: server.socketType, + authMethod: server.authMethod, + smtpServers: this._getSMTPDetails(account), + }); + } catch (error) { + // Populate placeholder data. + accountDetails.push({ + key: account.key, + name: error.message, + hostDetails: "", + sokectType: "", + authMethod: "", + smtpServers: [], + }); + } } function idCompare(accountA, accountB) { diff --git a/mailnews/base/prefs/content/AccountManager.js b/mailnews/base/prefs/content/AccountManager.js index bdfbfb9f2f..3e1c3531c9 100644 --- a/mailnews/base/prefs/content/AccountManager.js +++ b/mailnews/base/prefs/content/AccountManager.js @@ -1839,6 +1839,7 @@ var gAccountTree = { let amChrome = "about:blank"; const panelsToKeep = []; let server = null; + let validAccount = true; // This "try {} catch {}" block is intentionally very long to catch // unknown exceptions and confine them to this single account. @@ -1921,6 +1922,7 @@ var gAccountTree = { console.error("Error accessing account " + accountID + ": " + e); accountName = "Invalid account " + accountID; panelsToKeep.length = 0; + validAccount = false; } // Create the top level tree-item. @@ -1940,7 +1942,7 @@ var gAccountTree = { treeitem.classList.add("isSecure"); } // For IM accounts, we can try to fetch a protocol specific icon. - if (server.type == "im") { + if (server.type == "im" && validAccount) { treeitem.querySelector(".icon").style.backgroundImage = "url(" + ChatIcons.getProtocolIconURI(