Bug 1081693 - Port Bug 947507 to thunderbird: Reset intl.charset.detector if not set to off, Japanese, Russian or Ukrainian. r=bwinton, a=mkmelin
authorMagnus Melin <mkmelin+mozilla@iki.fi>
Sat, 13 Dec 2014 14:00:15 +0200
changeset 21491 a46f0d8be50bc614825d3fdec7b4f0b612538317
parent 21490 2843a3e7968ba370c5e7b8723ccfff1fe7465fec
child 21492 dbab5a5315945d5ca0eb69c873fe86d8e4e3cc24
push id1305
push usermbanner@mozilla.com
push dateMon, 23 Feb 2015 19:48:12 +0000
treeherdercomm-beta@3ae4f13858fd [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbwinton, mkmelin
bugs1081693, 947507
Bug 1081693 - Port Bug 947507 to thunderbird: Reset intl.charset.detector if not set to off, Japanese, Russian or Ukrainian. r=bwinton, a=mkmelin
mail/base/modules/mailMigrator.js
--- a/mail/base/modules/mailMigrator.js
+++ b/mail/base/modules/mailMigrator.js
@@ -90,20 +90,20 @@ var MailMigrator = {
       }
     }
   },
 
   /**
    * Determine if the UI has been upgraded in a way that requires us to reset
    * some user configuration.  If so, performs the resets.
    */
-  _migrateUI: function MailMigrator__migrateUI() {
+  _migrateUI: function() {
     // The code for this was ported from
     // mozilla/browser/components/nsBrowserGlue.js
-    const UI_VERSION = 8;
+    const UI_VERSION = 9;
     const MESSENGER_DOCURL = "chrome://messenger/content/messenger.xul";
     const UI_VERSION_PREF = "mail.ui-rdf.version";
     let currentUIVersion = 0;
 
     try {
       currentUIVersion = Services.prefs.getIntPref(UI_VERSION_PREF);
     } catch(ex) {}
 
@@ -247,16 +247,33 @@ var MailMigrator = {
       if (currentUIVersion < 8) {
         const kOldColorPref = "browser.display.use_document_colors";
         if (Services.prefs.prefHasUserValue(kOldColorPref) &&
             !Services.prefs.getBoolPref(kOldColorPref)) {
           Services.prefs.setIntPref("browser.display.document_color_use", 2);
         }
       }
 
+      // Limit the charset detector pref to values (now) available from the UI.
+      if (currentUIVersion < 9) {
+        let detector = null;
+        try {
+          detector = Services.prefs.getComplexValue("intl.charset.detector",
+                                                    Ci.nsIPrefLocalizedString).data;
+        } catch (ex) { }
+        if (!(detector == "" ||
+              detector == "ja_parallel_state_machine" ||
+              detector == "ruprob" ||
+              detector == "ukprob")) {
+          // If the encoding detector pref value is not reachable from the UI,
+          // reset to default (varies by localization).
+          Services.prefs.clearUserPref("intl.charset.detector");
+        }
+      }
+
       // Update the migration version.
       Services.prefs.setIntPref(UI_VERSION_PREF, UI_VERSION);
 
     } catch(e) {
       Cu.reportError("Migrating from UI version " + currentUIVersion + " to " +
                      UI_VERSION + " failed. Error message was: " + e + " -- " +
                      "Will reattempt on next start.");
     }