Store messageId also in the inner message. It's avaialable in beginCryptoEncapsulation().

master
Jörg Knobloch 2 years ago
parent c73ffeb477
commit 20754d54ef

@ -664,10 +664,11 @@ class pEpForThunderbird extends pEp {
// Copy some headers from the original to the new message.
// Starting with https://pep-security.lu/dev/repos/pEp_for_Thunderbird/rev/d3c752abce8c
// we store the references and in-reply-to also in the inner message.
// Sadly at encryption time, the message ID is not yet available, so it can't be used
// as ID for the inner message :-(
// on 7th Sep 2020 in verion 1.1.006-beta we store the references and in-reply-to also
// in the inner message. Starting on 18th Feb. 2021 in version 1.1.101 we store the
// messageId in the inner message.
if (this.currentMessage.enc_format == ENC_FORMAT_DECRYPTED) {
// Remove this code soon: Begin >>>>>
if (message.id) this.currentMessage.id = message.id;
// Only use original in_reply_to if decrypted (inner) message has none.
@ -681,6 +682,7 @@ class pEpForThunderbird extends pEp {
(typeof this.currentMessage.references !== "object" || this.currentMessage.references.length == 0)) {
this.currentMessage.references = message.references;
}
// Remove this code soon: End <<<<<
// Append decryption details to internet headers in original opt_fields.
if (message.opt_fields) {

@ -42,7 +42,8 @@ MimeEncrypt.prototype = {
bccRecipients: null,
replyToRecipients: null,
originalSubject: null,
originalReferences: null,
references: null,
messageId: null,
isDraftOrTemplate: false,
passThrough: false,
@ -54,16 +55,23 @@ MimeEncrypt.prototype = {
outBuffer: "",
// nsIMsgComposeSecure interface
requiresCryptoEncapsulation() {
requiresCryptoEncapsulation(msgIdentity, msgCompFields) {
// Only if our handler was registered in pepmessengercompose.js,
// we get here and we require encryption.
// Note that if `msgCompFields.subject` is set here, it will affect the
// subject in the message that is sent, but that is too early for us.
// Setting it any later has no effect.
// So we set the subject even earlier in pepmessengercompose.js.
return true;
},
beginCryptoEncapsulation(outStream, recipientList, compFields, msgIdentity, sendReport, isDraft) {
beginCryptoEncapsulation(outStream, recipientList, msgCompFields, msgIdentity, sendReport, isDraft) {
// Note that `isDraft` is false when saving as a template, so this is not useful.
this.outStream = outStream;
this.outStringStream = Cc["@mozilla.org/io/string-input-stream;1"].createInstance(Ci.nsIStringInputStream);
this.inspector = Cc["@mozilla.org/jsinspector;1"].createInstance(Ci.nsIJSInspector);
this.references = msgCompFields.references;
this.messageId = msgCompFields.messageId;
return null;
},
@ -110,14 +118,15 @@ MimeEncrypt.prototype = {
let message = this.controller.synchronise(messagePromise);
// Fill in some headers.
message.id = this.messageId.replace(/^<(.*)>$/, "$1");
message.shortmsg = this.originalSubject;
message.from = this.fromSender;
message.to = this.toRecipients;
message.cc = this.ccRecipients;
message.bcc = this.bccRecipients;
message.reply_to = this.replyToRecipients;
if (this.originalReferences) {
message.references = this.originalReferences.split(" ").map((r) => r.replace(/^<(.*)>$/, "$1"));
if (this.references) {
message.references = this.references.split(" ").map((r) => r.replace(/^<(.*)>$/, "$1"));
message.in_reply_to = [message.references[message.references.length - 1]];
}

@ -537,8 +537,7 @@ var pEpComposer = {
this.getAddresses(this.win.gCurrentIdentity, compFields);
compSec.isDraftOrTemplate = isDraftOrTemplate;
compSec.originalSubject = compFields.subject;
// Note that `compFields.messageId` is empty at this point in time.
compSec.originalReferences = compFields.references;
// We deal with messageId and references in pEpMimeEncrypt.js.
compFields.composeSecure = compSec;
// This is a hack. We tell the engine whether we want protected subjects,

Loading…
Cancel
Save