[or-cvs] [torbutton/master 19/30] Fix two google search redirect issues.

mikeperry at torproject.org mikeperry at torproject.org
Fri Apr 9 22:54:00 UTC 2010


Author: Mike Perry <mikeperry-git at fscked.org>
Date: Sat, 3 Apr 2010 05:40:33 -0700
Subject: Fix two google search redirect issues.
Commit: c41a140161c4166ddd938dbf59b5687732e26482

Both were introduced in bug 1304's fixes. First was in a multiple
redirect. Second was in the google search box randomly dying.
---
 src/chrome/content/torbutton.js |   42 +++++++++++++++++++++++++++++++++++---
 1 files changed, 38 insertions(+), 4 deletions(-)

diff --git a/src/chrome/content/torbutton.js b/src/chrome/content/torbutton.js
index 2ccbe8f..62f6b91 100644
--- a/src/chrome/content/torbutton.js
+++ b/src/chrome/content/torbutton.js
@@ -2233,6 +2233,8 @@ function torbutton_tag_new_browser(browser, tor_tag, no_plugins) {
         browser.__tb_tor_fetched = !tor_tag;
 
         // XXX: Do we need to remove this listener on tab close?
+        // No, but we probably do need to remove it on window close!
+        // FF3.5 may be throwing uncaught exceptions!
         var hlisten = new tbHistoryListener(browser);
 
         var sessionSetter = function() {
@@ -2821,6 +2823,31 @@ function torbutton_check_google_captcha(subject, topic, data) {
                   subject.URI.originCharset, null);
     redirURI = redirURI.QueryInterface(Components.interfaces.nsIURI);
     if (redirURI.host == "sorry.google.com") {
+      var browser = null;
+      if(m_tb_ff3 && subject.notificationCallbacks) {
+        // Arg. google.timers.load.t is fucking us up!
+        try {
+          var wind = subject.notificationCallbacks.QueryInterface(
+                  Components.interfaces.nsIInterfaceRequestor).getInterface(
+                      Components.interfaces.nsIDOMWindow);
+          var wm = Components.classes["@torproject.org/content-window-mapper;1"]
+             .getService(Components.interfaces.nsISupports)
+             .wrappedJSObject;
+          if(wind.top instanceof Components.interfaces.nsIDOMChromeWindow) {
+            if(wind.top.browserDOMWindow) {
+              // This never seems to work. Leaving it in just in case
+              // for optimizations sake.
+              torbutton_log(3, "Got browser window for 302");
+              browser = wind.top.getBrowser().selectedTab.linkedBrowser;
+            }
+          }
+          if (!browser)
+            browser = wm.getBrowserForContentWindow(wind.window.top);
+        } catch(e) {
+          torbutton_log(4, "Exception on google captcha logging: "+e);
+        }
+      }
+
       querymatch = subject.URI.path.match("[\?\&]q=([^&]+)(?:[\&]|$)");
       if (!querymatch) {
         torbutton_safelog(4, "No Google query found for captcha in: ",
@@ -2864,6 +2891,8 @@ function torbutton_check_google_captcha(subject, topic, data) {
         }
       }
       // Split url into [?&]q=...[&$]
+      if (browser)
+        browser.loadURI(newUrl+querymatch[1], null, subject.URI.originCharset);
       httpChannel.setResponseHeader("Location", newUrl+querymatch[1], false);
       torbutton_log(4, "Got Google Captcha. Redirecting");
     }
@@ -3155,7 +3184,12 @@ function torbutton_wrap_search_service()
     // searchForm.match(/^www\.google\.(co\.\S\S|com|\S\S|com\.\S\S)$/);
     if(origEngineObj._name.indexOf("Google") != -1) {
       torbutton_log(3, "Found google search plugin to wrap.");
-      origEngineObj.oldGetSubmission=origEngineObj.getSubmission;
+      if (typeof(origEngineObj.oldGetSubmission) == "undefined") {
+        torbutton_log(3, "Original window for google search");
+        origEngineObj.oldGetSubmission=origEngineObj.getSubmission;
+      } else {
+        torbutton_log(3, "Secondary window for google search");
+      }
       origEngineObj.getSubmission = function lmbd(aData, respType) {
         var sub = this.oldGetSubmission(aData, respType);
         if(!m_tb_prefs.getBoolPref("extensions.torbutton.tor_enabled")
@@ -3197,6 +3231,9 @@ function torbutton_do_main_window_startup()
         Components.interfaces.nsIWebProgress.NOTIFY_STATE_DOCUMENT|
             Components.interfaces.nsIWebProgress.NOTIFY_LOCATION);
 
+    // Wrap Google search service.
+    torbutton_wrap_search_service();
+
     torbutton_unique_pref_observer.register();
     torbutton_uninstall_observer.register();
     torbutton_http_observer.register();
@@ -3318,9 +3355,6 @@ function torbutton_do_startup()
           torbutton_new_google_cookie();
         }
 
-        // Wrap Google search service.
-        torbutton_wrap_search_service();
-
         m_tb_prefs.setBoolPref("extensions.torbutton.startup", false);
     }
 }
-- 
1.6.5




More information about the tor-commits mailing list