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..d0b0e28e549ef87aec4462efc2802734a41b21fd 100644 |
| --- a/components/autofill/core/browser/credit_card_field.cc |
| +++ b/components/autofill/core/browser/credit_card_field.cc |
| @@ -362,6 +362,15 @@ 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 kMinimum4YearCcExpLength = strlen("2014-12"); |
|
Evan Stade
2015/04/01 23:08:27
I guess it's a nit but why is this 2014-12 instead
Lei Zhang
2015/04/02 00:30:13
Done.
|
| + 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 +380,15 @@ bool CreditCardField::ParseExpirationDate(AutofillScanner* scanner) { |
| return true; |
| } |
| + |
| if (ParseFieldSpecifics(scanner, |
| base::UTF8ToUTF16(kExpirationDateRe), |
| kMatchTelAndSelect, |
| &expiration_date_)) { |
| + if (current_field_max_length > 0 && |
|
Evan Stade
2015/04/01 23:08:26
for consistency with the 2digit year case, shouldn
Lei Zhang
2015/04/02 00:30:13
|kExpirationDateRe| isn't only for 4 digit years.
|
| + current_field_max_length < kMinimum4YearCcExpLength) { |
| + exp_year_type_ = CREDIT_CARD_EXP_DATE_2_DIGIT_YEAR; |
| + } |
| expiration_month_ = nullptr; |
| return true; |
| } |