Verified Commit 7287a252 authored by Alex Catarineu's avatar Alex Catarineu
Browse files

Bugs 22538 and 22513: Fix new circuit button for neterror and certerror

parent 409f01d4
......@@ -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;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment