From 5ec48c287b880242d0ed1bdab5f749bad387c859 Mon Sep 17 00:00:00 2001 From: varjolintu Date: Sun, 15 Dec 2019 09:57:31 +0200 Subject: [PATCH 1/2] Ignore TOTP icons if the field is too small --- keepassxc-browser/content/totp-field.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/keepassxc-browser/content/totp-field.js b/keepassxc-browser/content/totp-field.js index 9b30714..5aa4006 100644 --- a/keepassxc-browser/content/totp-field.js +++ b/keepassxc-browser/content/totp-field.js @@ -1,5 +1,7 @@ 'use strict'; +const MINIMUM_SIZE = 60; + var kpxcTOTPIcons = {}; kpxcTOTPIcons.icons = []; @@ -25,7 +27,7 @@ class TOTPFieldIcon extends Icon { }; TOTPFieldIcon.prototype.initField = function(field) { - if (!field || field.getAttribute('kpxc-totp-field') === 'true') { + if (!field || field.getAttribute('kpxc-totp-field') === 'true' || field.offsetWidth < MINIMUM_SIZE) { return; } From 140357f6741e6a13cbbc889155ed1e45d69d4a86 Mon Sep 17 00:00:00 2001 From: varjolintu Date: Tue, 17 Dec 2019 09:35:53 +0200 Subject: [PATCH 2/2] Add length checks --- keepassxc-browser/content/totp-field.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/keepassxc-browser/content/totp-field.js b/keepassxc-browser/content/totp-field.js index 5aa4006..e537405 100644 --- a/keepassxc-browser/content/totp-field.js +++ b/keepassxc-browser/content/totp-field.js @@ -27,7 +27,11 @@ class TOTPFieldIcon extends Icon { }; TOTPFieldIcon.prototype.initField = function(field) { - if (!field || field.getAttribute('kpxc-totp-field') === 'true' || field.offsetWidth < MINIMUM_SIZE) { + if (!field + || field.getAttribute('kpxc-totp-field') === 'true' + || field.offsetWidth < MINIMUM_SIZE + || field.size < 2 + || (field.maxLength > 0 && field.maxLength < 4)) { return; }