From 1a218573e7d26b5c7f95d4902f657c081c5418d4 Mon Sep 17 00:00:00 2001 From: varjolintu Date: Wed, 11 Oct 2023 13:05:58 +0300 Subject: [PATCH] Add some extra checks when removing a connection --- keepassxc-browser/background/event.js | 5 +++-- keepassxc-browser/options/options.js | 6 +++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/keepassxc-browser/background/event.js b/keepassxc-browser/background/event.js index 71f530b..db8afbd 100755 --- a/keepassxc-browser/background/event.js +++ b/keepassxc-browser/background/event.js @@ -15,7 +15,8 @@ kpxcEvent.onMessage = async function(request, sender) { kpxcEvent.showStatus = async function(tab, configured, internalPoll) { let keyId = null; - if (configured && keepass.databaseHash !== '') { + if (configured && keepass.databaseHash !== '' + && Object.hasOwn(keepass.databaseHash, keepass.databaseHash)) { keyId = keepass.keyRing[keepass.databaseHash].id; } @@ -91,7 +92,7 @@ kpxcEvent.onGetStatus = async function(tab, args = []) { kpxcEvent.onReconnect = async function(tab) { const configured = await keepass.reconnect(tab); if (configured) { - browser.tabs.sendMessage(tab.id, { + browser.tabs.sendMessage(tab?.id, { action: 'redetect_fields' }).catch((err) => { logError(err); diff --git a/keepassxc-browser/options/options.js b/keepassxc-browser/options/options.js index 3e7bd85..3fd5a2f 100644 --- a/keepassxc-browser/options/options.js +++ b/keepassxc-browser/options/options.js @@ -370,7 +370,11 @@ options.initConnectedDatabases = function() { const closestTr = this.closest('tr'); $('#dialogDeleteConnectedDatabase').setAttribute('hash', closestTr.getAttribute('hash')); $('#dialogDeleteConnectedDatabase').setAttribute('tr-id', closestTr.getAttribute('id')); - $('#dialogDeleteConnectedDatabase .modal-body strong').textContent = closestTr.children[0].textContent; + + const identifier = $('#dialogDeleteConnectedDatabase .modal-body strong'); + if (identifier) { + identifier.textContent = closestTr.children[0].textContent; + } dialogDeleteConnectedDatabaseModal.show(); $('#dialogDeleteConnectedDatabase').addEventListener('shown.bs.modal', function(modalEvent) {