commit 7287a25268adb13789de3c5649780f9f4813d0d1 Author: Alex Catarineu acat@torproject.org Date: Wed Apr 3 18:09:30 2019 +0200
Bugs 22538 and 22513: Fix new circuit button for neterror and certerror --- src/chrome/content/torbutton.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+)
diff --git a/src/chrome/content/torbutton.js b/src/chrome/content/torbutton.js index f1b1dc0c..2421548d 100644 --- a/src/chrome/content/torbutton.js +++ b/src/chrome/content/torbutton.js @@ -18,6 +18,7 @@ const k_tb_last_browser_version_pref = "extensions.torbutton.lastBrowserVersion" const k_tb_browser_update_needed_pref = "extensions.torbutton.updateNeeded"; const k_tb_last_update_check_pref = "extensions.torbutton.lastUpdateCheck"; const k_tb_tor_check_failed_topic = "Torbutton:TorCheckFailed"; +const k_tb_about_uri_first_party_domain = "about.ef2a7dd5-93bc-417f-a698-142c3116864f.mozilla";
var m_tb_prefs = Services.prefs;
@@ -861,6 +862,22 @@ function torbutton_send_ctrl_cmd(command) { function torbutton_new_circuit() { let firstPartyDomain = gBrowser.contentPrincipal.originAttributes .firstPartyDomain; + // Bug 22538: For neterror or certerror, get firstPartyDomain causing it from the u param + if (firstPartyDomain === k_tb_about_uri_first_party_domain) { + let knownErrors = ["about:neterror", "about:certerror"]; + let origin = gBrowser.contentPrincipal.origin || ''; + if (knownErrors.some(x => origin.startsWith(x))) { + try { + let urlOrigin = new URL(origin); + let { hostname } = new URL(urlOrigin.searchParams.get('u')); + if (hostname) { + firstPartyDomain = Services.eTLD.getBaseDomainFromHost(hostname) || firstPartyDomain; + } + } catch (e) { + torbutton_log(4, "Exception on new circuit" +e); + } + } + }
let domainIsolator = Cc["@torproject.org/domain-isolator;1"] .getService(Ci.nsISupports).wrappedJSObject;