From f8517daf2531bbd0b9b899f55ea39c8a407250e4 Mon Sep 17 00:00:00 2001 From: antixn Date: Wed, 24 Mar 2021 15:49:39 +0100 Subject: [PATCH 01/25] allow alt lookup for keepass in /usr/lib --- xul-ext/modules/utils.js | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/xul-ext/modules/utils.js b/xul-ext/modules/utils.js index b0ef469..8e46b0c 100644 --- a/xul-ext/modules/utils.js +++ b/xul-ext/modules/utils.js @@ -27,6 +27,7 @@ const { KeeFoxLog } = ChromeUtils.import("resource://kfmod/KFLogger.js"); const { KFExtension } = ChromeUtils.import("resource://kfmod/KFExtension.js"); const { BigInteger } = ChromeUtils.import("resource://kfmod/biginteger.js"); const { FileUtils } = ChromeUtils.import("resource://gre/modules/FileUtils.jsm"); +var { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm"); // constructor function Utils() @@ -155,12 +156,24 @@ Utils.prototype = { this._KFLog.debug("Checking KeePass installation location from filesystem"); // Get the users home directory - var dirService = Components.classes["@mozilla.org/file/directory_service;1"]. - getService(Components.interfaces.nsIProperties); - var keePassFolder = dirService.get("Home", Components.interfaces.nsIFile); // returns an nsIFile object + var keePassFolder = Services.dirsvc.get("Home", Components.interfaces.nsIFile); // returns an nsIFile object keePassFolder.append("KeePass"); var keePassFile = keePassFolder.clone(); keePassFile.append("KeePass.exe"); + if (!keePassFile.exists()) + { + // try a location like /usr/lib/thunderbird/../keepass2 + // eg /usr/lib/keepass2 but a workaround seems needed as + // the parameter for dirsvc.get() is a constant + // see https://gist.github.com/Noitidart/715840fa5008ee032017 for more details + this._KFLog.debug("***was testing "+keePassFolder.path); + keePassFolder = Services.dirsvc.get("GreD", Components.interfaces.nsIFile); + this._KFLog.debug("***is testing "+keePassFolder.path); + keePassFolder.append(".."); + keePassFolder.append("keepass2"); + keePassFile = keePassFolder.clone(); + keePassFile.append("KeePass.exe"); + } if (keePassFile.exists()) { keePassLocation = keePassFolder.path; @@ -420,7 +433,7 @@ Utils.prototype = { else this._KFLog.debug("trying to find an already open tab with the requested url"); var found = false; - + var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"] .getService(Components.interfaces.nsIWindowMediator); try From 58565be6be33c97f6c9610b323ccc59a63b63def Mon Sep 17 00:00:00 2001 From: antixn Date: Wed, 24 Mar 2021 15:50:14 +0100 Subject: [PATCH 02/25] fix : avoid window.keefox_org is undefined --- xul-ext/modules/kprpcClient.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/xul-ext/modules/kprpcClient.js b/xul-ext/modules/kprpcClient.js index 3910512..18c8b1b 100644 --- a/xul-ext/modules/kprpcClient.js +++ b/xul-ext/modules/kprpcClient.js @@ -524,9 +524,11 @@ kprpcClient.prototype.constructor = kprpcClient; this.identifyToClient = function(data) { var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"] .getService(Components.interfaces.nsIWindowMediator); - var window = wm.getMostRecentWindow("common-dialog") || - wm.getMostRecentWindow("navigator:browser") || - wm.getMostRecentWindow("mail:3pane"); + var window = wm.getMostRecentWindow("navigator:browser") || + wm.getMostRecentWindow("mail:3pane") || + // to avoid the "JavaScript error: resource://kfmod/kprpcClient.js, line 537: TypeError: window.keefox_org is undefined" + // -> move common-dialog to the end of window lookup + wm.getMostRecentWindow("common-dialog"); // get the user to type in the one-time password let prompts = Components.classes["@mozilla.org/embedcomp/prompt-service;1"] From 0871d79ad6c2c72075f60de07fda14630b7dd00f Mon Sep 17 00:00:00 2001 From: antixn Date: Wed, 24 Mar 2021 15:50:50 +0100 Subject: [PATCH 03/25] usage comments --- xul-ext/modules/KF.js | 19 +++++++++++++++++++ xul-ext/modules/locales.js | 3 ++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/xul-ext/modules/KF.js b/xul-ext/modules/KF.js index 841fa3b..3359ee3 100644 --- a/xul-ext/modules/KF.js +++ b/xul-ext/modules/KF.js @@ -432,6 +432,10 @@ KeeFox.prototype = { try { var win = enumerator.getNext(); + if (win.keefox_win === undefined) { + this._KFLog.debug("win.keefox_win === undefined"); + continue; + } win.keefox_win.mainUI.resetSearchInterface(); win.keefox_win.mainUI.removeLogins(); win.keefox_win.context.removeLogins(); @@ -825,6 +829,19 @@ KeeFox.prototype = { } }, + /** + * https://github.com/kee-org/keepassrpc/blob/v1.14.0/KeePassRPC/KeePassRPCService.cs + * @param {*} fullURL The URLs to search for. Host must be lower case as per the URI specs. Other parts are case sensitive. + * @param {*} formSubmitURL The action URL. + * @param {*} httpRealm The HTTP realm. + * @param {*} uniqueID The unique ID of a particular entry we want to retrieve. + * @param {*} dbFileName The unique ID of the root group of the database we want to search. Empty string = search all DBs + * @param {*} freeText A string to search for in all entries. E.g. title, username (may change) + * @param {*} username Limit a search for URL to exact username matches only + * @param {*} callback + * @param {*} callbackData + * @returns + */ findLogins: function(fullURL, formSubmitURL, httpRealm, uniqueID, dbFileName, freeText, username, callback, callbackData) { try @@ -991,6 +1008,8 @@ KeeFox.prototype = { case "logMethodStdOut": case "logSensitiveData": // Allow the change to go ahead but warn the user (in case they did not understand the change that was made) + // Remark : strange here to refer to keefox_org from window, other cases directly uses keefox_org + // -> don't have any test scenario to see if it's working or not window.keefox_org._KFLog.configureFromPreferences(); utils.oneOffSensitiveLogCheckHandler(); break; diff --git a/xul-ext/modules/locales.js b/xul-ext/modules/locales.js index 1d2a7a8..25a7510 100644 --- a/xul-ext/modules/locales.js +++ b/xul-ext/modules/locales.js @@ -368,8 +368,9 @@ Localisation.prototype = { args = elements[i][1]; } - if (!element) + if (!element) { continue; + } // Replace within text content too. Assumes there are no other subnodes. May need to be more clever here. if (element.childNodes != null && element.childNodes.length > 0) From 5d478bfc5aaafbbb5b7eae774c16a986ba507d88 Mon Sep 17 00:00:00 2001 From: antixn Date: Wed, 24 Mar 2021 15:53:36 +0100 Subject: [PATCH 04/25] fix : avoid keefox_win.mainUI is undefined --- xul-ext/chrome/content/keefoxWin.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/xul-ext/chrome/content/keefoxWin.js b/xul-ext/chrome/content/keefoxWin.js index 3f46186..2e216c5 100644 --- a/xul-ext/chrome/content/keefoxWin.js +++ b/xul-ext/chrome/content/keefoxWin.js @@ -170,8 +170,9 @@ keefox_win.mainEventHandler = var observerService = Cc["@mozilla.org/observer-service;1"]. getService(Ci.nsIObserverService); observerService.removeObserver(this, "sessionstore-windows-restored", false); - - keefox_win.mainUI.shutdown(); + if (keefox_win.mainUI !== undefined) { + keefox_win.mainUI.shutdown(); + } keefox_win.Logger.info("Window shut down."); return; default: From 80ee637e3dfae6584b90237df6a4d661e53f2666 Mon Sep 17 00:00:00 2001 From: antixn Date: Wed, 24 Mar 2021 15:54:56 +0100 Subject: [PATCH 05/25] run target : uses web-ext to launch extension --- Makefile | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Makefile b/Makefile index 9e3ca29..1e193cb 100644 --- a/Makefile +++ b/Makefile @@ -2,6 +2,8 @@ PREFIX := /usr DATADIR := $(PREFIX)/share +# the profile dir is copied and left unmodified by web-ext +PROFILE := /home/xavier/.thunderbird/6ujxy9ck.default-release-2/ # UUID below is for Thunderbird TB_EXT_DIR := $(DATADIR)/mozilla/extensions/{3550f703-e582-4d05-9a08-453d09bdfdc6} @@ -17,3 +19,8 @@ clean: install: all install -d $(DESTDIR)$(TB_EXT_DIR) install --mode=644 *.xpi $(DESTDIR)$(TB_EXT_DIR) + +run: + web-ext run --verbose --firefox=/usr/bin/thunderbird --firefox-profile=$(PROFILE) -s xul-ext/ +lint: + web-ext lint -s xul-ext/ \ No newline at end of file From 3a416df1ad8b00b3c03056d99db041dc395b2a7d Mon Sep 17 00:00:00 2001 From: antixn Date: Wed, 24 Mar 2021 21:18:05 +0100 Subject: [PATCH 06/25] tb68/changes#less-than-progressmeter-greater-than --- xul-ext/chrome/content/install.xul | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/xul-ext/chrome/content/install.xul b/xul-ext/chrome/content/install.xul index e5b8bbd..745b767 100644 --- a/xul-ext/chrome/content/install.xul +++ b/xul-ext/chrome/content/install.xul @@ -295,7 +295,7 @@ IC7 and 8: Currently same as IC3/6 but will display different text to user