exclude input types from card and ident autofill

This commit is contained in:
Kyle Spearrin 2018-03-22 12:28:24 -04:00
parent 75d4ee3038
commit e806529259
1 changed files with 14 additions and 0 deletions

View File

@ -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++) {