From db5db03c9c4672775dd7800b52337c65711d87f7 Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Tue, 2 Apr 2024 06:20:16 -0400 Subject: [PATCH] HTTP.checkSecurity(): Only throw for state == 'broken' --- chrome/content/zotero/xpcom/http.js | 58 ++++++++++++++--------------- 1 file changed, 27 insertions(+), 31 deletions(-) diff --git a/chrome/content/zotero/xpcom/http.js b/chrome/content/zotero/xpcom/http.js index 8dee33bee8..e33c999a32 100644 --- a/chrome/content/zotero/xpcom/http.js +++ b/chrome/content/zotero/xpcom/http.js @@ -1263,41 +1263,37 @@ Zotero.HTTP = new function() { } let { state, errorMessage } = SecurityInfo.getSecurityInfo(channel); + if (state != 'broken') { + return; + } - let msg; let dialogButtonText; let dialogButtonCallback; - if (state !== 'secure') { - if (state === 'broken' || state === 'insecure') { - let domain = channel.originalURI?.host ?? ''; - msg = Zotero.getString('networkError.insecureConnectionTo', [Zotero.appName, domain]) - + "\n\n"; - if (channel.originalURI?.spec.includes(ZOTERO_CONFIG.DOMAIN_NAME) - || channel.originalURI?.spec.includes(ZOTERO_CONFIG.PROXY_AUTH_URL.match(/^https:\/\/([^\/]+)\//)[1])) { - msg += Zotero.getString('networkError.connectionMonitored', Zotero.appName) - + "\n\n" - + (isProxyAuthRequest - ? Zotero.getString('startupError.internetFunctionalityMayNotWork') + "\n\n" - : ""); - } - msg += errorMessage ?? channel.securityInfo?.errorCodeString ?? ''; - msg = msg.trim(); - dialogButtonText = Zotero.getString('general.moreInformation'); - dialogButtonCallback = function () { - Zotero.launchURL('https://www.zotero.org/support/kb/ssl_certificate_error'); - }; - } - if (msg) { - throw new Zotero.HTTP.SecurityException( - msg, - { - dialogHeader: Zotero.getString('networkError.connectionNotSecure'), - dialogButtonText, - dialogButtonCallback - } - ); - } + let domain = channel.originalURI?.host ?? ''; + let msg = Zotero.getString('networkError.insecureConnectionTo', [Zotero.appName, domain]) + + "\n\n"; + if (channel.originalURI?.spec.includes(ZOTERO_CONFIG.DOMAIN_NAME) + || channel.originalURI?.spec.includes(ZOTERO_CONFIG.PROXY_AUTH_URL.match(/^https:\/\/([^\/]+)\//)[1])) { + msg += Zotero.getString('networkError.connectionMonitored', Zotero.appName) + + "\n\n" + + (isProxyAuthRequest + ? Zotero.getString('startupError.internetFunctionalityMayNotWork') + "\n\n" + : ""); } + msg += errorMessage ?? channel.securityInfo?.errorCodeString ?? ''; + msg = msg.trim(); + dialogButtonText = Zotero.getString('general.moreInformation'); + dialogButtonCallback = function () { + Zotero.launchURL('https://www.zotero.org/support/kb/ssl_certificate_error'); + }; + throw new Zotero.HTTP.SecurityException( + msg, + { + dialogHeader: Zotero.getString('networkError.connectionNotSecure'), + dialogButtonText, + dialogButtonCallback + } + ); }; async function _checkRetry(req) {