Bug 400751 Migrating from an existing SeaMonkey installation causes errors in password manager due to old style encyption. r=dolske,gavin,aM9=beltzner

This commit is contained in:
bugzilla@standard8.plus.com 2007-10-25 08:59:11 -07:00
parent 8853d43cd5
commit 0152d4c715
3 changed files with 53 additions and 7 deletions

View File

@ -154,7 +154,7 @@ LoginManagerStorage_legacy.prototype = {
}
// Read in the stored login data.
this._readFile()
this._readFile();
// If we were importing, write back to the normal file.
if (importFile) {
@ -810,14 +810,28 @@ LoginManagerStorage_legacy.prototype = {
login.username = username;
login.password = password;
// Force any old mime64-obscured entries to be reencrypted.
// Old mime64-obscured entries need to be reencrypted in the new
// format.
if (login.wrappedJSObject.encryptedUsername &&
login.wrappedJSObject.encryptedUsername.charAt(0) == '~')
login.wrappedJSObject.encryptedUsername = null;
login.wrappedJSObject.encryptedUsername.charAt(0) == '~') {
[username, userCanceled] = this._encrypt(login.username);
if (userCanceled)
break;
login.wrappedJSObject.encryptedUsername = username;
}
if (login.wrappedJSObject.encryptedPassword &&
login.wrappedJSObject.encryptedPassword.charAt(0) == '~')
login.wrappedJSObject.encryptedPassword = null;
login.wrappedJSObject.encryptedPassword.charAt(0) == '~') {
[password, userCanceled] = this._encrypt(login.password);
if (userCanceled)
break;
login.wrappedJSObject.encryptedPassword = password;
}
result.push(login);
}

View File

@ -97,7 +97,7 @@ LoginTest.checkStorageData(storage, ["http://www.disabled.com"], []);
/* ========== 7 ========== */
testnum++;
testdesc = "Initialize with signons-06.txt (1 disabled, 0 logins, extra '.')";
testdesc = "Initialize with signons-04.txt (1 disabled, 0 logins, extra '.')";
// Mozilla code should never have generated the extra ".", but it's possible
// someone writing an external utility might have generated it, since it

View File

@ -146,6 +146,38 @@ logins = storage.getAllLogins({});
LoginTest.checkStorageData(storage, [], [dummyuser4]);
/*
* ---------------------- Bug 400751 ----------------------
* Migrating from existing mime64 encoded format causes
* errors in storage legacy's code
*/
/* ========== 8 ========== */
testnum++;
testdesc = "checking double reading of mime64-obscured entries";
LoginTest.initStorage(storage, INDIR, "signons-380961-1.txt");
LoginTest.checkStorageData(storage, [], [dummyuser1]);
testdesc = "checking double reading of mime64-obscured entries part 2";
LoginTest.checkStorageData(storage, [], [dummyuser1]);
/* ========== 9 ========== */
testnum++;
testdesc = "checking correct storage of mime64 converted entries";
LoginTest.initStorage(storage, INDIR, "signons-380961-1.txt",
OUTDIR, "output-400751-1.txt");
LoginTest.checkStorageData(storage, [], [dummyuser1]);
LoginTest.checkStorageData(storage, [], [dummyuser1]);
storage.addLogin(dummyuser2); // trigger a write
LoginTest.checkStorageData(storage, [], [dummyuser1, dummyuser2]);
testdesc = "[flush and reload for verification]";
LoginTest.initStorage(storage, OUTDIR, "output-400751-1.txt");
LoginTest.checkStorageData(storage, [], [dummyuser1, dummyuser2]);
} catch (e) {
throw ("FAILED in test #" + testnum + " -- " + testdesc + ": " + e);
}