From 5eac65ec85a35a3ebe098409b6de3341a6dcd84b Mon Sep 17 00:00:00 2001 From: varjolintu Date: Fri, 22 Jan 2021 15:57:24 +0200 Subject: [PATCH 1/2] Ignore buttons with different formaction --- keepassxc-browser/content/keepassxc-browser.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/keepassxc-browser/content/keepassxc-browser.js b/keepassxc-browser/content/keepassxc-browser.js index d02754b..7125fa9 100755 --- a/keepassxc-browser/content/keepassxc-browser.js +++ b/keepassxc-browser/content/keepassxc-browser.js @@ -189,8 +189,9 @@ kpxcForm.getFormSubmitButton = function(form) { } // Try to find another button. Select the last one. - // TODO: Possibly change this behavior to select the last one for only certain sites. - const buttons = Array.from(form.querySelectorAll(kpxcForm.formButtonQuery)); + // If any formaction overriding the default action is set, ignore those buttons. + const buttons = Array.from(form.querySelectorAll(kpxcForm.formButtonQuery)) + .filter(b => b.formAction === document.location.href); if (buttons.length > 0) { return buttons[buttons.length - 1]; } From 2fb17f7b19429f7d88d42b6c3f323daf4d30b237 Mon Sep 17 00:00:00 2001 From: varjolintu Date: Fri, 29 Jan 2021 17:14:54 +0200 Subject: [PATCH 2/2] Switch from direct access to getAttribute() --- keepassxc-browser/content/keepassxc-browser.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/keepassxc-browser/content/keepassxc-browser.js b/keepassxc-browser/content/keepassxc-browser.js index 7125fa9..798b9d1 100755 --- a/keepassxc-browser/content/keepassxc-browser.js +++ b/keepassxc-browser/content/keepassxc-browser.js @@ -190,8 +190,7 @@ kpxcForm.getFormSubmitButton = function(form) { // Try to find another button. Select the last one. // If any formaction overriding the default action is set, ignore those buttons. - const buttons = Array.from(form.querySelectorAll(kpxcForm.formButtonQuery)) - .filter(b => b.formAction === document.location.href); + const buttons = Array.from(form.querySelectorAll(kpxcForm.formButtonQuery)).filter(b => !b.getAttribute('formAction')); if (buttons.length > 0) { return buttons[buttons.length - 1]; }