Bug 500822 - Importing passwords to mozstorage can fail when signons3.txt is corrupted, r=dolske

This commit is contained in:
Paul O’Shannessy 2009-07-13 13:35:55 -07:00
parent 780f91a63f
commit d9997307e2
3 changed files with 68 additions and 2 deletions

View File

@ -1015,8 +1015,13 @@ LoginManagerStorage_mozStorage.prototype = {
// Wrap in a transaction for better performance.
this._dbConnection.beginTransaction();
for each (let login in logins)
this._addLogin(login, true);
for each (let login in logins) {
try {
this._addLogin(login, true);
} catch (e) {
this.log("_importLegacySignons failed to add login: " + e);
}
}
let disabledHosts = legacy.getAllDisabledHosts({});
for each (let hostname in disabledHosts)
this.setLoginSavingEnabled(hostname, false);

View File

@ -0,0 +1,33 @@
#2e
.
http://dummyhost.mozilla.org
put_user_here
MDoEEPgAAAAAAAAAAAAAAAAAAAEwFAYIKoZIhvcNAwcECEnlbhAkNBbBBBCexD5eaffSLGH/ORiFlQ4X
*put_pw_here
MDoEEPgAAAAAAAAAAAAAAAAAAAEwFAYIKoZIhvcNAwcECHmiTaseYjkkBBAA0ILJTFSa5CnlpD5PTEYR
.
http://dummyhost2.mozilla.org
put_user_here2
*MDoEEPgAAAAAAAAAAAAAAAAAAAEwFAYIKoZIhvcNAwcECEnlbhAkNBbBBBCexD5eaffSLGH/ORiFlQ4X
*put_pw_here2
MDoEEPgAAAAAAAAAAAAAAAAAAAEwFAYIKoZIhvcNAwcECHmiTaseYjkkBBAA0ILJTFSa5CnlpD5PTEYR
---
put_user_here3
MDoEEPgAAAAAAAAAAAAAAAAAAAEwFAYIKoZIhvcNAwcECEnlbhAkNBbBBBCexD5eaffSLGH/ORiFlQ4X
*put_pw_here3
MDoEEPgAAAAAAAAAAAAAAAAAAAEwFAYIKoZIhvcNAwcECHmiTaseYjkkBBAA0ILJTFSa5CnlpD5PTEYR
put_user_here
MDoEEPgAAAAAAAAAAAAAAAAAAAEwFAYIKoZIhvcNAwcECEnlbhAkNBbBBBCexD5eaffSLGH/ORiFlQ4X
*put_pw_here4
*MDoEEPgAAAAAAAAAAAAAAAAAAAEwFAYIKoZIhvcNAwcECHmiTaseYjkkBBAA0ILJTFSa5CnlpD5PTEYR
MDoEEPgAAAAAAAAAAAAAAAAAAAEwFAYIKoZIhvcNAwcECHmiTaseYjkkBBAA0ILJTFSa5CnlpD5PTEYR
.
http://dummyhost4.mozilla.org
MDoEEPgAAAAAAAAAAAAAAAAAAAEwFAYIKoZIhvcNAwcECEnlbhAkNBbBBBCexD5eaffSLGH/ORiFlQ4X
*password
MDoEEPgAAAAAAAAAAAAAAAAAAAEwFAYIKoZIhvcNAwcECHmiTaseYjkkBBAA0ILJTFSa5CnlpD5PTEYR
.

View File

@ -266,6 +266,34 @@ LoginTest.checkStorageData(storage, [], [testuser1]);
LoginTest.deleteFile(OUTDIR, "signons-427033-1.sqlite");
/*
* ---------------------- Bug 500822 ----------------------
* Importing passwords to mozstorage can fail when signons3.txt is corrupted.
*/
/* ========== 13 ========== */
testnum++;
testdesc = "checking import of partially corrupted signons3.txt"
testuser1.init("http://dummyhost.mozilla.org", "", null,
"dummydude", "itsasecret", "put_user_here", "put_pw_here");
storage = LoginTest.initStorage(INDIR, "signons-500822-1.txt",
OUTDIR, "signons-500822-1.sqlite");
// Using searchLogins to check that we have the correct first entry. Tests for
// searchLogin are in test_storage_mozStorage_7.js. Other entries may be
// corrupted, but we need to check for one valid login.
let matchData = Cc["@mozilla.org/hash-property-bag;1"].createInstance(Ci.nsIWritablePropertyBag2);
matchData.setPropertyAsAString("hostname", "http://dummyhost.mozilla.org");
matchData.setPropertyAsAString("usernameField", "put_user_here");
logins = storage.searchLogins({}, matchData);
do_check_eq(1, logins.length, "should match 1 login");
LoginTest.deleteFile(OUTDIR, "signons-500822-1.sqlite");
} catch (e) {
throw "FAILED in test #" + testnum + " -- " + testdesc + ": " + e;
}