Bug 1745751 - fix content policy. r=darktrojan
authorMagnus Melin <mkmelin+mozilla@iki.fi>
Thu, 13 Jan 2022 14:01:54 +0200
changeset 35761 24f75e70e904a8bfb8550dbbd64baf5cb1446463
parent 35760 d069bf4affa19fc3ce1b36816679b0463d846cf3
child 35762 caaad91334fc7b37c28353de7d8e2ce8e2b1aed9
push id19933
push usermkmelin@iki.fi
push dateWed, 18 May 2022 10:20:25 +0000
treeherdercomm-central@90328ce5bee2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdarktrojan
bugs1745751
Bug 1745751 - fix content policy. r=darktrojan Differential Revision: https://phabricator.services.mozilla.com/D133662
mailnews/base/src/nsMsgContentPolicy.cpp
--- a/mailnews/base/src/nsMsgContentPolicy.cpp
+++ b/mailnews/base/src/nsMsgContentPolicy.cpp
@@ -307,31 +307,25 @@ nsMsgContentPolicy::ShouldLoad(nsIURI* a
   rv = aLoadInfo->GetTargetBrowsingContext(getter_AddRefs(targetContext));
   NS_ENSURE_SUCCESS(rv, NS_OK);
 
   if (!targetContext) {
     *aDecision = nsIContentPolicy::ACCEPT;
     return NS_OK;
   }
 
+  nsCOMPtr<nsIURI> originatorLocation;
   dom::CanonicalBrowsingContext* cbc = targetContext->Canonical();
-  if (!cbc) {
-    *aDecision = nsIContentPolicy::ACCEPT;
-    return NS_OK;
+  if (cbc) {
+    dom::WindowGlobalParent* wgp = cbc->GetCurrentWindowGlobal();
+    if (wgp) {
+      originatorLocation = wgp->GetDocumentURI();
+    }
   }
-
-  dom::WindowGlobalParent* wgp = cbc->GetCurrentWindowGlobal();
-  if (!wgp) {
-    *aDecision = nsIContentPolicy::ACCEPT;
-    return NS_OK;
-  }
-
-  nsCOMPtr<nsIURI> originatorLocation = wgp->GetDocumentURI();
   if (!originatorLocation) {
-    *aDecision = nsIContentPolicy::ACCEPT;
     return NS_OK;
   }
 
 #ifdef DEBUG_MsgContentPolicy
   fprintf(stderr, "originatorLocation = %s\n",
           originatorLocation->GetSpecOrDefault().get());
 #endif