Add extra check for TOTP field input type

This commit is contained in:
varjolintu 2025-02-08 10:06:44 +02:00
parent 9d33016516
commit e7f4910e54

View file

@ -2,6 +2,7 @@
const ignoreRegex = /(bank|coupon|postal|user|zip).*code|(en|de)code(d|r)*|comment|author|error/i;
const ignoredTypes = [ 'email', 'password', 'username' ];
const allowedInputTypes = [ 'number', 'password', 'tel', 'text' ];
const acceptedOTPFields = [
'2fa',
@ -52,6 +53,12 @@ kpxcTOTPIcons.isAcceptedTOTPField = function(field) {
const id = field.getLowerCaseAttribute('id');
const name = field.getLowerCaseAttribute('name');
const placeholder = field.getLowerCaseAttribute('placeholder');
const type = field.getLowerCaseAttribute('type');
// Checks if input type is allowed
if (!allowedInputTypes.some(t => type === t)) {
return false;
}
// Checks if the field id, name or placeholder includes some of the acceptedOTPFields but not any from ignoredTypes
if ((acceptedOTPFields.some(f => id?.includes(f) || (name?.includes(f) || placeholder?.includes(f))) || acceptedParents.some(s => field.closest(s)))