diff --git a/mozilla/xpfe/global/resources/content/config.js b/mozilla/xpfe/global/resources/content/config.js index c3e4fef1b47..107f2e8ae8c 100644 --- a/mozilla/xpfe/global/resources/content/config.js +++ b/mozilla/xpfe/global/resources/content/config.js @@ -538,7 +538,16 @@ function ModifyPref(entry) if (!gPromptService.prompt(window, title, entry.prefCol, result, null, dummy)) return false; if (entry.typeCol == nsIPrefBranch.PREF_INT) { - gPrefBranch.setIntPref(entry.prefCol, eval(result.value)); + // | 0 converts to integer or 0; - 0 to float or NaN. + // Thus, this check should catch all cases. + var val = result.value | 0; + if (val != result.value - 0) { + var err_title = gConfigBundle.getString("nan_title"); + var err_text = gConfigBundle.getString("nan_text"); + gPromptService.alert(window, err_title, err_text); + return false; + } + gPrefBranch.setIntPref(entry.prefCol, val); } else { var supportsString = Components.classes[nsSupportsString_CONTRACTID].createInstance(nsISupportsString); supportsString.data = result.value; diff --git a/mozilla/xpfe/global/resources/locale/en-US/config.properties b/mozilla/xpfe/global/resources/locale/en-US/config.properties index aa11a6b9f6d..af7ebf6f777 100644 --- a/mozilla/xpfe/global/resources/locale/en-US/config.properties +++ b/mozilla/xpfe/global/resources/locale/en-US/config.properties @@ -52,3 +52,6 @@ bool=boolean new_title=New %S value new_prompt=Enter the preference name modify_title=Enter %S value + +nan_title=Invalid value +nan_text=The text you entered is not a number.