mirror of
https://github.com/keepassxreboot/keepassxc-browser.git
synced 2026-03-11 08:54:43 +00:00
Prevent endless loops with Auto-Submit
This commit is contained in:
parent
54b8ac79a3
commit
9dec7606ed
3 changed files with 43 additions and 12 deletions
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue