mirror of
https://github.com/bitwarden/browser
synced 2025-12-16 00:03:56 +00:00
exclude input types from card and ident autofill
This commit is contained in:
@@ -33,6 +33,8 @@ const UsernameFieldNames: string[] = [
|
|||||||
// German
|
// German
|
||||||
'benutzername', 'benutzer name', 'email adresse', 'e-mail adresse', 'benutzerid', 'benutzer id'];
|
'benutzername', 'benutzer name', 'email adresse', 'e-mail adresse', 'benutzerid', 'benutzer id'];
|
||||||
|
|
||||||
|
const ExcludedAutofillTypes: string[] = ['radio', 'checkbox', 'hidden', 'file', 'button', 'image', 'reset', 'search'];
|
||||||
|
|
||||||
/* tslint:disable */
|
/* tslint:disable */
|
||||||
const IsoCountries: { [id: string]: string; } = {
|
const IsoCountries: { [id: string]: string; } = {
|
||||||
afghanistan: "AF", "aland islands": "AX", albania: "AL", algeria: "DZ", "american samoa": "AS", andorra: "AD",
|
afghanistan: "AF", "aland islands": "AX", albania: "AL", algeria: "DZ", "american samoa": "AS", andorra: "AD",
|
||||||
@@ -418,6 +420,10 @@ export default class AutofillService implements AutofillServiceInterface {
|
|||||||
const fillFields: { [id: string]: AutofillField; } = {};
|
const fillFields: { [id: string]: AutofillField; } = {};
|
||||||
|
|
||||||
pageDetails.fields.forEach((f: any) => {
|
pageDetails.fields.forEach((f: any) => {
|
||||||
|
if (this.isExcludedType(f.type, ExcludedAutofillTypes)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
CardAttributes.forEach((attr) => {
|
CardAttributes.forEach((attr) => {
|
||||||
if (!f.hasOwnProperty(attr) || !f[attr] || !f.viewable) {
|
if (!f.hasOwnProperty(attr) || !f[attr] || !f.viewable) {
|
||||||
return;
|
return;
|
||||||
@@ -561,6 +567,10 @@ export default class AutofillService implements AutofillServiceInterface {
|
|||||||
const fillFields: { [id: string]: AutofillField; } = {};
|
const fillFields: { [id: string]: AutofillField; } = {};
|
||||||
|
|
||||||
pageDetails.fields.forEach((f: any) => {
|
pageDetails.fields.forEach((f: any) => {
|
||||||
|
if (this.isExcludedType(f.type, ExcludedAutofillTypes)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
IdentityAttributes.forEach((attr) => {
|
IdentityAttributes.forEach((attr) => {
|
||||||
if (!f.hasOwnProperty(attr) || !f[attr] || !f.viewable) {
|
if (!f.hasOwnProperty(attr) || !f[attr] || !f.viewable) {
|
||||||
return;
|
return;
|
||||||
@@ -714,6 +724,10 @@ export default class AutofillService implements AutofillServiceInterface {
|
|||||||
return fillScript;
|
return fillScript;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private isExcludedType(type: string, excludedTypes: string[]) {
|
||||||
|
return excludedTypes.indexOf(type) > -1;
|
||||||
|
}
|
||||||
|
|
||||||
private isFieldMatch(value: string, options: string[], containsOptions?: string[]): boolean {
|
private isFieldMatch(value: string, options: string[], containsOptions?: string[]): boolean {
|
||||||
value = value.trim().toLowerCase().replace(/[^a-zA-Z0-9]+/g, '');
|
value = value.trim().toLowerCase().replace(/[^a-zA-Z0-9]+/g, '');
|
||||||
for (let i = 0; i < options.length; i++) {
|
for (let i = 0; i < options.length; i++) {
|
||||||
|
|||||||
Reference in New Issue
Block a user