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

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: add form structure browser test 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
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..07826a106d0cbc262b75207e700152a360854b96 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,
@@ -375,6 +383,11 @@ bool CreditCardField::ParseExpirationDate(AutofillScanner* 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;
}

Powered by Google App Engine
This is Rietveld 408576698