From c2d5953d1080ef93ffc3a8a8e2b31263616778be Mon Sep 17 00:00:00 2001 From: "dolske%mozilla.com" Date: Thu, 17 Jan 2008 01:02:45 +0000 Subject: [PATCH] Bug 409915 - Logins stored by extensions could be converted to site logins by 2E upgrade. r=gavin, a=blocking-ff3+ git-svn-id: svn://10.0.0.236/trunk@243331 18797224-902f-48f8-a5cc-f745e15eee43 --- .../components/passwordmgr/src/storage-Legacy.js | 8 ++++++++ .../passwordmgr/test/unit/data/signons-2d-10.txt | 16 ++++++++++++++++ .../test/unit/test_storage_legacy_1.js | 14 ++++++++++++++ 3 files changed, 38 insertions(+) create mode 100644 mozilla/toolkit/components/passwordmgr/test/unit/data/signons-2d-10.txt diff --git a/mozilla/toolkit/components/passwordmgr/src/storage-Legacy.js b/mozilla/toolkit/components/passwordmgr/src/storage-Legacy.js index 72d0f80b3c4..6e7bd7fb7e3 100644 --- a/mozilla/toolkit/components/passwordmgr/src/storage-Legacy.js +++ b/mozilla/toolkit/components/passwordmgr/src/storage-Legacy.js @@ -582,6 +582,14 @@ LoginManagerStorage_legacy.prototype = { if (aLogin.hostname.indexOf("://") == -1) { var oldHost = aLogin.hostname; + // Check for a trailing port number, EG "site.com:80". If there's + // no port, it wasn't saved by the browser and is probably some + // arbitrary string picked by an extension. + if (!/:\d+$/.test(aLogin.hostname)) { + this.log("2E upgrade: no port, skipping " + aLogin.hostname); + return upgradedLogins; + } + // Parse out "host:port". try { // Small hack: Need a scheme for nsIURI, so just prepend http. diff --git a/mozilla/toolkit/components/passwordmgr/test/unit/data/signons-2d-10.txt b/mozilla/toolkit/components/passwordmgr/test/unit/data/signons-2d-10.txt new file mode 100644 index 00000000000..e37678de9e8 --- /dev/null +++ b/mozilla/toolkit/components/passwordmgr/test/unit/data/signons-2d-10.txt @@ -0,0 +1,16 @@ +#2d +. +eBay.companion.paypal.guard + +MDIEEPgAAAAAAAAAAAAAAAAAAAEwFAYIKoZIhvcNAwcECNePtPzgmj5LBAhTfGF4EdqA/A== +* +MDoEEPgAAAAAAAAAAAAAAAAAAAEwFAYIKoZIhvcNAwcECGqjM6mOKO/5BBCj4F1AP8q3uRv+nZBEo2UT + +. +eBay.companion.ebay.guard + +MDIEEPgAAAAAAAAAAAAAAAAAAAEwFAYIKoZIhvcNAwcECPt4wsEg6r7qBAiJSTMiFBk7dw== +* +MDoEEPgAAAAAAAAAAAAAAAAAAAEwFAYIKoZIhvcNAwcECNWeFfM4ZZ+ZBBD/lkgrrRXLM7kLfg4fPAn1 + +. diff --git a/mozilla/toolkit/components/passwordmgr/test/unit/test_storage_legacy_1.js b/mozilla/toolkit/components/passwordmgr/test/unit/test_storage_legacy_1.js index a2a9ad50746..36c2be8f18c 100644 --- a/mozilla/toolkit/components/passwordmgr/test/unit/test_storage_legacy_1.js +++ b/mozilla/toolkit/components/passwordmgr/test/unit/test_storage_legacy_1.js @@ -374,6 +374,20 @@ LoginTest.initStorage(storage, INDIR, "signons-2d-09.txt"); LoginTest.checkStorageData(storage, [], [testuser1, testuser2]); +/* ========== 20 ========== */ +testnum++; +testdesc = "Initialize with signons-2d-10.txt"; +// Extensions like the eBay Companion just use an arbitrary string for the +// hostname. We don't want to change the format of these logins. + +testuser1.init("eBay.companion.paypal.guard", "", null, + "p", "paypalpass", "", ""); +testuser2.init("eBay.companion.ebay.guard", "", null, + "p", "ebaypass", "", ""); +LoginTest.initStorage(storage, INDIR, "signons-2d-10.txt"); +LoginTest.checkStorageData(storage, [], [testuser1, testuser2]); + + } catch (e) { throw "FAILED in test #" + testnum + " -- " + testdesc + ": " + e; }