Bug 1468079 - Port relevant parts of [Bug 1411592 - prevent remote content for encrypted S/MIME messages] to SeaMonkey. r=IanN a=IanN DONTBUILD
authorFrank-Rainer Grahl <frgrahl@gmx.net>
Mon, 02 Jul 2018 17:02:00 +0200
changeset 28252 741187f6a790554ccbd7af6d9d1baa31572de357
parent 28249 2fa8e07e4394de761c145112825f1f771cb99e36
child 28253 251973ed8f779f930137a4b7195471e8a70db53c
push id2090
push userfrgrahl@gmx.net
push dateMon, 02 Jul 2018 15:03:07 +0000
treeherdercomm-esr52@741187f6a790 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersIanN, IanN
bugs1468079, 1411592
Bug 1468079 - Port relevant parts of [Bug 1411592 - prevent remote content for encrypted S/MIME messages] to SeaMonkey. r=IanN a=IanN DONTBUILD
mailnews/extensions/smime/content/msgHdrViewSMIMEOverlay.js
suite/mailnews/mailWindowOverlay.js
suite/mailnews/msgHdrViewOverlay.js
--- a/mailnews/extensions/smime/content/msgHdrViewSMIMEOverlay.js
+++ b/mailnews/extensions/smime/content/msgHdrViewSMIMEOverlay.js
@@ -15,16 +15,27 @@ var gMyLastEncryptedURI = null;
 
 var gSMIMEBundle = null;
 // var gBrandBundle; -- defined in mailWindow.js
 
 // manipulates some globals from msgReadSMIMEOverlay.js
 
 var nsICMSMessageErrors = Components.interfaces.nsICMSMessageErrors;
 
+/// Get the necko URL for the message URI.
+function neckoURLForMessageURI(aMessageURI)
+{
+  let msgSvc = Components.classes["@mozilla.org/messenger;1"]
+    .createInstance(Components.interfaces.nsIMessenger)
+    .messageServiceFromURI(aMessageURI);
+  let neckoURI = {};
+  msgSvc.GetUrlForUri(aMessageURI, neckoURI, null);
+  return neckoURI.value.spec;
+}
+
 var smimeHeaderSink = 
 { 
   maxWantedNesting: function()
   {
     return 1;
   },
 
   signedStatus: function(aNestingLevel, aSignatureStatus, aSignerCert)
@@ -87,18 +98,21 @@ var smimeHeaderSink =
     else
     {
       gEncryptedUINode.setAttribute("encrypted", "notok");
       gStatusBar.setAttribute("encrypted", "notok");
     }
     
     if (gEncryptedURIService)
     {
+      // Remember the message URI and the corresponding necko URI.
       gMyLastEncryptedURI = GetLoadedMessage();
       gEncryptedURIService.rememberEncrypted(gMyLastEncryptedURI);
+      gEncryptedURIService.rememberEncrypted(
+        neckoURLForMessageURI(gMyLastEncryptedURI));
     }
 
     switch (aEncryptionStatus)
     {
       case nsICMSMessageErrors.SUCCESS:
       case nsICMSMessageErrors.ENCRYPT_INCOMPLETE:
         break;
       default:
@@ -128,16 +142,18 @@ var smimeHeaderSink =
   }
 };
 
 function forgetEncryptedURI()
 {
   if (gMyLastEncryptedURI && gEncryptedURIService)
   {
     gEncryptedURIService.forgetEncrypted(gMyLastEncryptedURI);
+    gEncryptedURIService.forgetEncrypted(
+      neckoURLForMessageURI(gMyLastEncryptedURI));
     gMyLastEncryptedURI = null;
   }
 }
 
 function onSMIMEStartHeaders()
 {
   gEncryptionStatus = -1;
   gSignatureStatus = -1;
--- a/suite/mailnews/mailWindowOverlay.js
+++ b/suite/mailnews/mailWindowOverlay.js
@@ -2600,17 +2600,17 @@ var gMessageNotificationBar =
           null, this.mMsgNotificationBar.PRIORITY_WARNING_HIGH, buttons);
         this.mMsgNotificationBar.collapsed = false;
       }
     }
   },
 
   remoteOrigins: null,
 
-  setRemoteContentMsg: function(aMsgHdr, aContentURI)
+  setRemoteContentMsg: function(aMsgHdr, aContentURI, aCanOverride)
   {
     // remoteOrigins is a Set of all blockable Origins.
     if (!this.remoteOrigins)
       this.remoteOrigins = new Set();
 
     var origin = aContentURI.spec;
     try
     {
@@ -2640,17 +2640,17 @@ var gMessageNotificationBar =
       popup: "remoteContentOptions"
     }];
 
     this.mMsgNotificationBar
         .appendNotification(remoteContentMsg,
                             "remoteContent",
                             null,
                             this.mMsgNotificationBar.PRIORITY_WARNING_MEDIUM,
-                            buttons);
+                            (aCanOverride ? buttons : []));
   },
 
   // aUrl is the nsIURI for the message currently loaded in the message pane
   setPhishingMsg: function(aUrl)
   {
     // if we've explicitly marked this message as not being an email scam, then don't
     // bother checking it with the phishing detector.
     var phishingMsg = false;
--- a/suite/mailnews/msgHdrViewOverlay.js
+++ b/suite/mailnews/msgHdrViewOverlay.js
@@ -613,19 +613,19 @@ var messageHeaderSink = {
       OnMsgParsed(url);
     },
 
     onEndMsgHeaders: function(url)
     {
       OnMsgLoaded(url);
     },
 
-    onMsgHasRemoteContent: function(aMsgHdr, aContentURI)
+    onMsgHasRemoteContent: function(aMsgHdr, aContentURI, aCanOverride)
     {
-      gMessageNotificationBar.setRemoteContentMsg(aMsgHdr, aContentURI);
+      gMessageNotificationBar.setRemoteContentMsg(aMsgHdr, aContentURI, aCanOverride);
     },
 
     mSecurityInfo  : null,
     mSaveHdr: null,
     get securityInfo()
     {
       return this.mSecurityInfo;
     },