Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1430)

Unified Diff: components/autofill/core/browser/address_field.cc

Issue 853523004: Autofill: Set requirements for number of recognized fields in an autofillable form (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix bug, adjust tests Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: components/autofill/core/browser/address_field.cc
diff --git a/components/autofill/core/browser/address_field.cc b/components/autofill/core/browser/address_field.cc
index 0791eb3c9daf45029ad4f08f51c8f09ee7df2ba5..dffba7d4ea6a5a2cf52c906ee53858702bf319a5 100644
--- a/components/autofill/core/browser/address_field.cc
+++ b/components/autofill/core/browser/address_field.cc
@@ -71,18 +71,18 @@ scoped_ptr<FormField> AddressField::Parse(AutofillScanner* scanner) {
}
}
- // If we have identified any address fields in this field then it should be
- // added to the list of fields.
- if (address_field->company_ ||
- address_field->address1_ ||
- address_field->address2_ ||
- address_field->address3_ ||
- address_field->street_address_ ||
- address_field->city_ ||
- address_field->state_ ||
- address_field->zip_ ||
- address_field->zip4_ ||
- address_field->country_) {
+ // If we have identified any non-street address fields in this field then it
+ // should be added to the list of fields. We skip over the case of just having
+ // the street address by itself, because it is way too easy to have a field
+ // with the word "address" in it getting parsed as a street address.
+ // See http://crbug.com/447332
+ bool has_valid_non_street_address_field = (address_field->company_ ||
Evan Stade 2015/01/15 04:11:37 nit: I think we should require at least three reco
Evan Stade 2015/01/15 04:12:23 also, as this code is written, wouldn't the bug st
+ address_field->city_ ||
+ address_field->state_ ||
+ address_field->zip_ ||
+ address_field->zip4_ ||
+ address_field->country_);
+ if (has_valid_non_street_address_field) {
// Don't slurp non-labeled fields at the end into the address.
if (has_trailing_non_labeled_fields)
scanner->RewindTo(begin_trailing_non_labeled_fields);
« no previous file with comments | « chrome/test/data/autofill/heuristics/output/bug_447332.out ('k') | components/autofill/core/browser/address_field_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698