Merge pull request #2454 from keepassxreboot/fix/totp_allowed_inputtypes

Add extra check for TOTP field input type
This commit is contained in:
Sami Vänttinen 2025-02-08 17:14:53 +02:00 committed by GitHub
commit 688dee35e9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

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)))