Bug 966807 - Add an extra parameter to the streaming url for decryption in MsgHdrToMimeMessage r=asuth
authorJonathan Protzenko <jonathan.protzenko@gmail.com>
Sun, 23 Feb 2014 19:24:08 +0100
changeset 17606 ea36dee52123e2b235ff9174910357511a17a6d9
parent 17605 51589d434f0e0e5cec8b0a3100708170fb6f386e
child 17607 6e585f3aa13801cee18a99982c1a78506e04ee59
push id1175
push usermbanner@mozilla.com
push dateTue, 18 Mar 2014 08:37:15 +0000
treeherdercomm-aurora@3b5242ee031a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersasuth
bugs966807
Bug 966807 - Add an extra parameter to the streaming url for decryption in MsgHdrToMimeMessage r=asuth This improves the interaction between the latest versions of Enigmail and the MsgHdrToMimeMessage infrastructure.
mailnews/db/gloda/modules/mimemsg.js
--- a/mailnews/db/gloda/modules/mimemsg.js
+++ b/mailnews/db/gloda/modules/mimemsg.js
@@ -183,19 +183,29 @@ function MsgHdrToMimeMessage(aMsgHdr, aC
 
   let msgURI = aMsgHdr.folder.getUriForMsg(aMsgHdr);
   let msgService = gMessenger.messageServiceFromURI(msgURI);
 
   MsgHdrToMimeMessage.OPTION_TUNNEL = aOptions;
   let partsOnDemandStr = (aOptions && aOptions.partsOnDemand)
     ? "&fetchCompleteMessage=false"
     : "";
+  // By default, Enigmail only decrypts a message streamed via libmime if it's
+  // the one currently on display in the message reader. With this option, we're
+  // letting Enigmail know that it should decrypt the message since the client
+  // explicitly asked for it.
+  let encryptedStr = (aOptions && aOptions.examineEncryptedParts)
+    ? "&examineEncryptedParts=true"
+    : "";
 
-  // So unless the user explictly required that he wants to examine encrypted
-  // parts, give him a stripped-down version of the MimeMsg structure.
+  // S/MIME, our other encryption backend, is not that smart, and always
+  // decrypts data. In order to protect sensitive data (e.g. not index it in
+  // Gloda), unless the client asked for encrypted data, we pass to the client
+  // callback a stripped-down version of the MIME structure where encrypted
+  // parts have been removed.
   let wrapCallback = function (aCallback, aCallbackThis) {
     if (aOptions && aOptions.examineEncryptedParts)
       return aCallback;
     else
       return (function (aMsgHdr, aMimeMsg)
         aCallback.call(aCallbackThis, aMsgHdr, stripEncryptedParts(aMimeMsg))
       );
   };
@@ -222,17 +232,17 @@ function MsgHdrToMimeMessage(aMsgHdr, aC
   try {
     let streamURI = msgService.streamMessage(
       msgURI,
       streamListener, // consumer
       null, // nsIMsgWindow
       dumbUrlListener, // nsIUrlListener
       true, // have them create the converter
       // additional uri payload, note that "header=" is prepended automatically
-      "filter&emitter=js"+partsOnDemandStr,
+      "filter&emitter=js"+partsOnDemandStr+encryptedStr,
       requireOffline);
   } catch (ex) {
     // If streamMessage throws an exception, we should make sure to clear the
     // activeStreamListener, or any subsequent attempt at sreaming this URI
     // will silently fail
     if (activeStreamListeners[msgURI]) {
       delete activeStreamListeners[msgURI];
     }