Bug 1176602 - Make sure that the dictionary stored in spellchecker.dictionary is valid (Adapt Thunderbird Bug 1175908) r=Neil a=IanN for comm-aurora comm-beta and comm-release CLOSED TREE
authorPhilip Chee <philip.chee@gmail.com>
Fri, 18 Sep 2015 23:30:52 +0800
changeset 31211 1be679fa13d5af0274208ee8e5b4eecb71f98ec9
parent 31198 58111896d3d0c6c6b1a76fd3f3dbbb8a9a9af59a
child 31212 83f2af2ad036b15789010f3b460751fe5c1962c8
push id1
push userclokep@gmail.com
push dateMon, 07 May 2018 22:45:56 +0000
treeherdercomm-esr60@57eacde5ef40 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersNeil, IanN
bugs1176602, 1175908
Bug 1176602 - Make sure that the dictionary stored in spellchecker.dictionary is valid (Adapt Thunderbird Bug 1175908) r=Neil a=IanN for comm-aurora comm-beta and comm-release CLOSED TREE
suite/common/src/nsSuiteGlue.js
--- a/suite/common/src/nsSuiteGlue.js
+++ b/suite/common/src/nsSuiteGlue.js
@@ -338,16 +338,17 @@ SuiteGlue.prototype = {
                              "_blank", "chrome,centerscreen,modal,resizable=no", null);
     }
   },
 
   // profile startup handler (contains profile initialization routines)
   _onProfileStartup: function()
   {
     this._updatePrefs();
+    this._migrateDownloadPrefs();
     migrateMailnews(); // mailnewsMigrator.js
 
     Sanitizer.checkSettings();
     Sanitizer.doPendingSanitize();
 
     if (Services.prefs.prefHasUserValue("privacy.sanitize.didShutdownSanitize")) {
       Services.prefs.clearUserPref("privacy.sanitize.didShutdownSanitize");
       // We need to persist this preference change, since we want to
@@ -949,16 +950,36 @@ SuiteGlue.prototype = {
     // tri-state; 0=always but not accessibility themes, 1=always, 2=never
     try {
       if (!Services.prefs.getBoolPref("browser.display.use_document_colors")) {
         Services.prefs.setIntPref("browser.display.document_color_use", 2);
         Services.prefs.clearUserPref("browser.display.use_document_colors");
       }
     } catch (ex) {}
 
+    // Ensure that this preference is set to a valid dictionary.
+    var prefName = "spellchecker.dictionary";
+    var prefValue = Services.prefs.getCharPref(prefName);
+    if (/_/.test(prefValue)) {
+      prefValue = prefValue.replace(/_/g, "-");
+      Services.prefs.setCharPref(prefName, prefValue);
+    }
+    var spellChecker = Components.classes["@mozilla.org/spellchecker/engine;1"]
+                                 .getService(Components.interfaces.mozISpellCheckingEngine);
+    var o1 = {};
+    spellChecker.getDictionaryList(o1, {});
+    var dictList = o1.value;
+    // If the preference contains an invalid dictionary, set it to a valid
+    // dictionary, any dictionary will do.
+    if (dictList.length && dictList.indexOf(prefValue) < 0)
+      Services.prefs.setCharPref(prefName, dictList[0]);
+  },
+
+  _migrateDownloadPrefs: function()
+  {
     // Migration of download-manager preferences
     if (Services.prefs.getPrefType("browser.download.dir") == Services.prefs.PREF_INVALID ||
         Services.prefs.getPrefType("browser.download.lastDir") != Services.prefs.PREF_INVALID)
       return; //Do nothing if .dir does not exist, or if it exists and lastDir does not
 
     try {
       Services.prefs.setComplexValue("browser.download.lastDir",
                                      Components.interfaces.nsILocalFile,