Bug 514209 - Don't update gProfileRoot in case of bad input. r=jimm
authorJan Sonntag <jaso35@googlemail.com>
Sat, 19 Mar 2016 01:51:00 -0400
changeset 289502 f5b01783baaa9114f8dcd90ba40dcfdf147739c1
parent 289501 4015564e7420abe89cf27e2e1c570137a538b601
child 289503 f379a01f7e66f446931ebe8639714566c77cb32f
push id18270
push userryanvm@gmail.com
push dateSun, 20 Mar 2016 04:26:12 +0000
treeherderfx-team@f14898695ee0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjimm
bugs514209
milestone48.0a1
Bug 514209 - Don't update gProfileRoot in case of bad input. r=jimm
toolkit/profile/content/createProfileWizard.js
--- 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))