Bug 256076 - salt profiles 8.profilename instead of profilename.3 (and fix bug 255238 in the process, profiles created from the profile manager UI aren't salted at all) r=dveditz sr=brendan a=ben

git-svn-id: svn://10.0.0.236/branches/AVIARY_1_0_20040515_BRANCH@161315 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
bsmedberg%covad.net
2004-08-26 12:56:42 +00:00
parent af7b71f254
commit 25b7d7c778
2 changed files with 31 additions and 6 deletions

View File

@@ -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;

View File

@@ -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