mirror of
https://github.com/bitwarden/browser.git
synced 2025-01-02 18:17:46 +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;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
const passwordFieldsForForm: AutofillField[] = [];
|
|
||||||
passwordFields.forEach((passField) => {
|
|
||||||
if (formKey === passField.form) {
|
|
||||||
passwordFieldsForForm.push(passField);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
passwordFields.forEach((passField) => {
|
passwordFields.forEach((passField) => {
|
||||||
pf = passField;
|
pf = passField;
|
||||||
passwords.push(pf);
|
passwords.push(pf);
|
||||||
@ -438,7 +431,7 @@ export default class AutofillService implements AutofillServiceInterface {
|
|||||||
|
|
||||||
if (!totp && !options.onlyVisibleFields) {
|
if (!totp && !options.onlyVisibleFields) {
|
||||||
// not able to find any viewable totp fields. maybe there are some "hidden" ones?
|
// 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) {
|
if (totp) {
|
||||||
@ -741,6 +734,15 @@ export default class AutofillService implements AutofillServiceInterface {
|
|||||||
let exp: string = null;
|
let exp: string = null;
|
||||||
for (let i = 0; i < CreditCardAutoFillConstants.MonthAbbr.length; i++) {
|
for (let i = 0; i < CreditCardAutoFillConstants.MonthAbbr.length; i++) {
|
||||||
if (
|
if (
|
||||||
|
this.fieldAttrsContain(
|
||||||
|
fillFields.exp,
|
||||||
|
CreditCardAutoFillConstants.MonthAbbr[i] +
|
||||||
|
"/" +
|
||||||
|
CreditCardAutoFillConstants.YearAbbrLong[i]
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
exp = fullMonth + "/" + fullYear;
|
||||||
|
} else if (
|
||||||
this.fieldAttrsContain(
|
this.fieldAttrsContain(
|
||||||
fillFields.exp,
|
fillFields.exp,
|
||||||
CreditCardAutoFillConstants.MonthAbbr[i] +
|
CreditCardAutoFillConstants.MonthAbbr[i] +
|
||||||
@ -753,12 +755,12 @@ export default class AutofillService implements AutofillServiceInterface {
|
|||||||
} else if (
|
} else if (
|
||||||
this.fieldAttrsContain(
|
this.fieldAttrsContain(
|
||||||
fillFields.exp,
|
fillFields.exp,
|
||||||
CreditCardAutoFillConstants.MonthAbbr[i] +
|
CreditCardAutoFillConstants.YearAbbrLong[i] +
|
||||||
"/" +
|
"/" +
|
||||||
CreditCardAutoFillConstants.YearAbbrLong[i]
|
CreditCardAutoFillConstants.MonthAbbr[i]
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
exp = fullMonth + "/" + fullYear;
|
exp = fullYear + "/" + fullMonth;
|
||||||
} else if (
|
} else if (
|
||||||
this.fieldAttrsContain(
|
this.fieldAttrsContain(
|
||||||
fillFields.exp,
|
fillFields.exp,
|
||||||
@ -772,12 +774,12 @@ export default class AutofillService implements AutofillServiceInterface {
|
|||||||
} else if (
|
} else if (
|
||||||
this.fieldAttrsContain(
|
this.fieldAttrsContain(
|
||||||
fillFields.exp,
|
fillFields.exp,
|
||||||
CreditCardAutoFillConstants.YearAbbrLong[i] +
|
CreditCardAutoFillConstants.MonthAbbr[i] +
|
||||||
"/" +
|
"-" +
|
||||||
CreditCardAutoFillConstants.MonthAbbr[i]
|
CreditCardAutoFillConstants.YearAbbrLong[i]
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
exp = fullYear + "/" + fullMonth;
|
exp = fullMonth + "-" + fullYear;
|
||||||
} else if (
|
} else if (
|
||||||
this.fieldAttrsContain(
|
this.fieldAttrsContain(
|
||||||
fillFields.exp,
|
fillFields.exp,
|
||||||
@ -791,12 +793,12 @@ export default class AutofillService implements AutofillServiceInterface {
|
|||||||
} else if (
|
} else if (
|
||||||
this.fieldAttrsContain(
|
this.fieldAttrsContain(
|
||||||
fillFields.exp,
|
fillFields.exp,
|
||||||
CreditCardAutoFillConstants.MonthAbbr[i] +
|
CreditCardAutoFillConstants.YearAbbrLong[i] +
|
||||||
"-" +
|
"-" +
|
||||||
CreditCardAutoFillConstants.YearAbbrLong[i]
|
CreditCardAutoFillConstants.MonthAbbr[i]
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
exp = fullMonth + "-" + fullYear;
|
exp = fullYear + "-" + fullMonth;
|
||||||
} else if (
|
} else if (
|
||||||
this.fieldAttrsContain(
|
this.fieldAttrsContain(
|
||||||
fillFields.exp,
|
fillFields.exp,
|
||||||
@ -810,12 +812,10 @@ export default class AutofillService implements AutofillServiceInterface {
|
|||||||
} else if (
|
} else if (
|
||||||
this.fieldAttrsContain(
|
this.fieldAttrsContain(
|
||||||
fillFields.exp,
|
fillFields.exp,
|
||||||
CreditCardAutoFillConstants.YearAbbrLong[i] +
|
CreditCardAutoFillConstants.YearAbbrLong[i] + CreditCardAutoFillConstants.MonthAbbr[i]
|
||||||
"-" +
|
|
||||||
CreditCardAutoFillConstants.MonthAbbr[i]
|
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
exp = fullYear + "-" + fullMonth;
|
exp = fullYear + fullMonth;
|
||||||
} else if (
|
} else if (
|
||||||
this.fieldAttrsContain(
|
this.fieldAttrsContain(
|
||||||
fillFields.exp,
|
fillFields.exp,
|
||||||
@ -827,10 +827,10 @@ export default class AutofillService implements AutofillServiceInterface {
|
|||||||
} else if (
|
} else if (
|
||||||
this.fieldAttrsContain(
|
this.fieldAttrsContain(
|
||||||
fillFields.exp,
|
fillFields.exp,
|
||||||
CreditCardAutoFillConstants.YearAbbrLong[i] + CreditCardAutoFillConstants.MonthAbbr[i]
|
CreditCardAutoFillConstants.MonthAbbr[i] + CreditCardAutoFillConstants.YearAbbrLong[i]
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
exp = fullYear + fullMonth;
|
exp = fullMonth + fullYear;
|
||||||
} else if (
|
} else if (
|
||||||
this.fieldAttrsContain(
|
this.fieldAttrsContain(
|
||||||
fillFields.exp,
|
fillFields.exp,
|
||||||
@ -839,13 +839,6 @@ export default class AutofillService implements AutofillServiceInterface {
|
|||||||
partYear != null
|
partYear != null
|
||||||
) {
|
) {
|
||||||
exp = fullMonth + partYear;
|
exp = fullMonth + partYear;
|
||||||
} else if (
|
|
||||||
this.fieldAttrsContain(
|
|
||||||
fillFields.exp,
|
|
||||||
CreditCardAutoFillConstants.MonthAbbr[i] + CreditCardAutoFillConstants.YearAbbrLong[i]
|
|
||||||
)
|
|
||||||
) {
|
|
||||||
exp = fullMonth + fullYear;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (exp != null) {
|
if (exp != null) {
|
||||||
@ -1340,7 +1333,8 @@ export default class AutofillService implements AutofillServiceInterface {
|
|||||||
(canBeReadOnly || !f.readonly) &&
|
(canBeReadOnly || !f.readonly) &&
|
||||||
(withoutForm || f.form === passwordField.form) &&
|
(withoutForm || f.form === passwordField.form) &&
|
||||||
(canBeHidden || f.viewable) &&
|
(canBeHidden || f.viewable) &&
|
||||||
(f.type === "text" || f.type === "number")
|
(f.type === "text" || f.type === "number") &&
|
||||||
|
AutofillService.fieldIsFuzzyMatch(f, AutoFillConstants.TotpFieldNames)
|
||||||
) {
|
) {
|
||||||
totpField = f;
|
totpField = f;
|
||||||
|
|
||||||
@ -1516,7 +1510,7 @@ export default class AutofillService implements AutofillServiceInterface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static hasValue(str: string): boolean {
|
static hasValue(str: string): boolean {
|
||||||
return str && str !== "";
|
return Boolean(str && str !== "");
|
||||||
}
|
}
|
||||||
|
|
||||||
static setFillScriptForFocus(
|
static setFillScriptForFocus(
|
||||||
|
Loading…
Reference in New Issue
Block a user