Chromium Code Reviews| 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; |
| } |