Bug 1625259 - Initial enigmail fixes to ensure Thunderbird tests still pass. r=PatrickBrunschwig
authorKai Engert <kaie@kuix.de>
Thu, 26 Mar 2020 23:30:29 +0100
changeset 38595 aa309221cbea6c1f00a33c77491bdc82a92b6fc9
parent 38594 56477e02fb08d276e0347bbc4d2ad4d19d82d5f3
child 38596 9e8aed12d503873433ce4b5ef9f3f013e7dd6636
push id400
push userclokep@gmail.com
push dateMon, 04 May 2020 18:56:09 +0000
reviewersPatrickBrunschwig
bugs1625259
Bug 1625259 - Initial enigmail fixes to ensure Thunderbird tests still pass. r=PatrickBrunschwig Differential Revision: https://phabricator.services.mozilla.com/D68567
mail/extensions/am-e2e/prefs/e2e-prefs.js
mail/extensions/openpgp/content/modules/encryption.jsm
mail/extensions/openpgp/content/modules/rnp.jsm
mail/extensions/openpgp/content/ui/enigmailMsgComposeOverlay.js
mail/extensions/openpgp/skin/tb-linux/enigmail-common.css
--- a/mail/extensions/am-e2e/prefs/e2e-prefs.js
+++ b/mail/extensions/am-e2e/prefs/e2e-prefs.js
@@ -251,18 +251,18 @@ pref("temp.openpgp.enableExperiments", f
    settings
 */
 
 pref("mail.identity.default.defaultSigningPolicy", 0);
 pref("mail.identity.default.defaultEncryptionPolicy", 0);
 pref("mail.identity.default.openPgpUrlName", "");
 pref("mail.identity.default.pgpMimeMode", true);
 pref("mail.identity.default.attachPgpKey", false);
-pref("mail.identity.default.autoEncryptDrafts", true);
-pref("mail.identity.default.protectSubject", true);
+pref("mail.identity.default.autoEncryptDrafts", false);
+pref("mail.identity.default.protectSubject", false);
 pref("mail.identity.default.warnWeakReply", false);
 
 // prefer S/MIME or PGP/MIME (0: S/MIME, 1: PGP/MIME)
 pref("mail.identity.default.mimePreferOpenPGP", 1);
 
 /*
    Other settings (change Mozilla behaviour)
 */
--- a/mail/extensions/openpgp/content/modules/encryption.jsm
+++ b/mail/extensions/openpgp/content/modules/encryption.jsm
@@ -523,17 +523,19 @@ var EnigmailEncryption = {
       cApi.encryptAndOrSign(
         listener.getInputForEncryption(),
         encryptArgs,
         resultStatus
       )
     );
     console.debug(`encryptAndOrSign returned: ${encrypted}`);
 
-    listener.addEncryptedOutput(encrypted);
+    if (encrypted) {
+      listener.addEncryptedOutput(encrypted);
+    }
 
     if (pgpMime && errorMsgObj.value) {
       EnigmailDialog.alert(win, errorMsgObj.value);
     }
 
     listener.done(resultStatus.exitCode);
 
     //return proc;
--- a/mail/extensions/openpgp/content/modules/rnp.jsm
+++ b/mail/extensions/openpgp/content/modules/rnp.jsm
@@ -1028,17 +1028,17 @@ var RNP = {
       }
 
       key = new RNPLib.rnp_key_handle_t();
       if (RNPLib.rnp_locate_key(ffi, type, id, key.address())) {
         throw new Error("rnp_locate_key failed, " + type + ", " + id);
       }
     }
 
