Browse Source

Check that myself() is only run for own identities and issue alert() if not. 1.1.019-beta.

1.1.101
Jorg Knobloch 2 years ago
parent
commit
c9fa0cc7d7
2 changed files with 22 additions and 1 deletions
  1. +21
    -0
      addon/content/modules/pEp.js
  2. +1
    -1
      addon/manifest.json

+ 21
- 0
addon/content/modules/pEp.js View File

@ -15,6 +15,9 @@
*/
var { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
var { MailServices } = ChromeUtils.import("resource:///modules/MailServices.jsm");
var { fixIterator } = ChromeUtils.import("resource:///modules/iteratorUtils.jsm");
const EXPORTED_SYMBOLS = ["pEp"];
const DIR_INCOMING = 0;
@ -57,6 +60,21 @@ class pEp {
// pEp.instance = null;
}
check_myself(id) {
this.log.debug("check myself() for", id && id.address);
if (!(id && id.address)) return;
// Copied from `isOwnIdentity()`.
const emailToLower = id.address.toLowerCase();
for (let identity of fixIterator(MailServices.accounts.allIdentities, Ci.nsIMsgIdentity)) {
if (identity.email.toLowerCase() == emailToLower) return;
}
if (this.log.level >= 3) {
let win = Services.wm.getMostRecentWindow("mail:3pane");
win.alert(`Myself for ${id.address} which is NOT an own identity`);
}
}
async serverVersion() {
this.log.info("pEp: serverVersion()");
return this.adapter.serverVersion();
@ -66,6 +84,7 @@ class pEp {
* Function called on send mail
*/
async cache_encrypt_message(message, encodingFormat = ENC_FORMAT_PEP, isDraftOrTemplate = false) {
this.check_myself(message.from);
message.dir = DIR_OUTGOING;
message.enc_format = encodingFormat;
let encryptedMessage = await this.adapter.cache_encrypt_message(message, isDraftOrTemplate);
@ -76,6 +95,7 @@ class pEp {
* Function called on open mail
*/
async cache_decrypt_message(message) {
this.check_myself(message.recv_by);
message.dir = DIR_INCOMING;
let decryptedMessage = await this.adapter.cache_decrypt_message(message);
return pEp.Message.fromJSON(decryptedMessage);
@ -112,6 +132,7 @@ class pEp {
}
async myself(identity) {
this.check_myself(identity);
this.log.info("pEp: myself()");
// Workaround for ENGINE-753.
// Code was: return this.adapter.myself(identity);


+ 1
- 1
addon/manifest.json View File

@ -4,7 +4,7 @@
"description": "p≡p message encryption and authentication",
"author": "p≡p Team for Thunderbird",
"homepage_url": "https://pep.security",
"version": "1.1.018-beta",
"version": "1.1.019-beta",
"default_locale": "en",
"applications": {
"gecko": {


Loading…
Cancel
Save