Open Bug 1410098 Opened 7 years ago Updated 2 years ago

Apply more regexps to detect the cc-exp* fields of <input> elements

Categories

(Toolkit :: Form Autofill, enhancement, P3)

57 Branch
enhancement

Tracking

()

People

(Reporter: jkt, Unassigned)

References

(Blocks 1 open bug, )

Details

(Whiteboard: [form autofill])

In Bug 1406771 form autofill was used to detect the format to populate, however it appears in some cases the date types are being detected wrong.

carphonewarehouse.com have fields like:

<input id="expiryDateMonth" class="form-control month" data-bind="label" placeholder="MM" readonly="readonly" value="01" data-di-id="#expiryDateMonth" type="text">

<input id="expiryDateYear" class="form-control year" data-bind="label" placeholder="YY" readonly="readonly" value="" data-di-id="#expiryDateYear" type="text">


expiryDateMonth is currently being populated with YYY-MM which is invalid, instead 

:seanlee said:
> cc-exp* are misdetected so the filling feature can not fill the correct value.
In addition, <input id="expirydate" name="expirydate" value="1215" type="hidden"> is before <input id="expiryDateMonth"> and <input id="expiryDateYear">.
Priority: -- → P3
Whiteboard: [form autofill]
Hey Ray,

Can you take a look this bug? Our parser recognized these two inputs as cc-exps instead of cc-exp-month and cc-exp-year:
<input id="expiryDateMonth" class="form-control month" data-bind="label" placeholder="MM" readonly="readonly" value="01" data-di-id="#expiryDateMonth" type="text">

<input id="expiryDateYear" class="form-control year" data-bind="label" placeholder="YY" readonly="readonly" value="" data-di-id="#expiryDateYear" type="text">

Then `_isExpirationMonthLikely` and `_isExpirationYearLikely` exclude any <input> fields, so we need to apply the regexps `"^mm$"`, `"^(yy|yyyy)$"`, etc (see [1] in detail) after the block of `_isExpirationMonthLikely` and `_isExpirationYearLikely`:

[1] https://cs.chromium.org/chromium/src/components/autofill/core/browser/credit_card_field.cc?rcl=517fa8e7a69d22c2fee11a61294f693c169565da&l=439-487
Flags: needinfo?(ralin)
Summary: Use placeholder text for detection of month/year fields → Apply more regexps to detect the cc-exp* fields of <input> elements
With current implementation it's not surprise to the outcome. Two things need to be confirmed before starting this.

1. By seeing the DOM structure of carphonewarehouse.com, there's a hidden input preceding visible cc-exp-month and cc-exp-year. If we don't have a reliable strategy to judge the visibility(hidden or intangible also matters), it's difficult to tell whether we should choose a standalone cc-exp or choose cc-exp-month, cc-exp-year pair. Since normally only either should be filled in heuristics.
2.  IIUC, Chromium tests the regex with field name and filed label only[0]. If so, in this case, matching the regex might not help unless we decide to let placeholder account for parsing as well. (not sure why Chromium doesn't do that, any concerns might bring worse prediction? I don't know). [1] had fixed the way we fill by testing its placeholder, and maybe it's worth cribbing from to parsing process.


I think before getting into point 2, we might need to address point 1 in order not to skip real valid fields. Otherwise, even we came out with a correct, will still being deduping eventually.  


[0] https://cs.chromium.org/chromium/src/components/autofill/core/browser/form_field.cc?l=153
[1] https://hg.mozilla.org/mozilla-central/rev/f8843cf82310
Flags: needinfo?(ralin)
updates after a quick discussion with Sean offline:

1. type=hidden is invalid field type, so I won't put it in parseable list, though I still wonder if any cases changing visibility via CSS instead of type="hidden".

2. I'll try the following approach first:
> so we need to apply the regexps `"^mm$"`, `"^(yy|yyyy)$"`,
> etc (see [1] in detail) after the block of `_isExpirationMonthLikely` and
> `_isExpirationYearLikely`
Assignee: nobody → ralin
Blocks: 1411990
Component: Form Manager → Form Autofill
Assignee: ralin → nobody
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.