[tbb-commits] [torbutton/master] Bug 16730: Reset NoScript whitelist on upgrade

gk at torproject.org gk at torproject.org
Fri Aug 7 19:25:22 UTC 2015


commit 59ef74948aeea8d73f8833ab9e918cd1b70b6a32
Author: Georg Koppen <gk at torproject.org>
Date:   Fri Aug 7 15:09:42 2015 +0000

    Bug 16730: Reset NoScript whitelist on upgrade
    
    This fixes 16722 as well and resets the toolbar UI to kill
    "Share this page", but that still requires another restart :/.
    
    This is basically Mike's idea and code.
---
 src/chrome/content/torbutton.js         |   38 +++++++++++++++++++++++++++++++
 src/defaults/preferences/preferences.js |    3 +++
 2 files changed, 41 insertions(+)

diff --git a/src/chrome/content/torbutton.js b/src/chrome/content/torbutton.js
index 1d81960..28da420 100644
--- a/src/chrome/content/torbutton.js
+++ b/src/chrome/content/torbutton.js
@@ -2864,6 +2864,41 @@ function torbutton_restore_cookies(tor_enabled)
     }
 }
 
+// Bug 1506 P1: This function just cleans up prefs that got set badly in previous releases
+function torbutton_fixup_old_prefs()
+{
+    if(m_tb_prefs.getIntPref('extensions.torbutton.pref_fixup_version') < 1) {
+        // TBB 5.0a3 had bad Firefox code that silently flipped this pref on us
+        if (m_tb_prefs.prefHasUserValue("browser.newtabpage.enhanced")) {
+            m_tb_prefs.clearUserPref("browser.newtabpage.enhanced");
+            // TBB 5.0a3 users had all the necessary data cached in
+            // directoryLinks.json. This meant that resetting the pref above
+            // alone was not sufficient as the tiles features uses the cache
+            // even if the pref indicates that feature should be disabled.
+            // We flip the preference below as this forces a refetching which
+            // effectively results in an empty JSON file due to our spoofed
+            // URLs.
+            let matchOS = m_tb_prefs.getBoolPref("intl.locale.matchOS");
+            m_tb_prefs.setBoolPref("intl.locale.matchOS", !matchOS);
+            m_tb_prefs.setBoolPref("intl.locale.matchOS", matchOS);
+        }
+
+        // Prior to TBB 5.0, NoScript was allowed to update its whitelist. This caused
+        // odd things to appear in people's whitelists.
+        if (m_tb_prefs.prefHasUserValue("capability.policy.maonoscript.sites")) {
+            m_tb_prefs.clearUserPref("capability.policy.maonoscript.sites");
+        }
+
+        // For some reason, the Share This Page button also survived the
+        // TBB 5.0a4 update's attempt to remove it.
+        if (m_tb_prefs.prefHasUserValue("browser.uiCustomization.state")) {
+            m_tb_prefs.clearUserPref("browser.uiCustomization.state");
+        }
+
+        m_tb_prefs.setIntPref('extensions.torbutton.pref_fixup_version', 1);
+    }
+}
+
 // ---------------------- Event handlers -----------------
 
 // Bug 1506 P1/P3: This removes any platform-specific junk
@@ -2971,6 +3006,9 @@ function torbutton_do_startup()
           prompts.alert(null, title, warning);
         }
 
+        // For general pref fixups to handle pref damage in older versions
+        torbutton_fixup_old_prefs();
+
         m_tb_prefs.setBoolPref("extensions.torbutton.startup", false);
     }
 }
diff --git a/src/defaults/preferences/preferences.js b/src/defaults/preferences/preferences.js
index 6b4ec0c..ce66d0e 100644
--- a/src/defaults/preferences/preferences.js
+++ b/src/defaults/preferences/preferences.js
@@ -225,3 +225,6 @@ pref("spellchecker.dictionary", "chrome://torbutton/locale/browser.properties");
 
 pref("extensions.torbutton.window.maxHeight", 1000);
 pref("extensions.torbutton.window.maxWidth", 1000);
+
+// This pref specifies an ad-hoc "version" for various pref update hacks we need to do
+pref("extensions.torbutton.pref_fixup_version", 0);



More information about the tbb-commits mailing list