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

Side by Side 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 unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "components/autofill/core/browser/address_field.h" 5 #include "components/autofill/core/browser/address_field.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 begin_trailing_non_labeled_fields = cursor; 64 begin_trailing_non_labeled_fields = cursor;
65 } 65 }
66 66
67 continue; 67 continue;
68 } else { 68 } else {
69 // No field found. 69 // No field found.
70 break; 70 break;
71 } 71 }
72 } 72 }
73 73
74 // If we have identified any address fields in this field then it should be 74 // If we have identified any non-street address fields in this field then it
75 // added to the list of fields. 75 // should be added to the list of fields. We skip over the case of just having
76 if (address_field->company_ || 76 // the street address by itself, because it is way too easy to have a field
77 address_field->address1_ || 77 // with the word "address" in it getting parsed as a street address.
78 address_field->address2_ || 78 // See http://crbug.com/447332
79 address_field->address3_ || 79 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
80 address_field->street_address_ || 80 address_field->city_ ||
81 address_field->city_ || 81 address_field->state_ ||
82 address_field->state_ || 82 address_field->zip_ ||
83 address_field->zip_ || 83 address_field->zip4_ ||
84 address_field->zip4_ || 84 address_field->country_);
85 address_field->country_) { 85 if (has_valid_non_street_address_field) {
86 // Don't slurp non-labeled fields at the end into the address. 86 // Don't slurp non-labeled fields at the end into the address.
87 if (has_trailing_non_labeled_fields) 87 if (has_trailing_non_labeled_fields)
88 scanner->RewindTo(begin_trailing_non_labeled_fields); 88 scanner->RewindTo(begin_trailing_non_labeled_fields);
89 89
90 return address_field.Pass(); 90 return address_field.Pass();
91 } 91 }
92 92
93 scanner->RewindTo(saved_cursor); 93 scanner->RewindTo(saved_cursor);
94 return NULL; 94 return NULL;
95 } 95 }
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 if (state_) 247 if (state_)
248 return false; 248 return false;
249 249
250 return ParseFieldSpecifics(scanner, 250 return ParseFieldSpecifics(scanner,
251 UTF8ToUTF16(kStateRe), 251 UTF8ToUTF16(kStateRe),
252 MATCH_DEFAULT | MATCH_SELECT, 252 MATCH_DEFAULT | MATCH_SELECT,
253 &state_); 253 &state_);
254 } 254 }
255 255
256 } // namespace autofill 256 } // namespace autofill
OLDNEW
« 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