From 08e44ea20c6ff0056effcf8881784faf7634cb64 Mon Sep 17 00:00:00 2001 From: Alex Catarineu Date: Wed, 13 May 2020 11:13:24 +0200 Subject: [PATCH] Bug 34196: Update site info URL with the onion name --- browser/base/content/browser-siteIdentity.js | 12 +++++++----- browser/base/content/browser.js | 3 ++- browser/base/content/pageinfo/pageInfo.js | 2 +- browser/base/content/pageinfo/pageInfo.xul | 6 ++++++ browser/base/content/pageinfo/security.js | 17 ++++++++++++++++- 5 files changed, 32 insertions(+), 8 deletions(-) diff --git a/browser/base/content/browser-siteIdentity.js b/browser/base/content/browser-siteIdentity.js index 32e939787fb7b..d1cbf8708dfc0 100644 --- a/browser/base/content/browser-siteIdentity.js +++ b/browser/base/content/browser-siteIdentity.js @@ -464,13 +464,13 @@ var gIdentityHandler = { * nsIURI for which the identity UI should be displayed, already * processed by nsIURIFixup.createExposableURI. */ - updateIdentity(state, uri) { + updateIdentity(state, uri, onionAliasURI) { let shouldHidePopup = this._uri && this._uri.spec != uri.spec; this._state = state; // Firstly, populate the state properties required to display the UI. See // the documentation of the individual properties for details. - this.setURI(uri); + this.setURI(uri, onionAliasURI); this._secInfo = gBrowser.securityUI.secInfo; // Then, update the user interface with the available data. @@ -549,17 +549,18 @@ var gIdentityHandler = { * Attempt to provide proper IDN treatment for host names */ getEffectiveHost() { + let uri = this._onionAliasURI || this._uri; if (!this._IDNService) { this._IDNService = Cc["@mozilla.org/network/idn-service;1"].getService( Ci.nsIIDNService ); } try { - return this._IDNService.convertToDisplayIDN(this._uri.host, {}); + return this._IDNService.convertToDisplayIDN(uri.host, {}); } catch (e) { // If something goes wrong (e.g. host is an IP address) just fail back // to the full domain. - return this._uri.host; + return uri.host; } }, @@ -984,8 +985,9 @@ var gIdentityHandler = { ContentBlocking.toggleReportBreakageButton(); }, - setURI(uri) { + setURI(uri, onionAliasURI) { this._uri = uri; + this._onionAliasURI = onionAliasURI; try { // Account for file: urls and catch when "" is the value diff --git a/browser/base/content/browser.js b/browser/base/content/browser.js index 67a1977fef6af..251b11dda03fc 100644 --- a/browser/base/content/browser.js +++ b/browser/base/content/browser.js @@ -6083,6 +6083,7 @@ var XULBrowserWindow = { // Don't need to do anything if the data we use to update the UI hasn't // changed let uri = gBrowser.currentURI; + let onionAliasURI = gBrowser.selectedBrowser.currentOnionAliasURI; let spec = uri.spec; if (this._state == aState && this._lastLocation == spec) { // Switching to a tab of the same URL doesn't change most security @@ -6100,7 +6101,7 @@ var XULBrowserWindow = { try { uri = Services.uriFixup.createExposableURI(uri); } catch (e) {} - gIdentityHandler.updateIdentity(this._state, uri); + gIdentityHandler.updateIdentity(this._state, uri, onionAliasURI); }, // simulate all change notifications after switching tabs diff --git a/browser/base/content/pageinfo/pageInfo.js b/browser/base/content/pageinfo/pageInfo.js index ae228fb9bd61b..c30c74dab752e 100644 --- a/browser/base/content/pageinfo/pageInfo.js +++ b/browser/base/content/pageinfo/pageInfo.js @@ -412,7 +412,7 @@ function loadPageInfo(frameOuterWindowID, imageElement, browser) { ); } onLoadPermission(uri, principal); - securityOnLoad(uri, windowInfo); + securityOnLoad(uri, windowInfo, browser.currentOnionAliasURI); }); // Get the media elements from content script to setup the media tab. diff --git a/browser/base/content/pageinfo/pageInfo.xul b/browser/base/content/pageinfo/pageInfo.xul index c7de71c230489..9fbd8e54379a5 100644 --- a/browser/base/content/pageinfo/pageInfo.xul +++ b/browser/base/content/pageinfo/pageInfo.xul @@ -294,6 +294,12 @@ control="security-identity-domain-value"/> + + +