Bug 454708 - storage-Legacy can throw when calling ConvertToUnicode. r=gavin

This commit is contained in:
Justin Dolske 2008-09-24 09:12:23 -07:00
parent 88bcb5a900
commit d261d66277
3 changed files with 42 additions and 1 deletions

View File

@ -862,7 +862,11 @@ LoginManagerStorage_legacy.prototype = {
do {
var hasMore = lineStream.readLine(line);
try {
line.value = this._utfConverter.ConvertToUnicode(line.value);
} catch (e) {
this.log("Bad UTF8 conversion: " + line.value);
}
switch (parseState) {
// Check file header

View File

@ -0,0 +1,10 @@
#2e
.
https://FcK<63>.jp
put_user_here
MDoEEPgAAAAAAAAAAAAAAAAAAAEwFAYIKoZIhvcNAwcECEnlbhAkNBbBBBCexD5eaffSLGH/ORiFlQ4X
*put_pw_here
MDoEEPgAAAAAAAAAAAAAAAAAAAEwFAYIKoZIhvcNAwcECHmiTaseYjkkBBAA0ILJTFSa5CnlpD5PTEYR
https://FcK<63>.jp
---
.

View File

@ -586,6 +586,33 @@ storage = LoginTest.reloadStorage(OUTDIR, "output-451155.txt");
LoginTest.checkStorageData(storage, [utfHost], [utfUser1, utfUser2]);
/*
* ---------------------- Bug 454708 ----------------------
* Check that previous saved entries that are not valid UTF8
* are read without blowing up.
*/
/* ========== 16 ========== */
testnum++;
testdesc = "ensure bogus UTF8 strings don't cause failures."
var badHost = "https://FcK" + String.fromCharCode(0x8a) + ".jp";
var bad8User = Cc["@mozilla.org/login-manager/loginInfo;1"].
createInstance(Ci.nsILoginInfo);
bad8User.init(badHost, badHost, null,
"dummydude", "itsasecret", "put_user_here", "put_pw_here");
storage = LoginTest.initStorage(INDIR, "signons-454708.txt",
OUTDIR, "output-454708.txt");
LoginTest.checkStorageData(storage, [], [bad8User]);
// The output file should contain valid UTF8 now, but the resulting
// JS string value remains the same.
testdesc = "[flush and reload for verification]"
storage = LoginTest.reloadStorage(OUTDIR, "output-454708.txt");
LoginTest.checkStorageData(storage, [], [bad8User]);
/* ========== end ========== */
} catch (e) {
throw ("FAILED in test #" + testnum + " -- " + testdesc + ": " + e);