only autofill viewable fields for card/identities

This commit is contained in:
Kyle Spearrin 2017-11-11 22:25:16 -05:00
parent c6274dd1dc
commit 202d008cb0
1 changed files with 18 additions and 16 deletions

View File

@ -9,9 +9,11 @@ import TokenService from './token.service';
import TotpService from './totp.service'; import TotpService from './totp.service';
import UtilsService from './utils.service'; import UtilsService from './utils.service';
const CardAttributes: string[] = ['autoCompleteType', 'data-stripe', 'htmlName', 'htmlID', 'label-tag']; const CardAttributes: string[] = ['autoCompleteType', 'data-stripe', 'htmlName', 'htmlID', 'label-tag',
'placeholder'];
const IdentityAttributes: string[] = ['autoCompleteType', 'data-stripe', 'htmlName', 'htmlID', 'label-tag']; const IdentityAttributes: string[] = ['autoCompleteType', 'data-stripe', 'htmlName', 'htmlID', 'label-tag',
'placeholder'];
const UsernameFieldNames: string[] = ['username', 'user name', 'email', 'email address', 'e-mail', 'e-mail address', const UsernameFieldNames: string[] = ['username', 'user name', 'email', 'email address', 'e-mail', 'e-mail address',
'userid', 'user id']; 'userid', 'user id'];
@ -407,7 +409,7 @@ export default class AutofillService {
for (const f of pageDetails.fields) { for (const f of pageDetails.fields) {
for (const attr of CardAttributes) { for (const attr of CardAttributes) {
if (!f.hasOwnProperty(attr) || !f[attr]) { if (!f.hasOwnProperty(attr) || !f[attr] || !f.viewable) {
continue; continue;
} }
@ -481,7 +483,7 @@ export default class AutofillService {
for (const f of pageDetails.fields) { for (const f of pageDetails.fields) {
for (const attr of IdentityAttributes) { for (const attr of IdentityAttributes) {
if (!f.hasOwnProperty(attr) || !f[attr]) { if (!f.hasOwnProperty(attr) || !f[attr] || !f.viewable) {
continue; continue;
} }
@ -642,7 +644,7 @@ export default class AutofillService {
} }
private isFieldMatch(value: string, options: string[], containsOptions?: string[]): boolean { private isFieldMatch(value: string, options: string[], containsOptions?: string[]): boolean {
value = value.trim().toLowerCase().replace(/-|_| /g, ''); value = value.trim().toLowerCase().replace(/[^a-zA-Z]+/g, '');
for (let option of options) { for (let option of options) {
const checkValueContains = containsOptions == null || containsOptions.indexOf(option) > -1; const checkValueContains = containsOptions == null || containsOptions.indexOf(option) > -1;
option = option.replace(/-/g, ''); option = option.replace(/-/g, '');