-    if (key.isNull()) {
+    if (!key || key.isNull()) {
       console.debug("getKeyHandleByIdentifier nothing found");
     } else {
       console.debug("getKeyHandleByIdentifier found!");
       let is_subkey = new ctypes.bool();
       let res = RNPLib.rnp_key_is_sub(key, is_subkey.address());
       if (res) {
         throw new Error("rnp_key_is_sub failed: " + res);
       }
@@ -1239,17 +1239,17 @@ var RNP = {
         }
       }
       RNPLib.rnp_key_handle_destroy(senderKey);
     }
 
     if (args.encrypt) {
       for (let id in args.to) {
         let toKey = this.getKeyHandleByIdentifier(RNPLib.ffi, args.to[id]);
-        if (toKey.isNull()) {
+        if (!toKey || toKey.isNull()) {
           resultStatus.statusFlags |= EnigmailConstants.INVALID_RECIPIENT;
           return null;
         }
         this.addSuitableEncryptKey(toKey, op);
         RNPLib.rnp_key_handle_destroy(toKey);
       }
 
       for (let id in args.bcc) {
--- a/mail/extensions/openpgp/content/ui/enigmailMsgComposeOverlay.js
+++ b/mail/extensions/openpgp/content/ui/enigmailMsgComposeOverlay.js
@@ -2047,17 +2047,19 @@ Enigmail.msg = {
     if (!doEncrypt) {
       EnigmailLog.DEBUG("enigmailMsgComposeOverlay.js: drafts disabled\n");
 
       try {
         let p = Enigmail.msg.getSecurityParams();
         if (EnigmailMimeEncrypt.isEnigmailCompField(p)) {
           p.wrappedJSObject.sendFlags = 0;
         }
-      } catch (ex) {}
+      } catch (ex) {
+        console.debug(ex);
+      }
 
       return true;
     }
 
     let sendFlags =
       EnigmailConstants.SEND_PGP_MIME |
       EnigmailConstants.SEND_ENCRYPTED |
       EnigmailConstants.SAVE_MESSAGE |
@@ -2168,68 +2170,16 @@ Enigmail.msg = {
 
     if (!newSecurityInfo) {
       throw Cr.NS_ERROR_FAILURE;
     }
 
     Enigmail.msg.setSecurityParams(newSecurityInfo);
   },
 
-  compileFromAndTo() {
-    EnigmailLog.DEBUG(
-      "enigmailMsgComposeOverlay.js: Enigmail.msg.compileFromAndTo\n"
-    );
-    let compFields = gMsgCompose.compFields;
-    let toAddrList = [];
-
-    if (!Enigmail.msg.composeBodyReady) {
-      compFields = Cc[
-        "@mozilla.org/messengercompose/composefields;1"
-      ].createInstance(Ci.nsIMsgCompFields);
-    }
-    Recipients2CompFields(compFields);
-    gMsgCompose.expandMailingLists();
-
-    EnigmailLog.DEBUG(
-      "enigmailMsgComposeOverlay.js: to='" + compFields.to + "'\n"
-    );
-    if (compFields.to.length > 0) {
-      toAddrList = EnigmailFuncs.parseEmails(compFields.to, false);
-    }
-
-    if (compFields.cc.length > 0) {
-      toAddrList = toAddrList.concat(
-        EnigmailFuncs.parseEmails(compFields.cc, false)
-      );
-    }
-
-    if (compFields.bcc.length > 0) {
-      toAddrList = toAddrList.concat(
-        EnigmailFuncs.parseEmails(compFields.bcc, false)
-      );
-    }
-
-    for (let addr of toAddrList) {
-      // determine incomplete addresses --> do not attempt pEp encryption
-      if (addr.email.search(/.@./) < 0) {
-        return null;
-      }
-    }
-
-    this.identity = getCurrentIdentity();
-    let from = {
-      email: this.identity.email,
-      name: this.identity.fullName,
-    };
-    return {
-      from,
-      toAddrList,
-    };
-  },
-
   /*
   sendSmimeEncrypted: function(msgSendType, sendFlags, isOffline) {
     let recList;
     let toAddrList = [];
     let arrLen = {};
     const DeliverMode = Ci.nsIMsgCompDeliverMode;
 
     switch (msgSendType) {
@@ -3991,16 +3941,17 @@ Enigmail.msg = {
     }
   },
 
   /**
    * Determine if all addressees have a valid key ID; if not, attempt to
    * import them via WKD or Autocrypt.
    */
   async findMissingKeys() {
+    /*
     try {
       EnigmailLog.DEBUG("enigmailMsgComposeOverlay.js: findMissingKeys()\n");
 
       let missingKeys = this.determineSendFlags();
 
       if ("errArray" in missingKeys && missingKeys.errArray.length > 0) {
         let missingEmails = missingKeys.errArray.map(function(i) {
           return i.addr.toLowerCase().trim();
@@ -4015,25 +3966,23 @@ Enigmail.msg = {
             this.keyLookupDone.push(k);
           }
         }
 
         if (lookupList.length > 0) {
           try {
             let foundKeys;
 
-            /*
             if (this.isAutocryptEnabled()) {
               foundKeys = await EnigmailAutocrypt.importAutocryptKeys(lookupList, this.encryptForced === EnigmailConstants.ENIG_ALWAYS);
               EnigmailLog.DEBUG("enigmailMsgComposeOverlay.js: findMissingKeys: got " + foundKeys.length + " autocrypt keys\n");
               if (foundKeys.length > 0) {
                 this.determineSendFlags();
               }
             }
-            */
 
             if (EnigmailPrefs.getPref("autoWkdLookup") === 0) {
               return;
             }
 
             // old buggy: if autocrypt is disabled, foundKeys is still undefined
             // if (foundKeys.length >= lookupList.length) return;
 
@@ -4051,16 +4000,17 @@ Enigmail.msg = {
               "enigmailMsgComposeOverlay.js: findMissingKeys: error " +
                 err +
                 "\n"
             );
           }
         }
       }
     } catch (ex) {}
