Bug 345400: Password manager can't handle case insensitive user field names imported from IE, patch by Michael Wu <michael.wu@mozilla.com>, r=enndeakin, a=beltzner

git-svn-id: svn://10.0.0.236/branches/MOZILLA_1_8_BRANCH@203668 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
gavin%gavinsharp.com
2006-07-25 20:47:08 +00:00
parent 4f153a1b09
commit 308d72e2da

View File

@@ -1793,6 +1793,32 @@ nsPasswordManager::FillDocument(nsIDOMDocument* aDomDoc)
temp->GetValue(oldUserValue);
userField = temp;
} else if ((e->passField).IsEmpty()) {
// Happens sometimes when we import passwords from IE since
// their form name match is case insensitive. In this case,
// we'll just have to do a case insensitive search for the
// userField and hope we get something.
PRUint32 count;
form->GetElementCount(&count);
PRUint32 i;
nsCOMPtr<nsIFormControl> formControl;
for (i = 0; i < count; i++) {
form->GetElementAt(i, getter_AddRefs(formControl));
if (formControl &&
formControl->GetType() == NS_FORM_INPUT_TEXT) {
nsCOMPtr<nsIDOMHTMLInputElement> inputField = do_QueryInterface(formControl);
nsAutoString name;
inputField->GetName(name);
if (name.EqualsIgnoreCase(NS_ConvertUTF16toUTF8(e->userField).get())) {
inputField->GetValue(oldUserValue);
userField = inputField;
foundNode = inputField;
e->userField.Assign(name);
break;
}
}
}
}
if (!(e->passField).IsEmpty()) {
@@ -1847,6 +1873,8 @@ nsPasswordManager::FillDocument(nsIDOMDocument* aDomDoc)
temp->GetValue(oldPassValue);
passField = temp;
if ((e->passField).IsEmpty())
passField->GetName(e->passField);
} else {
continue;
}