#! /bin/sh /usr/share/dpatch/dpatch-run ## 15_passwdmgr.dpatch by Mike Hommey ## ## All lines beginning with `## DP:' are a description of the patch. ## DP: Allow password manager to work with sites that only have a password ## DP: field, no username. ## DP: bz#235336. Thanks Ian Jackson. @DPATCH@ === toolkit/components/passwordmgr/base/nsPasswordManager.cpp ================================================================== --- xulrunner/toolkit/components/passwordmgr/base/nsPasswordManager.cpp (revision 35) +++ xulrunner/toolkit/components/passwordmgr/base/nsPasswordManager.cpp (local) @@ -888,8 +888,10 @@ nsPasswordManager::OnStateChange(nsIWebP for (SignonDataEntry* e = hashEnt->head; e; e = e->next) { nsCOMPtr foundNode; - form->ResolveName(e->userField, getter_AddRefs(foundNode)); - temp = do_QueryInterface(foundNode); + if (!(e->userField).IsEmpty()) { + form->ResolveName(e->userField, getter_AddRefs(foundNode)); + temp = do_QueryInterface(foundNode); + } nsAutoString oldUserValue; @@ -900,16 +902,15 @@ nsPasswordManager::OnStateChange(nsIWebP temp->GetValue(oldUserValue); userField = temp; - } else { - continue; } if (!(e->passField).IsEmpty()) { form->ResolveName(e->passField, getter_AddRefs(foundNode)); temp = do_QueryInterface(foundNode); } - else { - // No password field name was supplied, try to locate one in the form. + else if (userField) { + // No password field name was supplied, try to locate one in the form, + // but only if we have a username field. nsCOMPtr fc(do_QueryInterface(foundNode)); PRInt32 index = -1; form->IndexOfControl(fc, &index); @@ -983,7 +984,7 @@ nsPasswordManager::OnStateChange(nsIWebP } } - if (firstMatch && !attachedToInput) { + if (firstMatch && userField && !attachedToInput) { // We've found more than one possible signon for this form. // Listen for blur and autocomplete events on the username field so @@ -1000,10 +1001,12 @@ nsPasswordManager::OnStateChange(nsIWebP if (firstMatch && !attachedToInput) { if (prefillForm) { nsAutoString buffer; - if (NS_FAILED(DecryptData(firstMatch->userValue, buffer))) - goto done; + if (userField) { + if (NS_FAILED(DecryptData(firstMatch->userValue, buffer))) + goto done; - userField->SetValue(buffer); + userField->SetValue(buffer); + } if (NS_FAILED(DecryptData(firstMatch->passValue, buffer))) goto done;