Skip to content

Commit c90cff8

Browse files
author
Sami Vänttinen
authored
Merge pull request #1000 from keepassxreboot/fix/171_small_fixes
Various fixes for 1.7.1
2 parents ff8915b + 83b9262 commit c90cff8

File tree

7 files changed

+50
-44
lines changed

7 files changed

+50
-44
lines changed

keepassxc-browser/content/autocomplete.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ kpxcAutocomplete.keyPress = function(e) {
190190
if (kpxcAutocomplete.index >= 0 && items && items[kpxcAutocomplete.index] !== undefined) {
191191
e.preventDefault();
192192
kpxcAutocomplete.input.value = kpxcAutocomplete.elements[kpxcAutocomplete.index].value;
193-
kpxcAutocomplete.fillPassword(kpxcAutocomplete.input.value, kpxcAutocomplete.index);
193+
kpxcAutocomplete.fillPassword(kpxcAutocomplete.input.value, kpxcAutocomplete.index, kpxcAutocomplete.elements[kpxcAutocomplete.index].uuid);
194194
kpxcAutocomplete.closeList();
195195
}
196196
} else if (e.key === 'Tab') {
@@ -201,7 +201,7 @@ kpxcAutocomplete.keyPress = function(e) {
201201
}
202202

203203
kpxcAutocomplete.index = kpxcAutocomplete.elements.findIndex(c => c.value === kpxcAutocomplete.input.value);
204-
kpxcAutocomplete.fillPassword(kpxcAutocomplete.input.value, kpxcAutocomplete.index);
204+
kpxcAutocomplete.fillPassword(kpxcAutocomplete.input.value, kpxcAutocomplete.index, kpxcAutocomplete.elements[kpxcAutocomplete.index].uuid);
205205
kpxcAutocomplete.closeList();
206206
} else if (e.key === 'Escape') {
207207
kpxcAutocomplete.closeList();

keepassxc-browser/content/banner.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -144,11 +144,11 @@ kpxcBanner.saveNewCredentials = async function(credentials = {}) {
144144

145145
if (!result.defaultGroupAlwaysAsk) {
146146
if (result.defaultGroup === '' || result.defaultGroup === DEFAULT_BROWSER_GROUP) {
147-
// Default group is used
148-
const args = [ credentials.username, credentials.password, credentials.url ];
149-
const res = await sendMessage('add_credentials', args);
150-
kpxcBanner.verifyResult(res);
151-
return;
147+
// Default group is used
148+
const args = [ credentials.username, credentials.password, credentials.url ];
149+
const res = await sendMessage('add_credentials', args);
150+
kpxcBanner.verifyResult(res);
151+
return;
152152
} else {
153153
// A specified group is used
154154
let gname = '';

keepassxc-browser/content/define.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ kpxcDefine.diffX = 0;
1414
kpxcDefine.diffY = 0;
1515
kpxcDefine.eventFieldClick = null;
1616
kpxcDefine.inputQueryPattern = 'input[type=\'text\'], input[type=\'email\'], input[type=\'password\'], input[type=\'tel\'], input[type=\'number\'], input[type=\'username\'], input:not([type])';
17-
kpxcDefine.markedFields= [];
17+
kpxcDefine.markedFields = [];
1818
kpxcDefine.keyDown = null;
1919
kpxcDefine.startPosX = 0;
2020
kpxcDefine.startPosY = 0;

keepassxc-browser/content/keepassxc-browser.js

Lines changed: 33 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -358,9 +358,9 @@ kpxcFields.getAllPageInputs = async function(previousInputs = []) {
358358
if (!kpxc.singleInputEnabledForPage
359359
&& ((fields.length === 1 && fields[0].getLowerCaseAttribute('type') !== 'password')
360360
|| (previousInputs.length === 1 && previousInputs[0].getLowerCaseAttribute('type') !== 'password'))) {
361-
sendMessage('username_field_detected', true );
361+
sendMessage('username_field_detected', true);
362362
} else {
363-
sendMessage('username_field_detected', false );
363+
sendMessage('username_field_detected', false);
364364
}
365365

366366
await kpxc.initCombinations(inputs);
@@ -390,11 +390,11 @@ kpxcFields.getCombination = async function(field, givenType) {
390390
// Gets of generates an unique ID for the element
391391
kpxcFields.getId = function(target) {
392392
if (target.classList.length > 0) {
393-
return `${target.nodeName} ${target.type} ${target.classList.value}`;
393+
return `${target.nodeName} ${target.type} ${target.classList.value} ${target.name} ${target.placeholder}`;
394394
}
395395

396396
if (target.id && target.id !== '') {
397-
return `${target.nodeName} ${target.type} ${kpxcFields.prepareId(target.id)}`;
397+
return `${target.nodeName} ${target.type} ${kpxcFields.prepareId(target.id)} ${target.name} ${target.placeholder}`;
398398
}
399399

400400
return `kpxc ${target.type} ${target.clientTop}${target.clientLeft}${target.clientWidth}${target.clientHeight}${target.offsetTop}${target.offsetLeft}`;
@@ -530,7 +530,7 @@ kpxcFields.useCustomLoginFields = async function() {
530530
}
531531
});
532532

533-
[ creds.username, creds.password, creds.totp ] = await Promise.all([
533+
const [ username, password, totp ] = await Promise.all([
534534
await findInputField(inputFields, creds.username),
535535
await findInputField(inputFields, creds.password),
536536
await findInputField(inputFields, creds.totp)
@@ -546,17 +546,17 @@ kpxcFields.useCustomLoginFields = async function() {
546546
}
547547

548548
// Handle custom TOTP field
549-
if (creds.totp) {
550-
creds.totp.setAttribute('kpxc-defined', 'totp');
551-
kpxcTOTPIcons.newIcon(creds.totp, kpxc.databaseState, true);
549+
if (totp) {
550+
totp.setAttribute('kpxc-defined', 'totp');
551+
kpxcTOTPIcons.newIcon(totp, kpxc.databaseState, true);
552552
}
553553

554554
const combinations = [];
555555
combinations.push({
556-
username: creds.username,
557-
password: creds.password,
558-
passwordInputs: [ creds.password ],
559-
totp: creds.totp,
556+
username: username,
557+
password: password,
558+
passwordInputs: [ password ],
559+
totp: totp,
560560
fields: stringFields
561561
});
562562

@@ -696,7 +696,7 @@ kpxc.fillInFromActiveElement = async function(passOnly = false) {
696696
const el = document.activeElement;
697697
if (el.nodeName !== 'INPUT' || kpxc.credentials.length === 0) {
698698
return;
699-
} else if (kpxc.credentials.length > 1 && kpxc.combinations.length > 0) {
699+
} else if (kpxc.credentials.length > 1 && kpxc.combinations.length > 0 && kpxc.settings.autoCompleteUsernames) {
700700
kpxcAutocomplete.showList(el);
701701
return;
702702
}
@@ -723,15 +723,16 @@ kpxc.fillInFromActiveElement = async function(passOnly = false) {
723723

724724
// Fill requested by Auto-Fill
725725
kpxc.fillFromAutofill = async function() {
726-
if (kpxc.credentials.length !== 1 || kpxc.combinations.length !== 1) {
726+
if (kpxc.credentials.length !== 1 || kpxc.combinations.length === 0) {
727727
return;
728728
}
729729

730+
const index = kpxc.combinations.length - 1;
730731
await sendMessage('page_set_login_id', 0);
731-
kpxc.fillInCredentials(kpxc.combinations[0], kpxc.credentials[0].login, kpxc.credentials[0].uuid);
732+
kpxc.fillInCredentials(kpxc.combinations[index], kpxc.credentials[0].login, kpxc.credentials[0].uuid);
732733

733734
// Generate popup-list of usernames + descriptions
734-
sendMessage('popup_login', [ `${kpxc.credentials[0].login} (${kpxc.credentials[0].name})` ]);
735+
sendMessage('popup_login', [ { text: `${kpxc.credentials[0].login} (${kpxc.credentials[0].name})`, uuid: kpxc.credentials[0].uuid } ]);
735736
};
736737

737738
// Fill requested by selecting credentials from the popup
@@ -783,7 +784,7 @@ kpxc.fillFromUsernameIcon = async function(combination) {
783784
await kpxc.receiveCredentialsIfNecessary();
784785
if (kpxc.credentials.length === 0) {
785786
return;
786-
} else if (kpxc.credentials.length > 1) {
787+
} else if (kpxc.credentials.length > 1 && kpxc.settings.autoCompleteUsernames) {
787788
kpxcAutocomplete.showList(combination.username || combination.password);
788789
return;
789790
}
@@ -854,7 +855,7 @@ kpxc.fillInCredentials = async function(combination, predefinedUsername, uuid, p
854855

855856
// Auto-submit
856857
if (kpxc.settings.autoSubmit && !skipAutoSubmit) {
857-
const submitButton = kpxc.getFormSubmitButton(combination.form);
858+
const submitButton = kpxcForm.getFormSubmitButton(combination.form);
858859
if (submitButton !== undefined) {
859860
submitButton.click();
860861
} else {
@@ -1035,7 +1036,7 @@ kpxc.initCombinations = async function(inputs = []) {
10351036

10361037
// The main function for finding input fields
10371038
kpxc.initCredentialFields = async function() {
1038-
await sendMessage('page_clear_logins', _called.clearLogins );
1039+
await sendMessage('page_clear_logins', _called.clearLogins);
10391040
_called.clearLogins = true;
10401041

10411042
// Identify all forms in the page
@@ -1060,7 +1061,7 @@ kpxc.initCredentialFields = async function() {
10601061
}
10611062

10621063
// Combine inputs
1063-
kpxc.inputs = [...formInputs, ...pageInputs];
1064+
kpxc.inputs = [ ...formInputs, ...pageInputs ];
10641065

10651066
// Combinations are already saved when identifying fields
10661067
if (kpxc.combinations.length === 0) {
@@ -1471,7 +1472,7 @@ kpxcObserverHelper.getInputs = function(target, ignoreVisibility = false) {
14711472
target.shadowSelectorAll('input').forEach(e => {
14721473
if (e.type !== 'hidden' && !e.disabled && !kpxcObserverHelper.alreadyIdentified(e)) {
14731474
inputFields.push(e);
1474-
};
1475+
}
14751476
});
14761477
}
14771478

@@ -1525,8 +1526,13 @@ kpxcObserverHelper.handleObserverAdd = async function(target) {
15251526
await kpxc.initCombinations(inputs);
15261527
await kpxcIcons.initIcons(kpxc.combinations);
15271528

1528-
if (kpxc.databaseState === DatabaseState.UNLOCKED && _called.retrieveCredentials === false) {
1529-
await kpxc.retrieveCredentials();
1529+
if (kpxc.databaseState === DatabaseState.UNLOCKED) {
1530+
if (_called.retrieveCredentials === false) {
1531+
await kpxc.retrieveCredentials();
1532+
return;
1533+
}
1534+
1535+
kpxc.prepareCredentials();
15301536
}
15311537
};
15321538

@@ -1574,8 +1580,8 @@ kpxcObserverHelper.ignoredNode = function(target) {
15741580
|| kpxcObserverHelper.ignoredNodeNames.some(e => e === target.nodeName)
15751581
|| target.nodeName.startsWith('YTMUSIC')
15761582
|| target.nodeName.startsWith('YT-')) {
1577-
return true;
1578-
}
1583+
return true;
1584+
}
15791585

15801586
return false;
15811587
};
@@ -1592,7 +1598,7 @@ kpxcObserverHelper.initObserver = async function() {
15921598
mutations = mutations.slice(0, _maximumMutations);
15931599
}
15941600

1595-
let styleMutations = [];
1601+
const styleMutations = [];
15961602
for (const mut of mutations) {
15971603
if (kpxcObserverHelper.ignoredNode(mut.target)) {
15981604
continue;
@@ -1614,10 +1620,6 @@ kpxcObserverHelper.initObserver = async function() {
16141620
continue;
16151621
}
16161622

1617-
// Listen for possible CSS animations
1618-
mut.target.removeEventListener('transitionend', kpxcObserverHelper.handleTransitionEnd);
1619-
mut.target.addEventListener('transitionend', kpxcObserverHelper.handleTransitionEnd);
1620-
16211623
// There's an issue here. We cannot know for sure if the class attribute if added or removed.
16221624
kpxcObserverHelper.handleObserverAdd(mut.target);
16231625
}
@@ -1658,7 +1660,7 @@ const initContentScript = async function() {
16581660
}
16591661

16601662
// Retrieve submitted credentials if available.
1661-
const [creds, redirectCount] = await Promise.all([
1663+
const [ creds, redirectCount ] = await Promise.all([
16621664
await sendMessage('page_get_submitted'),
16631665
await sendMessage('page_get_redirect_count')
16641666
]);

keepassxc-browser/content/pwgen.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ kpxcPasswordDialog.showDialog = function(field, icon) {
223223
// Save next password field if found
224224
if (kpxc.inputs.length > 0) {
225225
const index = kpxc.inputs.indexOf(field);
226-
const nextField = kpxc.inputs[index+1];
226+
const nextField = kpxc.inputs[index + 1];
227227
kpxcPasswordDialog.nextField = (nextField && nextField.getLowerCaseAttribute('type') === 'password') ? nextField : undefined;
228228
}
229229

@@ -278,7 +278,7 @@ kpxcPasswordDialog.fill = function(e) {
278278
const message = tr('passwordGeneratorErrorTooLong') + '\r\n'
279279
+ tr('passwordGeneratorErrorTooLongCut') + '\r\n' + tr('passwordGeneratorErrorTooLongRemember');
280280
message.style.whiteSpace = 'pre';
281-
sendMessage('show_notification' [ message ]);
281+
sendMessage('show_notification', [ message ]);
282282
return;
283283
}
284284
}

keepassxc-browser/content/totp-field.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,12 @@ kpxcTOTPIcons.isAcceptedTOTPField = function(field) {
3434
const id = field.getLowerCaseAttribute('id');
3535
const name = field.getLowerCaseAttribute('name');
3636
const autocomplete = field.getLowerCaseAttribute('autocomplete');
37+
const placeholder = field.getLowerCaseAttribute('placeholder');
3738

38-
if (autocomplete === 'one-time-code' || acceptedOTPFields.some(f => (id && id.includes(f)) || (name && name.includes(f)))) {
39+
// Checks if the field id, name or placeholder includes some of the acceptedOTPFields but not any from ignoredTypes
40+
if (autocomplete === 'one-time-code'
41+
|| (acceptedOTPFields.some(f => (id && id.includes(f)) || (name && name.includes(f) || placeholder && placeholder.includes(f))))
42+
&& !ignoredTypes.some(f => (id && id.includes(f)) || (name && name.includes(f) || placeholder && placeholder.includes(f)))) {
3943
return true;
4044
}
4145

keepassxc-browser/manifest.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
22
"manifest_version": 2,
33
"name": "KeePassXC-Browser",
4-
"version": "1.7.0",
5-
"version_name": "1.7.0",
4+
"version": "1.7.1",
5+
"version_name": "1.7.1",
66
"description": "__MSG_extensionDescription__",
77
"author": "KeePassXC Team",
88
"icons": {

0 commit comments

Comments
 (0)