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-05-31 15:39:32 +0300
committerGitHub <noreply@github.com>2022-05-31 15:39:32 +0300
commit54b8ac79a3ac8a02537d57b195d26d923c48bbc2 (patch)
treea234211defc982c862af74c34624476eec57284a
parent1a7975df9372b06797868fcf0349a9faf6a4bcc1 (diff)
Allow filling password for non-detected fields and combinations (#1580)
Allow filling password for non-detected fields and combinations
-rw-r--r--keepassxc-browser/content/fill.js70
-rwxr-xr-xkeepassxc-browser/content/keepassxc-browser.js12
2 files changed, 42 insertions, 40 deletions
diff --git a/keepassxc-browser/content/fill.js b/keepassxc-browser/content/fill.js
index 2ab54e5..4df4b50 100644
--- a/keepassxc-browser/content/fill.js
+++ b/keepassxc-browser/content/fill.js
@@ -23,60 +23,56 @@ kpxcFill.fillAttributeToActiveElementWith = async function(attr) {
// Fill requested from the context menu. Active element is used for combination detection
kpxcFill.fillInFromActiveElement = async function(passOnly = false) {
+ await kpxc.receiveCredentialsIfNecessary();
if (kpxc.credentials.length === 0) {
logDebug('Error: Credential list is empty.');
return;
}
if (kpxc.combinations.length > 0 && kpxc.settings.autoCompleteUsernames) {
- const combination = passOnly
- ? kpxc.combinations.find(c => c.password)
- : kpxc.combinations.find(c => c.username);
- if (!combination) {
- logDebug('Error: No combination found.');
+ if (await kpxcFill.fillFromCombination(passOnly)) {
+ // Combination found and filled
return;
}
+ }
- const field = passOnly ? combination.password : combination.username;
- if (!field) {
- logDebug('Error: No input field found.');
- return;
- }
+ // No previous combinations detected. Create a new one from active element
+ const el = document.activeElement;
+ const combination = await kpxc.createCombination(el, passOnly);
- // Set focus to the input field
- field.focus();
+ await sendMessage('page_set_login_id', kpxc.credentials[0].uuid);
+ kpxcFill.fillInCredentials(combination, kpxc.credentials[0].login, kpxc.credentials[0].uuid, passOnly);
+};
- if (kpxc.credentials.length > 1) {
- // More than one credential -> show autocomplete list
- kpxcUserAutocomplete.showList(field);
- return;
- } else {
- // Just one credential -> fill the first combination found
- await sendMessage('page_set_login_id', kpxc.credentials[0].uuid);
- kpxcFill.fillInCredentials(combination, kpxc.credentials[0].login, kpxc.credentials[0].uuid, passOnly);
- return;
- }
+// Fill from combination, if found
+kpxcFill.fillFromCombination = async function(passOnly) {
+ const combination = passOnly
+ ? kpxc.combinations.find(c => c.password)
+ : kpxc.combinations.find(c => c.username);
+ if (!combination) {
+ logDebug('Error: No combination found.');
+ return false;
}
- // No previous combinations detected. Create a new one from active element
- const el = document.activeElement;
- let combination;
- if (kpxc.combinations.length === 0) {
- combination = await kpxc.createCombination(el);
- } else {
- combination = el.type === 'password'
- ? await kpxcFields.getCombination(el, 'password')
- : await kpxcFields.getCombination(el, 'username');
+ const field = passOnly ? combination.password : combination.username;
+ if (!field) {
+ logDebug('Error: No input field found.');
+ return false;
}
- // Do not allow filling password to a non-password field
- if (passOnly && combination && !combination.password) {
- kpxcUI.createNotification('warning', tr('fieldsNoPasswordField'));
- return;
+ // Set focus to the input field
+ field.focus();
+
+ if (kpxc.credentials.length > 1) {
+ // More than one credential -> show autocomplete list
+ kpxcUserAutocomplete.showList(field);
+ } else {
+ // Just one credential -> fill the first combination found
+ await sendMessage('page_set_login_id', kpxc.credentials[0].uuid);
+ kpxcFill.fillInCredentials(combination, kpxc.credentials[0].login, kpxc.credentials[0].uuid, passOnly);
}
- await sendMessage('page_set_login_id', kpxc.credentials[0].uuid);
- kpxcFill.fillInCredentials(combination, kpxc.credentials[0].login, kpxc.credentials[0].uuid, passOnly);
+ return true;
};
// Fill requested by Auto-Fill
diff --git a/keepassxc-browser/content/keepassxc-browser.js b/keepassxc-browser/content/keepassxc-browser.js
index b93dd0a..876abd2 100755
--- a/keepassxc-browser/content/keepassxc-browser.js
+++ b/keepassxc-browser/content/keepassxc-browser.js
@@ -72,15 +72,21 @@ kpxc.clearAllFromPage = function() {
};
// Creates a new combination manually from active element
-kpxc.createCombination = async function(activeElement) {
+kpxc.createCombination = async function(activeElement, passOnly) {
const combination = {
username: null,
password: null,
passwordInputs: [],
- form: activeElement.form
+ form: null
};
- if (activeElement.getLowerCaseAttribute('type') === 'password') {
+ if (!activeElement) {
+ return combination;
+ }
+
+ combination.form = activeElement.form;
+
+ if (passOnly || activeElement.getLowerCaseAttribute('type') === 'password') {
combination.password = activeElement;
} else {
combination.username = activeElement;