Bug 992118 - Correctly handle the underscore in the LANG environment variable; r=smaug

This commit is contained in:
Ehsan Akhgari 2014-04-30 18:01:12 -04:00
parent 2378f04be0
commit 50a084ff52

View File

@ -752,6 +752,12 @@ nsEditorSpellCheck::DictionaryFetched(DictionaryFetcher* aFetcher)
// otherwise, get language from preferences
nsAutoString preferedDict(Preferences::GetLocalizedString("spellchecker.dictionary"));
// Replace '_' with '-' in case the user has an underscore stored in their
// pref, see bug 992118 for how this could have happened.
int32_t underScore = preferedDict.FindChar('_');
if (underScore != -1) {
preferedDict.Replace(underScore, 1, '-');
}
if (dictName.IsEmpty()) {
dictName.Assign(preferedDict);
}
@ -845,6 +851,11 @@ nsEditorSpellCheck::DictionaryFetched(DictionaryFetcher* aFetcher)
if (dot_pos != -1) {
lang = Substring(lang, 0, dot_pos - 1);
}
// Replace '_' with '-'
int32_t underScore = lang.FindChar('_');
if (underScore != -1) {
lang.Replace(underScore, 1, '-');
}
rv = SetCurrentDictionary(lang);
}
if (NS_FAILED(rv)) {