# HG changeset patch # User Ian Neal # Date 1638720550 0 # Parent 996e6ce40212dbaf1809541e78c89dc61283997f Bug 1744440 - Prefer secure over insecure protocol in network list in ChatZilla. r=frg a=frg diff --git a/suite/extensions/irc/xul/content/commands.js b/suite/extensions/irc/xul/content/commands.js --- a/suite/extensions/irc/xul/content/commands.js +++ b/suite/extensions/irc/xul/content/commands.js @@ -1437,30 +1437,21 @@ function cmdNetworks(e) { var wrapper = newInlineText(MSG_NETWORKS_HEADA); var netnames = keys(client.networks).sort(); for (let i = 0; i < netnames.length; i++) { let net = client.networks[netnames[i]]; - /* Test for an all-SSL network */ - var isSecure = true; - for (let s in net.serverList) - { - if (!net.serverList[s].isSecure) - { - isSecure = false; - break; - } - } + let hasSecure = networkHasSecure(net.serverList); var linkData = { "data": net.unicodeName, - "href": (isSecure ? "ircs://" : "irc://") + net.canonicalName + "href": (hasSecure ? "ircs://" : "irc://") + net.canonicalName }; wrapper.appendChild(newInlineText(linkData, "chatzilla-link", "a")); if (i < netnames.length - 1) wrapper.appendChild(document.createTextNode(", ")); } // Display an "Edit" link. diff --git a/suite/extensions/irc/xul/content/networks-edit.js b/suite/extensions/irc/xul/content/networks-edit.js --- a/suite/extensions/irc/xul/content/networks-edit.js +++ b/suite/extensions/irc/xul/content/networks-edit.js @@ -159,18 +159,23 @@ var gNetworkWindow = { // Connect to Network button. onConnect: function() { let selection = this.mNetworkList.selectedItem; if (!selection) return; let network = this.networkList[selection.id]; - if (this.onOK()) - client.dispatch("server " + network.name); + if (this.onOK()) { + if (networkHasSecure(network.servers)) { + client.dispatch("sslserver " + network.name); + } else { + client.dispatch("server " + network.name); + } + } }, // Select a network listitem. onSelectNetwork: function(aId = 0) { let header = document.getElementById("network-header"); // Remove all children. while (this.mServerList.hasChildNodes()) { diff --git a/suite/extensions/irc/xul/content/networks.js b/suite/extensions/irc/xul/content/networks.js --- a/suite/extensions/irc/xul/content/networks.js +++ b/suite/extensions/irc/xul/content/networks.js @@ -206,8 +206,23 @@ function networksSaveList(networkList) networksFile.append("networks.json"); var networksLoader = new JSONSerializer(networksFile); if (networksLoader.open(">")) { networksLoader.serialize(Object.values(networkList)); networksLoader.close(); } } + +function networkHasSecure(serverList) +{ + // Test to see if the network has a secure server. + let hasSecure = false; + for (let s in serverList) + { + if (serverList[s].isSecure) + { + hasSecure = true; + break; + } + } + return hasSecure; +}