[tbb-commits] [torbutton/master] Bug 26409: Remove spoofed locale implementation

gk at torproject.org gk at torproject.org
Mon Aug 13 11:38:46 UTC 2018


commit e950aeac23670983bedd84c6526bb9a865450a25
Author: Georg Koppen <gk at torproject.org>
Date:   Wed Aug 1 08:04:21 2018 +0000

    Bug 26409: Remove spoofed locale implementation
    
    In bug 1039069 Mozilla implemented the option of spoofing the locale in
    the Accept-Language header/JS locale if users with localized builds want
    that for better fingerprinting protection. That makes our workaround in
    Torbutton obsolete and we can remove it. Otherwise users start to get
    the respective language prompt twice, which is quite annoying.
---
 src/chrome/content/torbutton.js           | 109 +-----------------------------
 src/chrome/locale/en/torbutton.properties |   1 -
 src/defaults/preferences/preferences.js   |   2 -
 3 files changed, 1 insertion(+), 111 deletions(-)

diff --git a/src/chrome/content/torbutton.js b/src/chrome/content/torbutton.js
index 18895927..d0195b46 100644
--- a/src/chrome/content/torbutton.js
+++ b/src/chrome/content/torbutton.js
@@ -12,7 +12,7 @@ let { showDialog } = Cu.import("resource://torbutton/modules/utils.js", {});
 let { getLocale, unescapeTorString } = Cu.import("resource://torbutton/modules/utils.js", {});
 let SecurityPrefs = Cu.import("resource://torbutton/modules/security-prefs.js", {});
 let NoScriptControl = Cu.import("resource://torbutton/modules/noscript-control.js", {});
-let { bindPrefAndInit, observe } = Cu.import("resource://torbutton/modules/utils.js", {});
+let { bindPrefAndInit } = Cu.import("resource://torbutton/modules/utils.js", {});
 
 Cu.importGlobalProperties(["XMLHttpRequest"]);
 
@@ -170,7 +170,6 @@ var torbutton_unique_pref_observer =
                 torbutton_use_nontor_proxy();
                 break;
             case "privacy.resistFingerprinting":
-            case "extensions.torbutton.spoof_english":
                 torbutton_update_fingerprinting_prefs();
                 break;
             case "privacy.firstparty.isolate":
@@ -463,36 +462,6 @@ var torbutton_abouttor_message_handler = {
   }
 };
 
-function torbutton_should_prompt_for_language_preference() {
-  return torbutton_get_general_useragent_locale().substring(0, 2) != "en" &&
-        !m_tb_prefs.getBoolPref("extensions.torbutton.prompted_language");
-}
-
-
-// Bug 1506 P3: This code asks the user once if they want to spoof their
-// language to English.
-//
-// Asks the user whether Torbutton should make "English requests", and updates
-// the extensions.torbutton.spoof_english preference accordingly.
-function torbutton_prompt_for_language_preference() {
-  var prompts = Cc["@mozilla.org/embedcomp/prompt-service;1"]
-                  .getService(Ci.nsIPromptService);
-
-  // Display two buttons, both with string titles.
-  var flags = prompts.STD_YES_NO_BUTTONS;
-
-  var message = torbutton_get_property_string("torbutton.popup.prompted_language");
-
-  m_tb_prefs.setBoolPref("extensions.torbutton.prompted_language", true);
-  // Display modal prompt, anchored to this window.
-  var response = prompts.confirmEx(window, "", message, flags,
-                                   null, null, null, null, {value: false});
-
-  // Update preferences to reflect their response and to prevent the prompt from
-  // being displayed again.
-  m_tb_prefs.setBoolPref("extensions.torbutton.spoof_english", response == 0);
-}
-
 function torbutton_confirm_plugins() {
   var any_plugins_enabled = false;
   var PH=Cc["@mozilla.org/plugin/host;1"].getService(Ci.nsIPluginHost);
@@ -1641,23 +1610,6 @@ function torbutton_update_disk_prefs() {
 function torbutton_update_fingerprinting_prefs() {
     var mode = m_tb_prefs.getBoolPref("privacy.resistFingerprinting");
 
-    if (m_tb_tbb) {
-      if (mode) {
-        // Governed also by the spoof_english dialog..
-        if (m_tb_prefs.getBoolPref("extensions.torbutton.spoof_english")) {
-          m_tb_prefs.setCharPref("intl.accept_languages", "en-US, en");
-          m_tb_prefs.setBoolPref("javascript.use_us_english_locale", true);
-        } else {
-          if(m_tb_prefs.prefHasUserValue("intl.accept_languages"))
-            m_tb_prefs.clearUserPref("intl.accept_languages");
-          m_tb_prefs.setBoolPref("javascript.use_us_english_locale", false);
-        }
-      } else {
-        if(m_tb_prefs.prefHasUserValue("intl.accept_languages"))
-          m_tb_prefs.clearUserPref("intl.accept_languages");
-      }
-    }
-
     m_tb_prefs.setBoolPref("webgl.min_capability_mode", mode);
     m_tb_prefs.setBoolPref("webgl.disable-extensions", mode);
     m_tb_prefs.setBoolPref("dom.network.enabled", !mode);
@@ -2019,8 +1971,6 @@ function torbutton_is_windowed(wind) {
     return true;
 }
 
-let stopLanguagePromptObserver;
-
 // Bug 1506 P3: This is needed pretty much only for the version check
 // and the window resizing. See comments for individual functions for
 // details
@@ -2054,15 +2004,6 @@ function torbutton_new_window(event)
                                    Ci.nsIWebProgress.NOTIFY_STATE_DOCUMENT);
     }
 
-    // If the default language is not English and we have not already asked,
-    // add an http-on-modify-request observer that will show a "request English
-    // language web pages?" prompt the first time a content http or https page
-    // is opened.
-    if (torbutton_should_prompt_for_language_preference()) {
-      stopLanguagePromptObserver = observe("http-on-modify-request",
-                                           torbutton_http_connection_observed);
-    }
-
     // Check the version on every new window. We're already pinging check in these cases.    
     torbutton_do_async_versioncheck();
 
@@ -2238,54 +2179,6 @@ var torbutton_resizelistener =
   onSecurityChange: function() {}
 };
 
