mirror of
https://github.com/bitwarden/browser.git
synced 2024-12-29 17:38:04 +01:00
allow csv field names as well
This commit is contained in:
parent
745b17fe95
commit
907247b3a7
@ -88,7 +88,7 @@ var IsoProvinces: { [id: string]: string; } = {
|
||||
|
||||
export default class AutofillService {
|
||||
constructor(public cipherService: CipherService, public tokenService: TokenService,
|
||||
public totpService: TotpService, public utilsService: UtilsService) {
|
||||
public totpService: TotpService, public utilsService: UtilsService) {
|
||||
}
|
||||
|
||||
getFormsWithPasswordFields(pageDetails: AutofillPageDetails): any[] {
|
||||
@ -288,8 +288,8 @@ export default class AutofillService {
|
||||
}
|
||||
|
||||
private generateLoginFillScript(fillScript: AutofillScript, pageDetails: any,
|
||||
filledFields: { [id: string]: AutofillField; },
|
||||
options: any): AutofillScript {
|
||||
filledFields: { [id: string]: AutofillField; },
|
||||
options: any): AutofillScript {
|
||||
if (!options.cipher.login) {
|
||||
return null;
|
||||
}
|
||||
@ -399,8 +399,8 @@ export default class AutofillService {
|
||||
}
|
||||
|
||||
private generateCardFillScript(fillScript: AutofillScript, pageDetails: any,
|
||||
filledFields: { [id: string]: AutofillField; },
|
||||
options: any): AutofillScript {
|
||||
filledFields: { [id: string]: AutofillField; },
|
||||
options: any): AutofillScript {
|
||||
if (!options.cipher.card) {
|
||||
return null;
|
||||
}
|
||||
@ -473,8 +473,8 @@ export default class AutofillService {
|
||||
}
|
||||
|
||||
private generateIdentityFillScript(fillScript: AutofillScript, pageDetails: any,
|
||||
filledFields: { [id: string]: AutofillField; },
|
||||
options: any): AutofillScript {
|
||||
filledFields: { [id: string]: AutofillField; },
|
||||
options: any): AutofillScript {
|
||||
if (!options.cipher.identity) {
|
||||
return null;
|
||||
}
|
||||
@ -657,8 +657,8 @@ export default class AutofillService {
|
||||
}
|
||||
|
||||
private makeScriptAction(fillScript: AutofillScript, cipherData: any, fillFields: any,
|
||||
filledFields: { [id: string]: AutofillField; }, dataProp: string,
|
||||
fieldProp?: string) {
|
||||
filledFields: { [id: string]: AutofillField; }, dataProp: string,
|
||||
fieldProp?: string) {
|
||||
fieldProp = fieldProp || dataProp;
|
||||
if (cipherData[dataProp] && cipherData[dataProp] !== '' && fillFields[fieldProp]) {
|
||||
filledFields[fillFields[fieldProp].opid] = fillFields[fieldProp];
|
||||
@ -679,7 +679,7 @@ export default class AutofillService {
|
||||
}
|
||||
|
||||
private findUsernameField(pageDetails: AutofillPageDetails, passwordField: AutofillField, canBeHidden: boolean,
|
||||
withoutForm: boolean) {
|
||||
withoutForm: boolean) {
|
||||
let usernameField: AutofillField = null;
|
||||
for (const f of pageDetails.fields) {
|
||||
if (f.elementNumber >= passwordField.elementNumber) {
|
||||
@ -725,15 +725,26 @@ export default class AutofillService {
|
||||
return false;
|
||||
}
|
||||
|
||||
fieldVal = fieldVal.replace(/(?:\r\n|\r|\n)/g, '');
|
||||
if (name.startsWith('regex:')) {
|
||||
fieldVal = fieldVal.trim().replace(/(?:\r\n|\r|\n)/g, '');
|
||||
if (name.startsWith('regex=')) {
|
||||
try {
|
||||
const regexParts = name.split(':', 2);
|
||||
const regexParts = name.split('=', 2);
|
||||
if (regexParts.length === 2) {
|
||||
const regex = new RegExp(regexParts[1], 'i');
|
||||
return regex.test(fieldVal);
|
||||
}
|
||||
} catch (e) { }
|
||||
} else if (name.startsWith('csv=')) {
|
||||
const csvParts = name.split('=', 2);
|
||||
if (csvParts.length === 2) {
|
||||
const csvVals = csvParts[1].split(',');
|
||||
for (const val of csvVals) {
|
||||
if (val != null && val.trim().toLowerCase() === fieldVal.toLowerCase()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return fieldVal.toLowerCase() === name;
|
||||
@ -773,7 +784,7 @@ export default class AutofillService {
|
||||
}
|
||||
|
||||
private setFillScriptForFocus(filledFields: { [id: string]: AutofillField; },
|
||||
fillScript: AutofillScript): AutofillScript {
|
||||
fillScript: AutofillScript): AutofillScript {
|
||||
let lastField: AutofillField = null;
|
||||
let lastPasswordField: AutofillField = null;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user