[PM-41295] feat: Detect and fill extended address for identity autofill - #7371
Conversation
🤖 Bitwarden Claude Code ReviewOverall Assessment: REQUEST CHANGES Reviewed the addition of an The heuristic path has a detection problem rooted in Code Review Details
|
| val SUPPORTED_EXACT_ADDRESS_STREET_HINTS: List<String> = listOf( | ||
| "address", | ||
| ) |
There was a problem hiding this comment.
address2 normalizes to address, so line-2 fields exact-match as street.
Details and fix
equalsAnyTerms compares the output of toLowerCaseAndStripNonAlpha(), which strips digits (replace(Regex("[^a-z]"), "")). An attribute value of address2 / address_2, or a label of Address 2, therefore normalizes to exactly address and matches this term.
Trace, for <input name="address2"> on a form with no autocomplete attribute — the case this exact term was added for:
hints()returns["address2", ...](nameis inSUPPORTED_HTML_ATTRIBUTE_HINTS).HtmlInfo.isAddressStreetField()→equalsAnyTerms(["address"])→true.supportedAutofillHintevaluatesisAddressStreetField(ViewNodeExtensions.kt:191) beforeisAddressExtendedField(line 195), so the field resolves toADDRESS_STREET.FilledDataBuilderImpl.kt:287fills the apartment/suite field withaddress1.
Before this change that field matched nothing and was left alone, so this turns a miss into a wrong value.
Exact-matching against a digit-preserving normalization (lowercase + strip non-alphanumeric) would keep address working while leaving address2 unmatched.
| this.isAddressLocalityField -> AutofillHint.Identity.ADDRESS_LOCALITY | ||
| this.isAddressRegionField -> AutofillHint.Identity.ADDRESS_REGION | ||
| this.isAddressCountryField -> AutofillHint.Identity.ADDRESS_COUNTRY | ||
| this.isAddressExtendedField -> AutofillHint.Identity.ADDRESS_EXTENDED |
There was a problem hiding this comment.
addressLine2 is claimed by the street heuristic, so this branch never sees it.
Details and fix
SUPPORTED_RAW_ADDRESS_STREET_HINTS contains addressline, and digit stripping collapses addressLine2 / address_line_2 / addressLine1 all to addressline. Since isAddressStreetField is evaluated at line 191, before this branch, an id/hint/HTML name of addressLine2 resolves to ADDRESS_STREET and gets filled with address1.
SUPPORTED_RAW_ADDRESS_EXTENDED_HINTS only holds addressext, so addressLine2 and address2 — the two most common line-2 field names on real forms — never reach AddressExtended by heuristic at all. The address-line2 OS hint path does work; only the heuristic path in the PR objective is affected.
The fix needs both halves:
- Match extended terms against a normalization that preserves digits, so
addressline2is distinguishable fromaddressline1(see the related comment onSUPPORTED_EXACT_ADDRESS_STREET_HINTS). - Move
this.isAddressExtendedFieldabovethis.isAddressStreetFieldso the more specific term wins when both could match.
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## PM-41294/identity-autofill-multi-partition-pipeline #7371 +/- ##
======================================================================================
Coverage ? 85.77%
======================================================================================
Files ? 1056
Lines ? 69259
Branches ? 10330
======================================================================================
Hits ? 59409
Misses ? 6225
Partials ? 3625
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
🎟️ Tracking
https://bitwarden.atlassian.net/browse/PM-41295
📔 Objective
Adds heuristic detection and fill support for a second/extended address line (e.g. apartment,
suite, unit) in identity autofill.
AddressExtendedvia id/hint/HTML attribute heuristics or the OSaddress-line2autofill hint.AddressExtendedto the vault Identity'saddress2when filling.📸 Screenshots
N/A — no UI changes.