diff --git a/mozilla/toolkit/profile/content/createProfileWizard.js b/mozilla/toolkit/profile/content/createProfileWizard.js index 73b21f9fe2b..a654f8bfc45 100644 --- a/mozilla/toolkit/profile/content/createProfileWizard.js +++ b/mozilla/toolkit/profile/content/createProfileWizard.js @@ -74,10 +74,26 @@ function initSecondWizardPage() checkCurrentInput(profileName.value); } +const kSaltTable = [ + 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', + 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', + '1', '2', '3', '4', '5', '6', '7', '8', '9', '0' ]; + +var kSaltString = ""; +for (var i = 0; i < 8; ++i) { + kSaltString += kSaltTable[Math.floor(Math.random() * kSaltTable.length)]; +} + + +function saltName(aName) +{ + return kSaltString + "." + aName; +} + function setDisplayToDefaultFolder() { var defaultProfileDir = gDefaultProfileParent.clone(); - defaultProfileDir.append(document.getElementById("profileName").value); + defaultProfileDir.append(saltName(document.getElementById("profileName").value)); gProfileRoot = defaultProfileDir; document.getElementById("useDefault").disabled = true; } @@ -138,8 +154,12 @@ function checkCurrentInput(currentInput) function updateProfileName(aNewName) { checkCurrentInput(aNewName); - if (gProfileRoot.leafName == gOldProfileName) { - gProfileRoot.leafName = aNewName; + var re = new RegExp("^[a-z0-9]{8}\\." + + gOldProfileName.replace(/[|^$()\[\]{}\\+?.*]/g, "\\$&") + + '$'); + + if (re.test(gProfileRoot.leafName)) { + gProfileRoot.leafName = saltName(aNewName); updateProfileDisplay(); } gOldProfileName = aNewName; diff --git a/mozilla/toolkit/profile/src/nsToolkitProfileService.cpp b/mozilla/toolkit/profile/src/nsToolkitProfileService.cpp index 98ca3718cce..8ec4f11b177 100644 --- a/mozilla/toolkit/profile/src/nsToolkitProfileService.cpp +++ b/mozilla/toolkit/profile/src/nsToolkitProfileService.cpp @@ -551,10 +551,15 @@ static void SaltProfileName(nsACString& aName) // use 1e-6, granularity of PR_Now() on the mac is seconds srand((uint)(fpTime * 1e-6 + 0.5)); - aName.Append('.'); + char salt[9]; + int i; - for (i = 0; i < 3; ++i) - aName.Append(kTable[rand() % NS_ARRAY_LENGTH(kTable)]); + for (i = 0; i < 8; ++i) + salt[i] = kTable[rand() % NS_ARRAY_LENGTH(kTable)]; + + salt[8] = '.'; + + aName.Insert(salt, 0, 9); } NS_IMETHODIMP