[tbb-commits] [tor-browser/tor-browser-91.5.0esr-11.5-1] fixup! Bug 27476: Implement about:torconnect captive portal within Tor Browser

gk at torproject.org gk at torproject.org
Wed Jan 19 13:38:29 UTC 2022


commit eefa8951d7eabcb2b079cb0719bbfc8daff2fc24
Author: Richard Pospesel <richard at torproject.org>
Date:   Tue Dec 21 17:05:49 2021 +0100

    fixup! Bug 27476: Implement about:torconnect captive portal within Tor Browser
---
 browser/base/content/utilityOverlay.js | 12 +++++++++---
 browser/modules/TorConnect.jsm         | 11 ++++++-----
 2 files changed, 15 insertions(+), 8 deletions(-)

diff --git a/browser/base/content/utilityOverlay.js b/browser/base/content/utilityOverlay.js
index 3d22093119ca..5f629dece94e 100644
--- a/browser/base/content/utilityOverlay.js
+++ b/browser/base/content/utilityOverlay.js
@@ -337,11 +337,17 @@ function openUILinkIn(
   aPostData,
   aReferrerInfo
 ) {
-
   // make sure users are not faced with the scary red 'tor isn't working' screen
   // if they navigate to about:tor before bootstrapped
-  if (url === "about:tor" && TorConnect.shouldShowTorConnect) {
-    url = `about:torconnect?redirect=${encodeURIComponent("about:tor")}`;
+  //
+  // fixes tor-browser#40752
+  // new tabs also redirect to about:tor if browser.newtabpage.enabled is true
+  // otherwise they go to about:blank
+  if (TorConnect.shouldShowTorConnect) {
+    if (url === "about:tor" ||
+        (url === "about:newtab" && Services.prefs.getBoolPref("browser.newtabpage.enabled", false))) {
+      url = TorConnect.getRedirectURL(url);
+    }
   }
 
   var params;
diff --git a/browser/modules/TorConnect.jsm b/browser/modules/TorConnect.jsm
index 7c8580b5d8a9..c7ab480e2be0 100644
--- a/browser/modules/TorConnect.jsm
+++ b/browser/modules/TorConnect.jsm
@@ -587,6 +587,10 @@ const TorConnect = (() => {
             );
         },
 
+        getRedirectURL: function(url) {
+            return `about:torconnect?redirect=${encodeURIComponent(url)}`;
+        },
+
         // called from browser.js on browser startup, passed in either the user's homepage(s)
         // or uris passed via command-line; we want to replace them with about:torconnect uris
         // which redirect after bootstrapping
@@ -628,13 +632,10 @@ const TorConnect = (() => {
             let uris = uriStrings.map(uriStringToUri);
 
             // assume we have a valid uri and generate an about:torconnect redirect uri
-            let uriToRedirectUri = (uri) => {
-                return`about:torconnect?redirect=${encodeURIComponent(uri.spec)}`;
-            };
-            let redirectUris = uris.map(uriToRedirectUri);
+            let redirectUrls = uris.map((uri) => this.getRedirectURL(uri.spec));
 
             console.log(`TorConnect: Will load after bootstrap => [${uris.map((uri) => {return uri.spec;}).join(", ")}]`);
-            return redirectUris;
+            return redirectUrls;
         },
     };
     retval.init();





More information about the tbb-commits mailing list