+    */
   },
 };
 
 Enigmail.composeStateListener = {
   NotifyComposeFieldsReady() {
     // Note: NotifyComposeFieldsReady is only called when a new window is created (i.e. not in case a window object is reused).
     EnigmailLog.DEBUG(
       "enigmailMsgComposeOverlay.js: ECSL.NotifyComposeFieldsReady\n"
--- a/mail/extensions/openpgp/skin/tb-linux/enigmail-common.css
+++ b/mail/extensions/openpgp/skin/tb-linux/enigmail-common.css
@@ -196,17 +196,17 @@
 }
 
 .enigmailMessagePane {
   margin: 6px;
   -moz-user-focus: normal;
   -moz-user-select: text;
   cursor: text !important;
   white-space: pre-wrap;
-  unicode-bidi: -moz-plaintext;
+  unicode-bidi: plaintext;
 }
 
 /***************************************************
  *  Various other styles
  ***************************************************/
 
 .enigmailDialogTitle {
   font-size: 120%;
@@ -214,17 +214,17 @@
   padding-bottom: 6px;
 }
 
 .enigmailDialogBody {
   -moz-user-focus: normal;
   -moz-user-select: text;
   cursor: text !important;
   white-space: pre-wrap;
-  unicode-bidi: -moz-plaintext;
+  unicode-bidi: plaintext;
 }
 
 .enigmailDialogInfoBox {
   border: 1px solid #afafaf;
   border-radius: 5px;
   padding: 15px;
   margin: 0px 10px 0px 10px;
 }
@@ -333,28 +333,16 @@ They can be applied using:
 treechildren::-moz-tree-cell(STYLE) {}
 treechildren::-moz-tree-cell-text(STYLE) {}
 */
 
 /******************************
  *  Rules for filter actions
  ******************************/
 
-.ruleactiontarget[type="enigmail@enigmail.net#filterActionMoveDecrypt"] {
-  -moz-binding: url("chrome://messenger/content/searchWidgets.xml#ruleactiontarget-folder") !important;
-}
-
-.ruleactiontarget[type="enigmail@enigmail.net#filterActionCopyDecrypt"] {
-  -moz-binding: url("chrome://messenger/content/searchWidgets.xml#ruleactiontarget-folder") !important;
-}
-
-.ruleactiontarget[type="enigmail@enigmail.net#filterActionEncrypt"] {
-  -moz-binding: url("chrome://messenger/content/searchWidgets.xml#ruleactiontarget-forwardto") !important;
-}
-
 .enigmailPassphraseQuality {
   margin: 2px 4px;
   min-width: 128px;
   height: 12px;
   background-color: #C21540;
 }
 
 .enigmailPassphraseQuality[value="medium"] {