-function torbutton_http_connection_observed(aRequest, aData) {
-  // If we are loading an HTTP page from content, show the
-  // "request English language web pages?" prompt.
-  try {
-    let httpChannel = aRequest.QueryInterface(Ci.nsIHttpChannel);
-    if (!aRequest.URI.schemeIs("http") && !aRequest.URI.schemeIs("https")) {
-      return;
-    }
-    if (!httpChannel) return;
-    let notificationCallbacks = httpChannel.notificationCallbacks;
-    if (!notificationCallbacks) return;
-    let loadContext = notificationCallbacks.getInterface(Ci.nsILoadContext);
-    if (!loadContext) return;
-    if (!loadContext.isContent) return;
-    // The above QI did not throw, the scheme is http[s], and we know the
-    // load context is content, so we must have a true HTTP request from content.
-    // Stop the observer and display the prompt if another window has
-    // not already done so.
-    stopLanguagePromptObserver();
-
-    if (torbutton_should_prompt_for_language_preference()) {
-      if (torbutton_is_homepage_url(aRequest.URI)) {
-        // If the homepage is being loaded, display the prompt after a
-        // delay to avoid a problem where a blank prompt is displayed.
-        // In this case, the homepage will be loaded using the current
-        // spoof English setting, which is OK.
-        setTimeout(function() {
-          if (torbutton_should_prompt_for_language_preference())
-            torbutton_prompt_for_language_preference();
-        }, 2000);
-      } else {
-        // No delay is needed. Display the prompt and fix up the
-        // Accept-Language header before allowing the load to continue.
-        torbutton_prompt_for_language_preference();
-
-        // The Accept-Language header for this request was set when the
-        // channel was created. Reset it to match the value that will be
-        // used for future requests.
-        let val = torbutton_get_current_accept_language_value(aRequest.URI);
-        if (val)
-          httpChannel.setRequestHeader("Accept-Language", val, false);
-      }
-    }
-  } catch (e) {
-    torbutton_log(3, e.message);
-  }
-}
-
 // aURI should be an http or https nsIURI object.
 function torbutton_get_current_accept_language_value(aURI)
 {
diff --git a/src/chrome/locale/en/torbutton.properties b/src/chrome/locale/en/torbutton.properties
index d77af1ee..53573df0 100644
--- a/src/chrome/locale/en/torbutton.properties
+++ b/src/chrome/locale/en/torbutton.properties
@@ -21,7 +21,6 @@ torbutton.popup.external.suggest = To be safe, you should only open downloaded f
 torbutton.popup.launch = Download file
 torbutton.popup.cancel = Cancel
 torbutton.popup.dontask = Automatically download files from now on
-torbutton.popup.prompted_language = To give you more privacy, Torbutton can request the English language version of web pages. This may cause web pages that you prefer to read in your native language to display in English instead.\n\nWould you like to request English language web pages for better privacy?
 torbutton.popup.no_newnym = Torbutton cannot safely give you a new identity. It does not have access to the Tor Control Port.\n\nAre you running Tor Browser Bundle?
 torbutton.title.prompt_torbrowser = Important Torbutton Information
 torbutton.popup.prompt_torbrowser = Torbutton works differently now: you can't turn it off any more.\n\nWe made this change because it isn't safe to use Torbutton in a browser that's also used for non-Tor browsing. There were too many bugs there that we couldn't fix any other way.\n\nIf you want to keep using Firefox normally, you should uninstall Torbutton and download Tor Browser Bundle. The privacy properties of Tor Browser are also superior to those of normal Firefox, even when Firefox is used with Torbutton.\n\nTo remove Torbutton, go to Tools->Addons->Extensions and then click the Remove button next to Torbutton.
diff --git a/src/defaults/preferences/preferences.js b/src/defaults/preferences/preferences.js
index 5cfb0eb3..ab9b4bf4 100644
--- a/src/defaults/preferences/preferences.js
+++ b/src/defaults/preferences/preferences.js
@@ -19,7 +19,6 @@ pref("extensions.torbutton.use_nontor_proxy",false);
 // State prefs:
 pref("extensions.torbutton.startup",false);
 pref("extensions.torbutton.inserted_button",false);
-pref("extensions.torbutton.prompted_language",false);
 
 // TODO: This is just part of a stopgap until #14429 gets properly implemented.
 // See #7255 for details. We display the warning three times to make sure the
@@ -29,7 +28,6 @@ pref("extensions.torbutton.maximize_warnings_remaining", 3);
 // Security prefs:
 pref("extensions.torbutton.cookie_protections",true);
 pref("extensions.torbutton.cookie_auto_protect",false);
-pref("extensions.torbutton.spoof_english",true);
 pref("extensions.torbutton.clear_http_auth",true);
 pref("extensions.torbutton.close_newnym",true);
 pref("extensions.torbutton.resize_new_windows",true);



More information about the tbb-commits mailing list