Index: chrome/browser/autofill/credit_card_field.cc |
diff --git a/chrome/browser/autofill/credit_card_field.cc b/chrome/browser/autofill/credit_card_field.cc |
index f8b4c5e210a81fae47c0ab965321bdccd0ff1c4b..af125cad19a0442ee7420604c0c094269ecfba36 100644 |
--- a/chrome/browser/autofill/credit_card_field.cc |
+++ b/chrome/browser/autofill/credit_card_field.cc |
@@ -115,35 +115,42 @@ CreditCardField* CreditCardField::Parse( |
&credit_card_field->number_)) |
continue; |
- // "Expiration date" is the most common label here, but some pages have |
- // "Expires", "exp. date" or "exp. month" and "exp. year". We also look for |
- // the field names ccmonth and ccyear, which appear on at least 4 of our |
- // test pages. |
- // |
- // -> On at least one page (The China Shop2.html) we find only the labels |
- // "month" and "year". So for now we match these words directly; we'll |
- // see if this turns out to be too general. |
- // |
- // Toolbar Bug 51451: indeed, simply matching "month" is too general for |
- // https://rps.fidelity.com/ftgw/rps/RtlCust/CreatePIN/Init. |
- // Instead, we match only words beginning with "month". |
- if (is_ecml) |
- pattern = GetEcmlPattern(kEcmlCardExpireMonth); |
- else |
- pattern = ASCIIToUTF16("expir|exp.*month|exp date|ccmonth"); |
- |
- if ((!credit_card_field->expiration_month_ || |
- credit_card_field->expiration_month_->IsEmpty()) && |
- ParseText(&q, pattern, &credit_card_field->expiration_month_)) { |
+ if ((*q) && LowerCaseEqualsASCII((*q)->form_control_type(), "month")) { |
dhollowa
2011/01/07 03:47:15
This is looking good.
However, I tried it against
honten.org
2011/01/07 04:05:59
I can't see your full example. Did you put your ex
|
+ credit_card_field->expiration_month_ = *q++; |
+ } else { |
+ // "Expiration date" is the most common label here, but some pages have |
+ // "Expires", "exp. date" or "exp. month" and "exp. year". We also look |
+ // for the field names ccmonth and ccyear, which appear on at least 4 of |
+ // our test pages. |
+ // |
+ // -> On at least one page (The China Shop2.html) we find only the labels |
+ // "month" and "year". So for now we match these words directly; we'll |
+ // see if this turns out to be too general. |
+ // |
+ // Toolbar Bug 51451: indeed, simply matching "month" is too general for |
+ // https://rps.fidelity.com/ftgw/rps/RtlCust/CreatePIN/Init. |
+ // Instead, we match only words beginning with "month". |
if (is_ecml) |
- pattern = GetEcmlPattern(kEcmlCardExpireYear); |
+ pattern = GetEcmlPattern(kEcmlCardExpireMonth); |
else |
- pattern = ASCIIToUTF16("|exp|^/|ccyear|year"); |
+ pattern = ASCIIToUTF16("expir|exp.*month|exp date|ccmonth"); |
- if (!ParseText(&q, pattern, &credit_card_field->expiration_year_)) |
- return NULL; |
+ if ((!credit_card_field->expiration_month_ || |
+ credit_card_field->expiration_month_->IsEmpty()) && |
+ ParseText(&q, pattern, &credit_card_field->expiration_month_)) { |
- continue; |
+ // If type="month", year is included into the expiration_month_. |
dhollowa
2011/01/07 03:47:15
This comment can be removed now.
|
+ // So we don't need another year input field. |
+ if (is_ecml) |
+ pattern = GetEcmlPattern(kEcmlCardExpireYear); |
+ else |
+ pattern = ASCIIToUTF16("|exp|^/|ccyear|year"); |
+ |
+ if (!ParseText(&q, pattern, &credit_card_field->expiration_year_)) { |
+ return NULL; |
+ } |
Ilya Sherman
2011/01/07 07:28:28
nit: This is a one-line if-stmt, so no need for br
|
+ continue; |
+ } |
} |
if (ParseText(&q, GetEcmlPattern(kEcmlCardExpireDay))) |
@@ -177,7 +184,10 @@ CreditCardField* CreditCardField::Parse( |
// the cvc and date were found independently they are returned. |
if ((credit_card_field->number_ || credit_card_field->verification_) && |
credit_card_field->expiration_month_ && |
- credit_card_field->expiration_year_) { |
+ (credit_card_field->expiration_year_ || |
+ (LowerCaseEqualsASCII( |
+ credit_card_field->expiration_month_->form_control_type(), |
+ "month")))) { |
*iter = q; |
return credit_card_field.release(); |
} |