Merge pull request #1000 from keepassxreboot/fix/171_small_fixes

Various fixes for 1.7.1
This commit is contained in:
Sami Vänttinen 2020-09-13 07:54:09 +03:00 committed by GitHub
commit c90cff8f65
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 50 additions and 44 deletions

View file

@ -190,7 +190,7 @@ kpxcAutocomplete.keyPress = function(e) {
if (kpxcAutocomplete.index >= 0 && items && items[kpxcAutocomplete.index] !== undefined) {
e.preventDefault();
kpxcAutocomplete.input.value = kpxcAutocomplete.elements[kpxcAutocomplete.index].value;
kpxcAutocomplete.fillPassword(kpxcAutocomplete.input.value, kpxcAutocomplete.index);
kpxcAutocomplete.fillPassword(kpxcAutocomplete.input.value, kpxcAutocomplete.index, kpxcAutocomplete.elements[kpxcAutocomplete.index].uuid);
kpxcAutocomplete.closeList();
}
} else if (e.key === 'Tab') {
@ -201,7 +201,7 @@ kpxcAutocomplete.keyPress = function(e) {
}
kpxcAutocomplete.index = kpxcAutocomplete.elements.findIndex(c => c.value === kpxcAutocomplete.input.value);
kpxcAutocomplete.fillPassword(kpxcAutocomplete.input.value, kpxcAutocomplete.index);
kpxcAutocomplete.fillPassword(kpxcAutocomplete.input.value, kpxcAutocomplete.index, kpxcAutocomplete.elements[kpxcAutocomplete.index].uuid);
kpxcAutocomplete.closeList();
} else if (e.key === 'Escape') {
kpxcAutocomplete.closeList();

View file

@ -144,11 +144,11 @@ kpxcBanner.saveNewCredentials = async function(credentials = {}) {
if (!result.defaultGroupAlwaysAsk) {
if (result.defaultGroup === '' || result.defaultGroup === DEFAULT_BROWSER_GROUP) {
// Default group is used
const args = [ credentials.username, credentials.password, credentials.url ];
const res = await sendMessage('add_credentials', args);
kpxcBanner.verifyResult(res);
return;
// Default group is used
const args = [ credentials.username, credentials.password, credentials.url ];
const res = await sendMessage('add_credentials', args);
kpxcBanner.verifyResult(res);
return;
} else {
// A specified group is used
let gname = '';

View file

@ -14,7 +14,7 @@ kpxcDefine.diffX = 0;
kpxcDefine.diffY = 0;
kpxcDefine.eventFieldClick = null;
kpxcDefine.inputQueryPattern = 'input[type=\'text\'], input[type=\'email\'], input[type=\'password\'], input[type=\'tel\'], input[type=\'number\'], input[type=\'username\'], input:not([type])';
kpxcDefine.markedFields= [];
kpxcDefine.markedFields = [];
kpxcDefine.keyDown = null;
kpxcDefine.startPosX = 0;
kpxcDefine.startPosY = 0;

View file

@ -358,9 +358,9 @@ kpxcFields.getAllPageInputs = async function(previousInputs = []) {
if (!kpxc.singleInputEnabledForPage
&& ((fields.length === 1 && fields[0].getLowerCaseAttribute('type') !== 'password')
|| (previousInputs.length === 1 && previousInputs[0].getLowerCaseAttribute('type') !== 'password'))) {
sendMessage('username_field_detected', true );
sendMessage('username_field_detected', true);
} else {
sendMessage('username_field_detected', false );
sendMessage('username_field_detected', false);
}
await kpxc.initCombinations(inputs);
@ -390,11 +390,11 @@ kpxcFields.getCombination = async function(field, givenType) {
// Gets of generates an unique ID for the element
kpxcFields.getId = function(target) {
if (target.classList.length > 0) {
return `${target.nodeName} ${target.type} ${target.classList.value}`;
return `${target.nodeName} ${target.type} ${target.classList.value} ${target.name} ${target.placeholder}`;
}
if (target.id && target.id !== '') {
return `${target.nodeName} ${target.type} ${kpxcFields.prepareId(target.id)}`;
return `${target.nodeName} ${target.type} ${kpxcFields.prepareId(target.id)} ${target.name} ${target.placeholder}`;
}
return `kpxc ${target.type} ${target.clientTop}${target.clientLeft}${target.clientWidth}${target.clientHeight}${target.offsetTop}${target.offsetLeft}`;
@ -530,7 +530,7 @@ kpxcFields.useCustomLoginFields = async function() {
}
});
[ creds.username, creds.password, creds.totp ] = await Promise.all([
const [ username, password, totp ] = await Promise.all([
await findInputField(inputFields, creds.username),
await findInputField(inputFields, creds.password),
await findInputField(inputFields, creds.totp)
@ -546,17 +546,17 @@ kpxcFields.useCustomLoginFields = async function() {
}
// Handle custom TOTP field
if (creds.totp) {
creds.totp.setAttribute('kpxc-defined', 'totp');
kpxcTOTPIcons.newIcon(creds.totp, kpxc.databaseState, true);
if (totp) {
totp.setAttribute('kpxc-defined', 'totp');
kpxcTOTPIcons.newIcon(totp, kpxc.databaseState, true);
}
const combinations = [];
combinations.push({
username: creds.username,
password: creds.password,
passwordInputs: [ creds.password ],
totp: creds.totp,
username: username,
password: password,
passwordInputs: [ password ],
totp: totp,
fields: stringFields
});
@ -696,7 +696,7 @@ kpxc.fillInFromActiveElement = async function(passOnly = false) {
const el = document.activeElement;
if (el.nodeName !== 'INPUT' || kpxc.credentials.length === 0) {
return;
} else if (kpxc.credentials.length > 1 && kpxc.combinations.length > 0) {
} else if (kpxc.credentials.length > 1 && kpxc.combinations.length > 0 && kpxc.settings.autoCompleteUsernames) {
kpxcAutocomplete.showList(el);
return;
}
@ -723,15 +723,16 @@ kpxc.fillInFromActiveElement = async function(passOnly = false) {
// Fill requested by Auto-Fill
kpxc.fillFromAutofill = async function() {
if (kpxc.credentials.length !== 1 || kpxc.combinations.length !== 1) {
if (kpxc.credentials.length !== 1 || kpxc.combinations.length === 0) {
return;
}
const index = kpxc.combinations.length - 1;
await sendMessage('page_set_login_id', 0);
kpxc.fillInCredentials(kpxc.combinations[0], kpxc.credentials[0].login, kpxc.credentials[0].uuid);
kpxc.fillInCredentials(kpxc.combinations[index], kpxc.credentials[0].login, kpxc.credentials[0].uuid);
// Generate popup-list of usernames + descriptions
sendMessage('popup_login', [ `${kpxc.credentials[0].login} (${kpxc.credentials[0].name})` ]);
sendMessage('popup_login', [ { text: `${kpxc.credentials[0].login} (${kpxc.credentials[0].name})`, uuid: kpxc.credentials[0].uuid } ]);
};
// Fill requested by selecting credentials from the popup
@ -783,7 +784,7 @@ kpxc.fillFromUsernameIcon = async function(combination) {
await kpxc.receiveCredentialsIfNecessary();
if (kpxc.credentials.length === 0) {
return;
} else if (kpxc.credentials.length > 1) {
} else if (kpxc.credentials.length > 1 && kpxc.settings.autoCompleteUsernames) {
kpxcAutocomplete.showList(combination.username || combination.password);
return;
}
@ -854,7 +855,7 @@ kpxc.fillInCredentials = async function(combination, predefinedUsername, uuid, p
// Auto-submit
if (kpxc.settings.autoSubmit && !skipAutoSubmit) {
const submitButton = kpxc.getFormSubmitButton(combination.form);
const submitButton = kpxcForm.getFormSubmitButton(combination.form);
if (submitButton !== undefined) {
submitButton.click();
} else {
@ -1035,7 +1036,7 @@ kpxc.initCombinations = async function(inputs = []) {
// The main function for finding input fields
kpxc.initCredentialFields = async function() {
await sendMessage('page_clear_logins', _called.clearLogins );
await sendMessage('page_clear_logins', _called.clearLogins);
_called.clearLogins = true;
// Identify all forms in the page
@ -1060,7 +1061,7 @@ kpxc.initCredentialFields = async function() {
}
// Combine inputs
kpxc.inputs = [...formInputs, ...pageInputs];
kpxc.inputs = [ ...formInputs, ...pageInputs ];
// Combinations are already saved when identifying fields
if (kpxc.combinations.length === 0) {
@ -1471,7 +1472,7 @@ kpxcObserverHelper.getInputs = function(target, ignoreVisibility = false) {
target.shadowSelectorAll('input').forEach(e => {
if (e.type !== 'hidden' && !e.disabled && !kpxcObserverHelper.alreadyIdentified(e)) {
inputFields.push(e);
};
}
});
}
@ -1525,8 +1526,13 @@ kpxcObserverHelper.handleObserverAdd = async function(target) {
await kpxc.initCombinations(inputs);
await kpxcIcons.initIcons(kpxc.combinations);
if (kpxc.databaseState === DatabaseState.UNLOCKED && _called.retrieveCredentials === false) {
await kpxc.retrieveCredentials();
if (kpxc.databaseState === DatabaseState.UNLOCKED) {
if (_called.retrieveCredentials === false) {
await kpxc.retrieveCredentials();
return;
}
kpxc.prepareCredentials();
}
};
@ -1574,8 +1580,8 @@ kpxcObserverHelper.ignoredNode = function(target) {
|| kpxcObserverHelper.ignoredNodeNames.some(e => e === target.nodeName)
|| target.nodeName.startsWith('YTMUSIC')
|| target.nodeName.startsWith('YT-')) {
return true;
}
return true;
}
return false;
};
@ -1592,7 +1598,7 @@ kpxcObserverHelper.initObserver = async function() {
mutations = mutations.slice(0, _maximumMutations);
}
let styleMutations = [];
const styleMutations = [];
for (const mut of mutations) {
if (kpxcObserverHelper.ignoredNode(mut.target)) {
continue;
@ -1614,10 +1620,6 @@ kpxcObserverHelper.initObserver = async function() {
continue;
}
// Listen for possible CSS animations
mut.target.removeEventListener('transitionend', kpxcObserverHelper.handleTransitionEnd);
mut.target.addEventListener('transitionend', kpxcObserverHelper.handleTransitionEnd);
// There's an issue here. We cannot know for sure if the class attribute if added or removed.
kpxcObserverHelper.handleObserverAdd(mut.target);
}
@ -1658,7 +1660,7 @@ const initContentScript = async function() {
}
// Retrieve submitted credentials if available.
const [creds, redirectCount] = await Promise.all([
const [ creds, redirectCount ] = await Promise.all([
await sendMessage('page_get_submitted'),
await sendMessage('page_get_redirect_count')
]);

View file

@ -223,7 +223,7 @@ kpxcPasswordDialog.showDialog = function(field, icon) {
// Save next password field if found
if (kpxc.inputs.length > 0) {
const index = kpxc.inputs.indexOf(field);
const nextField = kpxc.inputs[index+1];
const nextField = kpxc.inputs[index + 1];
kpxcPasswordDialog.nextField = (nextField && nextField.getLowerCaseAttribute('type') === 'password') ? nextField : undefined;
}
@ -278,7 +278,7 @@ kpxcPasswordDialog.fill = function(e) {
const message = tr('passwordGeneratorErrorTooLong') + '\r\n'
+ tr('passwordGeneratorErrorTooLongCut') + '\r\n' + tr('passwordGeneratorErrorTooLongRemember');
message.style.whiteSpace = 'pre';
sendMessage('show_notification' [ message ]);
sendMessage('show_notification', [ message ]);
return;
}
}

View file

@ -34,8 +34,12 @@ kpxcTOTPIcons.isAcceptedTOTPField = function(field) {
const id = field.getLowerCaseAttribute('id');
const name = field.getLowerCaseAttribute('name');
const autocomplete = field.getLowerCaseAttribute('autocomplete');
const placeholder = field.getLowerCaseAttribute('placeholder');
if (autocomplete === 'one-time-code' || acceptedOTPFields.some(f => (id && id.includes(f)) || (name && name.includes(f)))) {
// Checks if the field id, name or placeholder includes some of the acceptedOTPFields but not any from ignoredTypes
if (autocomplete === 'one-time-code'
|| (acceptedOTPFields.some(f => (id && id.includes(f)) || (name && name.includes(f) || placeholder && placeholder.includes(f))))
&& !ignoredTypes.some(f => (id && id.includes(f)) || (name && name.includes(f) || placeholder && placeholder.includes(f)))) {
return true;
}

View file

@ -1,8 +1,8 @@
{
"manifest_version": 2,
"name": "KeePassXC-Browser",
"version": "1.7.0",
"version_name": "1.7.0",
"version": "1.7.1",
"version_name": "1.7.1",
"description": "__MSG_extensionDescription__",
"author": "KeePassXC Team",
"icons": {