From 93e5eeda6bc5268e5c4d3c42bd42f442d5ca171b Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Wed, 25 Sep 2019 09:54:01 -0400 Subject: [PATCH] dont autofill non-empty fields on page load --- jslib | 2 +- src/services/autofill.service.ts | 13 ++++++++----- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/jslib b/jslib index 6b82cd0380..971e19335f 160000 --- a/jslib +++ b/jslib @@ -1 +1 @@ -Subproject commit 6b82cd0380d33c83e8b242713eb173d94e16e9f4 +Subproject commit 971e19335f66ac64845b65a7bcf688811f60eaff diff --git a/src/services/autofill.service.ts b/src/services/autofill.service.ts index d1956443d5..ab76fda4a9 100644 --- a/src/services/autofill.service.ts +++ b/src/services/autofill.service.ts @@ -119,7 +119,7 @@ export default class AutofillService implements AutofillServiceInterface { getFormsWithPasswordFields(pageDetails: AutofillPageDetails): any[] { const formData: any[] = []; - const passwordFields = this.loadPasswordFields(pageDetails, true, true); + const passwordFields = this.loadPasswordFields(pageDetails, true, true, false); if (passwordFields.length === 0) { return formData; } @@ -165,6 +165,7 @@ export default class AutofillService implements AutofillServiceInterface { const fillScript = this.generateFillScript(pd.details, { skipUsernameOnlyFill: options.skipUsernameOnlyFill || false, + onlyEmptyFields: options.onlyEmptyFields || false, onlyVisibleFields: options.onlyVisibleFields || false, cipher: options.cipher, }); @@ -227,6 +228,7 @@ export default class AutofillService implements AutofillServiceInterface { skipTotp: !fromCommand, skipLastUsed: true, skipUsernameOnlyFill: !fromCommand, + onlyEmptyFields: !fromCommand, onlyVisibleFields: !fromCommand, }); } @@ -313,10 +315,10 @@ export default class AutofillService implements AutofillServiceInterface { return fillScript; } - let passwordFields = this.loadPasswordFields(pageDetails, false, false); + let passwordFields = this.loadPasswordFields(pageDetails, false, false, options.onlyEmptyFields); if (!passwordFields.length && !options.onlyVisibleFields) { // not able to find any viewable password fields. maybe there are some "hidden" ones? - passwordFields = this.loadPasswordFields(pageDetails, true, true); + passwordFields = this.loadPasswordFields(pageDetails, true, true, options.onlyEmptyFields); } for (const formKey in pageDetails.forms) { @@ -871,7 +873,8 @@ export default class AutofillService implements AutofillServiceInterface { } } - private loadPasswordFields(pageDetails: AutofillPageDetails, canBeHidden: boolean, canBeReadOnly: boolean) { + private loadPasswordFields(pageDetails: AutofillPageDetails, canBeHidden: boolean, canBeReadOnly: boolean, + mustBeEmpty: boolean) { const arr: AutofillField[] = []; pageDetails.fields.forEach((f) => { const isPassword = f.type === 'password'; @@ -904,7 +907,7 @@ export default class AutofillService implements AutofillServiceInterface { return false; }; if (!f.disabled && (canBeReadOnly || !f.readonly) && (isPassword || isLikePassword()) - && (canBeHidden || f.viewable)) { + && (canBeHidden || f.viewable) && (!mustBeEmpty || f.value == null || f.value.trim() === '')) { arr.push(f); } });