Commit 31885f53 authored by Vadym Doroshenko's avatar Vadym Doroshenko Committed by Commit Bot

Ignore password related predictions for non-password fields.

The server might make mistake and say that <input type=text is
password field. This CL teaches the new parser to ignore such
predictions.

Bug: 908869, 831123
Change-Id: Ib4cfa715e0746b828be3c2356e8ae5bc60717a69
Reviewed-on: https://chromium-review.googlesource.com/c/1354000
Commit-Queue: Vadym Doroshenko <dvadym@chromium.org>
Reviewed-by: default avatarVaclav Brozek <vabr@chromium.org>
Cr-Commit-Position: refs/heads/master@{#612134}
parent c0162c1b
......@@ -235,6 +235,8 @@ std::unique_ptr<SignificantFields> ParseUsingPredictions(
processed_field =
FindFieldWithUniqueRendererId(processed_fields, prediction.first);
if (processed_field) {
if (!processed_field->is_password)
return nullptr;
result->password = processed_field->field;
}
}
......@@ -254,6 +256,8 @@ std::unique_ptr<SignificantFields> ParseUsingPredictions(
processed_field =
FindFieldWithUniqueRendererId(processed_fields, prediction.first);
if (processed_field) {
if (!processed_field->is_password)
return nullptr;
result->new_password = processed_field->field;
}
}
......@@ -262,6 +266,8 @@ std::unique_ptr<SignificantFields> ParseUsingPredictions(
processed_field =
FindFieldWithUniqueRendererId(processed_fields, prediction.first);
if (processed_field) {
if (!processed_field->is_password)
return nullptr;
result->confirmation_password = processed_field->field;
}
break;
......
......@@ -1045,6 +1045,17 @@ TEST(FormParserTest, ServerHints) {
},
.number_of_all_possible_passwords = 4,
},
{
"password prediction for a non-password field is ignored",
{
{.role = ElementRole::USERNAME,
.prediction = {.type = autofill::PASSWORD},
.form_control_type = "text"},
{.role = ElementRole::CURRENT_PASSWORD,
.form_control_type = "password"},
},
},
});
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment