mirror of
https://github.com/bitwarden/browser.git
synced 2024-12-30 17:47:44 +01:00
[PM-2787] Fix Autofill Regex Check to Correctly Handle Both two-digit and four-digit years (#5700)
This commit is contained in:
parent
61d5b2df9c
commit
d42e87fbc6
@ -409,13 +409,6 @@ export default class AutofillService implements AutofillServiceInterface {
|
||||
continue;
|
||||
}
|
||||
|
||||
const passwordFieldsForForm: AutofillField[] = [];
|
||||
passwordFields.forEach((passField) => {
|
||||
if (formKey === passField.form) {
|
||||
passwordFieldsForForm.push(passField);
|
||||
}
|
||||
});
|
||||
|
||||
passwordFields.forEach((passField) => {
|
||||
pf = passField;
|
||||
passwords.push(pf);
|
||||
@ -438,7 +431,7 @@ export default class AutofillService implements AutofillServiceInterface {
|
||||
|
||||
if (!totp && !options.onlyVisibleFields) {
|
||||
// not able to find any viewable totp fields. maybe there are some "hidden" ones?
|
||||
totp = this.findTotpField(pageDetails, pf, true, true, true);
|
||||
totp = this.findTotpField(pageDetails, pf, true, true, false);
|
||||
}
|
||||
|
||||
if (totp) {
|
||||
@ -741,6 +734,15 @@ export default class AutofillService implements AutofillServiceInterface {
|
||||
let exp: string = null;
|
||||
for (let i = 0; i < CreditCardAutoFillConstants.MonthAbbr.length; i++) {
|
||||
if (
|
||||
this.fieldAttrsContain(
|
||||
fillFields.exp,
|
||||
CreditCardAutoFillConstants.MonthAbbr[i] +
|
||||
"/" +
|
||||
CreditCardAutoFillConstants.YearAbbrLong[i]
|
||||
)
|
||||
) {
|
||||
exp = fullMonth + "/" + fullYear;
|
||||
} else if (
|
||||
this.fieldAttrsContain(
|
||||
fillFields.exp,
|
||||
CreditCardAutoFillConstants.MonthAbbr[i] +
|
||||
@ -753,12 +755,12 @@ export default class AutofillService implements AutofillServiceInterface {
|
||||
} else if (
|
||||
this.fieldAttrsContain(
|
||||
fillFields.exp,
|
||||
CreditCardAutoFillConstants.MonthAbbr[i] +
|
||||
CreditCardAutoFillConstants.YearAbbrLong[i] +
|
||||
"/" +
|
||||
CreditCardAutoFillConstants.YearAbbrLong[i]
|
||||
CreditCardAutoFillConstants.MonthAbbr[i]
|
||||
)
|
||||
) {
|
||||
exp = fullMonth + "/" + fullYear;
|
||||
exp = fullYear + "/" + fullMonth;
|
||||
} else if (
|
||||
this.fieldAttrsContain(
|
||||
fillFields.exp,
|
||||
@ -772,12 +774,12 @@ export default class AutofillService implements AutofillServiceInterface {
|
||||
} else if (
|
||||
this.fieldAttrsContain(
|
||||
fillFields.exp,
|
||||
CreditCardAutoFillConstants.YearAbbrLong[i] +
|
||||
"/" +
|
||||
CreditCardAutoFillConstants.MonthAbbr[i]
|
||||
CreditCardAutoFillConstants.MonthAbbr[i] +
|
||||
"-" +
|
||||
CreditCardAutoFillConstants.YearAbbrLong[i]
|
||||
)
|
||||
) {
|
||||
exp = fullYear + "/" + fullMonth;
|
||||
exp = fullMonth + "-" + fullYear;
|
||||
} else if (
|
||||
this.fieldAttrsContain(
|
||||
fillFields.exp,
|
||||
@ -791,12 +793,12 @@ export default class AutofillService implements AutofillServiceInterface {
|
||||
} else if (
|
||||
this.fieldAttrsContain(
|
||||
fillFields.exp,
|
||||
CreditCardAutoFillConstants.MonthAbbr[i] +
|
||||
CreditCardAutoFillConstants.YearAbbrLong[i] +
|
||||
"-" +
|
||||
CreditCardAutoFillConstants.YearAbbrLong[i]
|
||||
CreditCardAutoFillConstants.MonthAbbr[i]
|
||||
)
|
||||
) {
|
||||
exp = fullMonth + "-" + fullYear;
|
||||
exp = fullYear + "-" + fullMonth;
|
||||
} else if (
|
||||
this.fieldAttrsContain(
|
||||
fillFields.exp,
|
||||
@ -810,12 +812,10 @@ export default class AutofillService implements AutofillServiceInterface {
|
||||
} else if (
|
||||
this.fieldAttrsContain(
|
||||
fillFields.exp,
|
||||
CreditCardAutoFillConstants.YearAbbrLong[i] +
|
||||
"-" +
|
||||
CreditCardAutoFillConstants.MonthAbbr[i]
|
||||
CreditCardAutoFillConstants.YearAbbrLong[i] + CreditCardAutoFillConstants.MonthAbbr[i]
|
||||
)
|
||||
) {
|
||||
exp = fullYear + "-" + fullMonth;
|
||||
exp = fullYear + fullMonth;
|
||||
} else if (
|
||||
this.fieldAttrsContain(
|
||||
fillFields.exp,
|
||||
@ -827,10 +827,10 @@ export default class AutofillService implements AutofillServiceInterface {
|
||||
} else if (
|
||||
this.fieldAttrsContain(
|
||||
fillFields.exp,
|
||||
CreditCardAutoFillConstants.YearAbbrLong[i] + CreditCardAutoFillConstants.MonthAbbr[i]
|
||||
CreditCardAutoFillConstants.MonthAbbr[i] + CreditCardAutoFillConstants.YearAbbrLong[i]
|
||||
)
|
||||
) {
|
||||
exp = fullYear + fullMonth;
|
||||
exp = fullMonth + fullYear;
|
||||
} else if (
|
||||
this.fieldAttrsContain(
|
||||
fillFields.exp,
|
||||
@ -839,13 +839,6 @@ export default class AutofillService implements AutofillServiceInterface {
|
||||
partYear != null
|
||||
) {
|
||||
exp = fullMonth + partYear;
|
||||
} else if (
|
||||
this.fieldAttrsContain(
|
||||
fillFields.exp,
|
||||
CreditCardAutoFillConstants.MonthAbbr[i] + CreditCardAutoFillConstants.YearAbbrLong[i]
|
||||
)
|
||||
) {
|
||||
exp = fullMonth + fullYear;
|
||||
}
|
||||
|
||||
if (exp != null) {
|
||||
@ -1340,7 +1333,8 @@ export default class AutofillService implements AutofillServiceInterface {
|
||||
(canBeReadOnly || !f.readonly) &&
|
||||
(withoutForm || f.form === passwordField.form) &&
|
||||
(canBeHidden || f.viewable) &&
|
||||
(f.type === "text" || f.type === "number")
|
||||
(f.type === "text" || f.type === "number") &&
|
||||
AutofillService.fieldIsFuzzyMatch(f, AutoFillConstants.TotpFieldNames)
|
||||
) {
|
||||
totpField = f;
|
||||
|
||||
@ -1516,7 +1510,7 @@ export default class AutofillService implements AutofillServiceInterface {
|
||||
}
|
||||
|
||||
static hasValue(str: string): boolean {
|
||||
return str && str !== "";
|
||||
return Boolean(str && str !== "");
|
||||
}
|
||||
|
||||
static setFillScriptForFocus(
|
||||
|
Loading…
Reference in New Issue
Block a user