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

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

Issue 1053473002: Autofill: Use field maxlength to improve credit card date matching. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: nit Created 5 years, 9 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
« no previous file with comments | « no previous file | components/autofill/core/browser/credit_card_field_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/autofill/core/browser/credit_card_field.cc
diff --git a/components/autofill/core/browser/credit_card_field.cc b/components/autofill/core/browser/credit_card_field.cc
index 0e8d25dbfa58483b0badab61796a48d2e6a59a9d..1d2a2607be7abcd8471e82928a635348bd734931 100644
--- a/components/autofill/core/browser/credit_card_field.cc
+++ b/components/autofill/core/browser/credit_card_field.cc
@@ -362,6 +362,14 @@ bool CreditCardField::ParseExpirationDate(AutofillScanner* scanner) {
// Look for a 2-digit year first.
// We allow <select> fields, because they're used e.g. on qvc.com.
scanner->RewindTo(month_year_saved_cursor);
+
+ static int kMinimum2YearCcExpLength = strlen("12/14");
+ int current_field_max_length = scanner->Cursor()->max_length;
+ if (current_field_max_length > 0 &&
+ current_field_max_length < kMinimum2YearCcExpLength) {
+ return false;
+ }
+
if (ParseFieldSpecifics(scanner,
base::UTF8ToUTF16(kExpirationDate2DigitYearRe),
kMatchTelAndSelect,
@@ -371,10 +379,16 @@ bool CreditCardField::ParseExpirationDate(AutofillScanner* scanner) {
return true;
}
+
Evan Stade 2015/04/02 00:42:52 remove \n
if (ParseFieldSpecifics(scanner,
base::UTF8ToUTF16(kExpirationDateRe),
kMatchTelAndSelect,
&expiration_date_)) {
+ static int kMinimum4YearCcExpLength = strlen("12/2014");
+ if (current_field_max_length > 0 &&
+ current_field_max_length < kMinimum4YearCcExpLength) {
+ exp_year_type_ = CREDIT_CARD_EXP_DATE_2_DIGIT_YEAR;
+ }
expiration_month_ = nullptr;
return true;
}
« no previous file with comments | « no previous file | components/autofill/core/browser/credit_card_field_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698