Bug 1695590 - openpgp alias: prevent sending if alias file was malformed, don't send unencrypted. r=kaie
authorMagnus Melin <mkmelin+mozilla@iki.fi>
Wed, 03 Mar 2021 12:54:02 +0200
changeset 31832 7ce196669f1c3f7fb900e93cfccc606ccb343546
parent 31831 ff6b83994b9ae81cd3dd01cb780165fad13768c3
child 31833 bebb326ced3f17237d5c184ad4740eabf7f4c96f
push id18523
push usermkmelin@iki.fi
push dateWed, 03 Mar 2021 10:59:08 +0000
treeherdercomm-central@d753b6013e03 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskaie
bugs1695590
Bug 1695590 - openpgp alias: prevent sending if alias file was malformed, don't send unencrypted. r=kaie
mail/components/compose/content/MsgComposeCommands.js
mail/extensions/openpgp/content/modules/cryptoAPI/interface.js
mail/extensions/openpgp/content/ui/enigmailMsgComposeOverlay.js
--- a/mail/components/compose/content/MsgComposeCommands.js
+++ b/mail/components/compose/content/MsgComposeCommands.js
@@ -4737,17 +4737,20 @@ async function CompleteGenericSendMessag
     // compose-send-message event for listeners, so they can do
     // any pre-security work before sending.
     var event = document.createEvent("UIEvents");
     event.initEvent("compose-send-message", false, true);
     var msgcomposeWindow = document.getElementById("msgcomposeWindow");
     msgcomposeWindow.setAttribute("msgtype", msgType);
     msgcomposeWindow.dispatchEvent(event);
     if (event.defaultPrevented) {
-      throw Components.Exception("", Cr.NS_ERROR_ABORT);
+      throw Components.Exception(
+        "compose-send-message prevented",
+        Cr.NS_ERROR_ABORT
+      );
     }
 
     gAutoSaving = msgType == Ci.nsIMsgCompDeliverMode.AutoSaveAsDraft;
 
     // disable the ui if we're not auto-saving
     if (!gAutoSaving) {
       ToggleWindowLock(true);
     } else {
--- a/mail/extensions/openpgp/content/modules/cryptoAPI/interface.js
+++ b/mail/extensions/openpgp/content/modules/cryptoAPI/interface.js
@@ -39,16 +39,21 @@ class CryptoAPI {
     let res = null;
     promise
       .then(gotResult => {
         res = gotResult;
         inspector.exitNestedEventLoop();
       })
       .catch(gotResult => {
         console.log("CryptoAPI.sync() failed result: %o", gotResult);
+        if (gotResult instanceof Error) {
+          inspector.exitNestedEventLoop();
+          throw gotResult;
+        }
+
         res = gotResult;
         inspector.exitNestedEventLoop();
       });
 
     inspector.enterNestedEventLoop(0);
     return res;
   }
 
--- a/mail/extensions/openpgp/content/ui/enigmailMsgComposeOverlay.js
+++ b/mail/extensions/openpgp/content/ui/enigmailMsgComposeOverlay.js
@@ -2611,29 +2611,30 @@ Enigmail.msg = {
         sendMsgType == Ci.nsIMsgCompDeliverMode.AutoSaveAsDraft
       )
     ) {
       this.sendProcess = true;
       //let bc = document.getElementById("enigmail-bc-sendprocess");
 
       try {
         this.modifyCompFields();
-        //bc.setAttribute("disabled", "true");
 
         const cApi = EnigmailCryptoAPI();
         let encryptResult = cApi.sync(this.prepareSendMsg(sendMsgType));
         if (!encryptResult) {
           this.resetUpdatedFields();
           event.preventDefault();
           event.stopPropagation();
         }
       } catch (ex) {
-        console.debug(ex);
+        Cu.reportError("GenericSendMessage FAILED: " + ex);
+        this.resetUpdatedFields();
+        event.preventDefault();
+        event.stopPropagation();
       }
-      //bc.removeAttribute("disabled");
     } else {
       EnigmailLog.DEBUG(
         "enigmailMsgComposeOverlay.js: Enigmail.msg.sendMessageListener: sending in progress - autosave aborted\n"
       );
       event.preventDefault();
       event.stopPropagation();
     }
     this.sendProcess = false;