Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/keepassxreboot/keepassxc-browser.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSami Vänttinen <sami.vanttinen@protonmail.com>2022-06-04 13:48:25 +0300
committerGitHub <noreply@github.com>2022-06-04 13:48:25 +0300
commit92dfd04943c2769302b24eb815966a1b785e76d2 (patch)
tree89a469692b71b13877582f5eeb3ec9d663be92d2
parent54b8ac79a3ac8a02537d57b195d26d923c48bbc2 (diff)
parent9dec7606edee9bb34800b7a0d1beac9741c0d0aa (diff)
Merge pull request #1637 from keepassxreboot/feature/limit_auto_submit
Prevent endless loops with Auto-Submit
-rwxr-xr-xkeepassxc-browser/background/event.js2
-rwxr-xr-xkeepassxc-browser/background/page.js18
-rw-r--r--keepassxc-browser/content/fill.js35
3 files changed, 43 insertions, 12 deletions
diff --git a/keepassxc-browser/background/event.js b/keepassxc-browser/background/event.js
index c196b28..6201429 100755
--- a/keepassxc-browser/background/event.js
+++ b/keepassxc-browser/background/event.js
@@ -246,10 +246,12 @@ kpxcEvent.messageHandlers = {
'lock_database': kpxcEvent.lockDatabase,
'page_clear_logins': kpxcEvent.pageClearLogins,
'page_clear_submitted': page.clearSubmittedCredentials,
+ 'page_get_autosubmit_performed': page.getAutoSubmitPerformed,
'page_get_login_id': page.getLoginId,
'page_get_manual_fill': page.getManualFill,
'page_get_redirect_count': kpxcEvent.pageGetRedirectCount,
'page_get_submitted': page.getSubmitted,
+ 'page_set_autosubmit_performed': page.setAutoSubmitPerformed,
'page_set_login_id': page.setLoginId,
'page_set_manual_fill': page.setManualFill,
'page_set_submitted': page.setSubmitted,
diff --git a/keepassxc-browser/background/page.js b/keepassxc-browser/background/page.js
index 3196453..461671f 100755
--- a/keepassxc-browser/background/page.js
+++ b/keepassxc-browser/background/page.js
@@ -29,7 +29,10 @@ const defaultSettings = {
usePasswordGeneratorIcons: false
};
+const AUTO_SUBMIT_TIMEOUT = 5000;
+
var page = {};
+page.autoSubmitPerformed = false;
page.attributeMenuItemIds = [];
page.blockedTabs = [];
page.clearCredentialsTimeout = null;
@@ -343,6 +346,21 @@ page.setSubmitted = async function(tab, args = []) {
page.setSubmittedCredentials(submitted, username, password, url, oldCredentials, tab.id);
};
+page.getAutoSubmitPerformed = async function(tab) {
+ return page.autoSubmitPerformed;
+};
+
+// Set autoSubmitPerformed to false after 5 seconds, preventing possible endless loops
+page.setAutoSubmitPerformed = async function(tab) {
+ if (!page.autoSubmitPerformed) {
+ page.autoSubmitPerformed = true;
+
+ setTimeout(() => {
+ page.autoSubmitPerformed = false;
+ }, AUTO_SUBMIT_TIMEOUT);
+ }
+};
+
// Update context menu for attribute filling
page.updateContextMenu = async function(tab, credentials) {
// Remove any old attribute items
diff --git a/keepassxc-browser/content/fill.js b/keepassxc-browser/content/fill.js
index 4df4b50..198f80c 100644
--- a/keepassxc-browser/content/fill.js
+++ b/keepassxc-browser/content/fill.js
@@ -278,18 +278,7 @@ kpxcFill.fillInCredentials = async function(combination, predefinedUsername, uui
// Reset ManualFill
await sendMessage('page_set_manual_fill', ManualFill.NONE);
- // Auto-submit
- const autoSubmitIgnoredForSite = await kpxc.siteIgnored(IGNORE_AUTOSUBMIT);
- if (kpxc.settings.autoSubmit && !skipAutoSubmit && !autoSubmitIgnoredForSite) {
- const submitButton = kpxcForm.getFormSubmitButton(combination.form);
- if (submitButton !== undefined) {
- submitButton.click();
- } else if (combination.form) {
- combination.form.submit();
- }
- } else {
- (combination.username || combination.password).focus();
- }
+ await kpxcFill.performAutoSubmit(combination, skipAutoSubmit);
};
// Fills StringFields defined in Custom Fields
@@ -307,3 +296,25 @@ kpxcFill.fillInStringFields = function(fields, stringFields) {
}
}
};
+
+// Performs Auto-Submit. If filling single credentials is enabled, a 5 second timeout will be needed for fill
+kpxcFill.performAutoSubmit = async function(combination, skipAutoSubmit) {
+ const isAutoSubmitPerformed = await sendMessage('page_get_autosubmit_performed');
+ if (isAutoSubmitPerformed && kpxc.settings.autoFillSingleEntry) {
+ return;
+ }
+
+ const autoSubmitIgnoredForSite = await kpxc.siteIgnored(IGNORE_AUTOSUBMIT);
+ if (kpxc.settings.autoSubmit && !skipAutoSubmit && !autoSubmitIgnoredForSite) {
+ await sendMessage('page_set_autosubmit_performed');
+
+ const submitButton = kpxcForm.getFormSubmitButton(combination.form);
+ if (submitButton !== undefined) {
+ submitButton.click();
+ } else if (combination.form) {
+ combination.form.submit();
+ }
+ } else {
+ (combination.username || combination.password).focus();
+ }
+}