Fix for bug 201850, autocomplete fun - null check to avoid random autocomplete crashing, and support autocomplete="off" on web page text fields so as to avoid autocompleting sensitive fields such as credit card numbers

This commit is contained in:
ben%netscape.com 2003-04-22 10:27:30 +00:00
Родитель b888a0ba49
Коммит f3323a41a1
2 изменённых файлов: 17 добавлений и 3 удалений

Просмотреть файл

@ -678,9 +678,13 @@ nsAutoCompleteController::StartSearch()
}
nsAutoString searchParam;
mInput->GetSearchParam(searchParam);
// XXXben - can yank this when we discover what's causing this to
// fail & crash.
nsresult rv = mInput->GetSearchParam(searchParam);
if (NS_FAILED(rv))
return rv;
nsresult rv = search->StartSearch(mSearchString, searchParam, result, NS_STATIC_CAST(nsIAutoCompleteObserver *, this));
rv = search->StartSearch(mSearchString, searchParam, result, NS_STATIC_CAST(nsIAutoCompleteObserver *, this));
if (NS_FAILED(rv)) {
++searchesFailed;
--mSearchesOngoing;

Просмотреть файл

@ -324,6 +324,11 @@ nsFormFillController::SetSearchParam(const nsAString &aSearchParam)
NS_IMETHODIMP
nsFormFillController::GetSearchParam(nsAString &aSearchParam)
{
if (!mFocusedInput) {
NS_WARNING("mFocusedInput is null for some reason! avoiding a crash. should find out why... - ben");
return NS_ERROR_FAILURE; // XXX why? fix me.
}
mFocusedInput->GetName(aSearchParam);
if (aSearchParam.IsEmpty())
mFocusedInput->GetId(aSearchParam);
@ -452,7 +457,12 @@ nsFormFillController::Focus(nsIDOMEvent* aEvent)
if (input) {
nsAutoString type;
input->GetType(type);
if (type.Equals(NS_LITERAL_STRING("text")))
nsAutoString autocomplete;
input->GetAttribute(NS_LITERAL_STRING("autocomplete"), autocomplete);
if (type.Equals(NS_LITERAL_STRING("text")) &&
!autocomplete.Equals(NS_LITERAL_STRING("off")))
StartControllingInput(input);
}