From e806529259fbeaeb5581f277970a7d30757b42a6 Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Thu, 22 Mar 2018 12:28:24 -0400 Subject: [PATCH] exclude input types from card and ident autofill --- src/services/autofill.service.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/services/autofill.service.ts b/src/services/autofill.service.ts index e44aa2c1596..7a242a5ffae 100644 --- a/src/services/autofill.service.ts +++ b/src/services/autofill.service.ts @@ -33,6 +33,8 @@ const UsernameFieldNames: string[] = [ // German 'benutzername', 'benutzer name', 'email adresse', 'e-mail adresse', 'benutzerid', 'benutzer id']; +const ExcludedAutofillTypes: string[] = ['radio', 'checkbox', 'hidden', 'file', 'button', 'image', 'reset', 'search']; + /* tslint:disable */ const IsoCountries: { [id: string]: string; } = { 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; } = {}; pageDetails.fields.forEach((f: any) => { + if (this.isExcludedType(f.type, ExcludedAutofillTypes)) { + return; + } + CardAttributes.forEach((attr) => { if (!f.hasOwnProperty(attr) || !f[attr] || !f.viewable) { return; @@ -561,6 +567,10 @@ export default class AutofillService implements AutofillServiceInterface { const fillFields: { [id: string]: AutofillField; } = {}; pageDetails.fields.forEach((f: any) => { + if (this.isExcludedType(f.type, ExcludedAutofillTypes)) { + return; + } + IdentityAttributes.forEach((attr) => { if (!f.hasOwnProperty(attr) || !f[attr] || !f.viewable) { return; @@ -714,6 +724,10 @@ export default class AutofillService implements AutofillServiceInterface { return fillScript; } + private isExcludedType(type: string, excludedTypes: string[]) { + return excludedTypes.indexOf(type) > -1; + } + private isFieldMatch(value: string, options: string[], containsOptions?: string[]): boolean { value = value.trim().toLowerCase().replace(/[^a-zA-Z0-9]+/g, ''); for (let i = 0; i < options.length; i++) {