From f2847be93e1949c6c0b25eaccc966d0608cbcec6 Mon Sep 17 00:00:00 2001 From: Justin Dolske Date: Sun, 7 Sep 2008 00:12:34 -0700 Subject: [PATCH] Bug 399703 - Password manager offers to store logins with empty passwords. r=gavin --- .../passwordmgr/src/nsLoginManagerPrompter.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/toolkit/components/passwordmgr/src/nsLoginManagerPrompter.js b/toolkit/components/passwordmgr/src/nsLoginManagerPrompter.js index 4361e8cfd78..bf151103bc5 100644 --- a/toolkit/components/passwordmgr/src/nsLoginManagerPrompter.js +++ b/toolkit/components/passwordmgr/src/nsLoginManagerPrompter.js @@ -268,6 +268,11 @@ LoginManagerPrompter.prototype = { if (!ok || !checkBox.value || !hostname) return ok; + if (!aPassword.value) { + this.log("No password entered, so won't offer to save."); + return ok; + } + var newLogin = Cc["@mozilla.org/login-manager/loginInfo;1"]. createInstance(Ci.nsILoginInfo); newLogin.init(hostname, null, realm, aUsername.value, aPassword.value, @@ -350,7 +355,7 @@ LoginManagerPrompter.prototype = { aText, aPassword, checkBoxLabel, checkBox); - if (ok && checkBox.value && hostname) { + if (ok && checkBox.value && hostname && aPassword.value) { var newLogin = Cc["@mozilla.org/login-manager/loginInfo;1"]. createInstance(Ci.nsILoginInfo); newLogin.init(hostname, null, realm, username, @@ -468,6 +473,11 @@ LoginManagerPrompter.prototype = { try { var [username, password] = this._GetAuthInfo(aAuthInfo); + if (!password) { + this.log("No password entered, so won't offer to save."); + return ok; + } + var newLogin = Cc["@mozilla.org/login-manager/loginInfo;1"]. createInstance(Ci.nsILoginInfo); newLogin.init(hostname, null, httpRealm,