Merge pull request #1937 from keepassxreboot/fix/prevent_background_credential_request

Prevent retrieving credentials from background tabs
This commit is contained in:
Sami Vänttinen 2023-07-12 08:06:05 +03:00 committed by GitHub
commit bfd6988240
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -196,17 +196,25 @@ page.createTabEntry = function(tabId) {
// Page reload or tab switch clears the cache.
// If the retrieval is forced (from Credential Banner), get new credentials normally.
page.retrieveCredentials = async function(tab, args = []) {
if (!tab?.active) {
return [];
}
const [ url, submitUrl, force ] = args;
if (page.tabs[tab.id]?.credentials.length > 0 && !force) {
return page.tabs[tab.id].credentials;
}
// Ignore duplicate requests
if (page.currentRequest.url === url && page.currentRequest.submitUrl === submitUrl && !force) {
// Ignore duplicate requests from the same tab
if (page.currentRequest.url === url
&& page.currentRequest.submitUrl === submitUrl
&& page.currentRequest.tabId === tab.id
&& !force) {
return [];
} else {
page.currentRequest.url = url;
page.currentRequest.submitUrl = submitUrl;
page.currentRequest.tabId = tab.id;
}
const credentials = await keepass.retrieveCredentials(tab, args);