Bug 514209 - Don't update gProfileRoot in case of bad input. r=jimm
--- a/toolkit/profile/content/createProfileWizard.js
+++ b/toolkit/profile/content/createProfileWizard.js
@@ -8,17 +8,16 @@ const I = Components.interfaces;
Components.utils.import("resource://gre/modules/AppConstants.jsm");
const ToolkitProfileService = "@mozilla.org/toolkit/profile-service;1";
var gProfileService;
var gProfileManagerBundle;
var gDefaultProfileParent;
-var gOldProfileName;
// The directory where the profile will be created.
var gProfileRoot;
// Text node to display the location and name of the profile to create.
var gProfileDisplay;
// Called once when the wizard is opened.
@@ -26,18 +25,16 @@ function initWizard()
{
try {
gProfileService = C[ToolkitProfileService].getService(I.nsIToolkitProfileService);
gProfileManagerBundle = document.getElementById("bundle_profileManager");
var dirService = C["@mozilla.org/file/directory_service;1"].getService(I.nsIProperties);
gDefaultProfileParent = dirService.get("DefProfRt", I.nsIFile);
- gOldProfileName = document.getElementById("profileName").value;
-
// Initialize the profile location display.
gProfileDisplay = document.getElementById("profileDisplay").firstChild;
setDisplayToDefaultFolder();
}
catch(e) {
window.close();
throw (e);
}
@@ -132,30 +129,26 @@ function checkCurrentInput(currentInput)
finishText.firstChild.data = errorMessage;
canAdvance = false;
}
document.documentElement.canAdvance = canAdvance;
finishButton.disabled = !canAdvance;
updateProfileDisplay();
+
+ return canAdvance;
}
-function updateProfileName(aNewName) {
- checkCurrentInput(aNewName);
-
- var re = new RegExp("^[a-z0-9]{8}\\." +
- gOldProfileName.replace(/[|^$()\[\]{}\\+?.*]/g, "\\$&")
- + '$');
-
- if (re.test(gProfileRoot.leafName)) {
+function updateProfileName(aNewName)
+{
+ if (checkCurrentInput(aNewName)) {
gProfileRoot.leafName = saltName(aNewName);
updateProfileDisplay();
}
- gOldProfileName = aNewName;
}
// Checks whether the given string is a valid profile name.
// Returns an error message describing the error in the name or "" when it's valid.
function checkProfileName(profileNameToCheck)
{
// Check for emtpy profile name.
if (!/\S/.test(profileNameToCheck))