зеркало из https://github.com/mozilla/pjs.git
fixes bug 175495 "Password Manager reprompts whether or not to save
passwords it already has stored" r=morse sr=dveditz a=asa
This commit is contained in:
Родитель
b53482139a
Коммит
5eadcb8323
|
@ -1436,7 +1436,7 @@ si_PutReject(const char * passwordRealm, const nsString& userName, PRBool save)
|
|||
* This routine is called only if signon pref is enabled!!!
|
||||
*/
|
||||
PRIVATE void
|
||||
si_PutData(const char * passwordRealm, nsVoidArray * signonData, PRBool save) {
|
||||
si_PutData(const char *passwordRealm, nsVoidArray *signonData, PRBool save) {
|
||||
PRBool added_to_list = PR_FALSE;
|
||||
si_SignonURLStruct * url;
|
||||
si_SignonUserStruct * user;
|
||||
|
@ -1986,12 +1986,12 @@ si_ExtractRealm(nsIURI *uri, nsCString &realm)
|
|||
* we have no host to get the signon data from, so we must not attempt to
|
||||
* build a valid realm from the URI (bug 159484) */
|
||||
nsresult rv = uri->GetHostPort(hostPort);
|
||||
if (NS_FAILED(rv))
|
||||
if (NS_FAILED(rv) || hostPort.IsEmpty())
|
||||
return PR_FALSE;
|
||||
|
||||
nsCAutoString scheme;
|
||||
rv = uri->GetScheme(scheme);
|
||||
if (NS_FAILED(rv))
|
||||
if (NS_FAILED(rv) || scheme.IsEmpty())
|
||||
return PR_FALSE;
|
||||
|
||||
realm = scheme + NS_LITERAL_CSTRING("://") + hostPort;
|
||||
|
@ -2000,12 +2000,16 @@ si_ExtractRealm(nsIURI *uri, nsCString &realm)
|
|||
|
||||
/* Ask user if it is ok to save the signon data */
|
||||
PRIVATE PRBool
|
||||
si_OkToSave(const char *passwordRealm, const nsString& userName, nsIDOMWindowInternal* window) {
|
||||
si_OkToSave(const char *passwordRealm, const char *legacyRealm,
|
||||
const nsString& userName, nsIDOMWindowInternal* window) {
|
||||
|
||||
/* if url/user already exists, then it is safe to save it again */
|
||||
if (si_CheckForUser(passwordRealm, userName)) {
|
||||
return PR_TRUE;
|
||||
}
|
||||
if (legacyRealm && si_CheckForUser(legacyRealm, userName)) {
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
#ifdef WALLET_PASSWORDMANAGER_DEFAULT_IS_OFF
|
||||
if (!si_RememberSignons && !si_GetNotificationPref()) {
|
||||
|
@ -2024,6 +2028,9 @@ si_OkToSave(const char *passwordRealm, const nsString& userName, nsIDOMWindowInt
|
|||
if (si_CheckForReject(passwordRealm, userName)) {
|
||||
return PR_FALSE;
|
||||
}
|
||||
if (legacyRealm && si_CheckForReject(legacyRealm, userName)) {
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
PRUnichar * message;
|
||||
if (SI_GetBoolPref(pref_Crypto, PR_FALSE)) {
|
||||
|
@ -2045,8 +2052,8 @@ si_OkToSave(const char *passwordRealm, const nsString& userName, nsIDOMWindowInt
|
|||
*/
|
||||
PRIVATE void
|
||||
si_RememberSignonData
|
||||
(nsIPrompt* dialog, const char* passwordRealm, nsVoidArray * signonData,
|
||||
nsIDOMWindowInternal* window)
|
||||
(nsIPrompt* dialog, const char* passwordRealm, const char* legacyRealm,
|
||||
nsVoidArray * signonData, nsIDOMWindowInternal* window)
|
||||
{
|
||||
int passwordCount = 0;
|
||||
int pswd[3];
|
||||
|
@ -2087,7 +2094,11 @@ si_RememberSignonData
|
|||
if (j<signonData->Count()) {
|
||||
data2 = NS_STATIC_CAST(si_SignonDataStruct*, signonData->ElementAt(j));
|
||||
|
||||
if (si_OkToSave(passwordRealm, data2->value, window)) {
|
||||
if (si_OkToSave(passwordRealm, legacyRealm, data2->value, window)) {
|
||||
// remove legacy password entry if found
|
||||
if (legacyRealm && si_CheckForUser(legacyRealm, data2->value)) {
|
||||
si_RemoveUser(legacyRealm, data2->value, PR_TRUE, PR_FALSE, PR_TRUE);
|
||||
}
|
||||
Wallet_GiveCaveat(window, nsnull);
|
||||
for (j=0; j<signonData->Count(); j++) {
|
||||
data2 = NS_STATIC_CAST(si_SignonDataStruct*, signonData->ElementAt(j));
|
||||
|
@ -2166,12 +2177,15 @@ SINGSIGN_RememberSignonData
|
|||
if (!passwordRealm)
|
||||
return;
|
||||
|
||||
nsCAutoString realm;
|
||||
nsCAutoString realm, legacyRealm;
|
||||
if (!si_ExtractRealm(passwordRealm, realm))
|
||||
return;
|
||||
|
||||
if (NS_FAILED(passwordRealm->GetHost(legacyRealm)))
|
||||
return;
|
||||
|
||||
if (!realm.IsEmpty()) {
|
||||
si_RememberSignonData(dialog, realm.get(), signonData, window);
|
||||
si_RememberSignonData(dialog, realm.get(), legacyRealm.get(), signonData, window);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче