Bug 1462910 - Prevent form submits by sandboxing. r=BenB,jorgk a=jorgk
authorMagnus Melin <mkmelin+mozilla@iki.fi>
Mon, 28 May 2018 23:12:50 +0300
changeset 28244 01b9a646acb304b209b781563b0aca92888832b5
parent 28243 2f0222c3f952d52997e0c94d0262b2b430d399be
child 28245 ff574714a516cb92ca6dc5fae061a905fc115a40
push id2087
push usermozilla@jorgk.com
push dateFri, 29 Jun 2018 15:47:48 +0000
treeherdercomm-esr52@3d3f118c29a2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersBenB, jorgk, jorgk
bugs1462910
Bug 1462910 - Prevent form submits by sandboxing. r=BenB,jorgk a=jorgk
mailnews/base/src/nsMsgContentPolicy.cpp
--- a/mailnews/base/src/nsMsgContentPolicy.cpp
+++ b/mailnews/base/src/nsMsgContentPolicy.cpp
@@ -22,16 +22,17 @@
 #include "nsContentPolicyUtils.h"
 #include "nsIDOMHTMLImageElement.h"
 #include "nsIFrameLoader.h"
 #include "nsIWebProgress.h"
 #include "nsMsgUtils.h"
 #include "nsThreadUtils.h"
 #include "mozilla/mailnews/MimeHeaderParser.h"
 #include "nsINntpUrl.h"
+#include "nsSandboxFlags.h"
 
 static const char kBlockRemoteImages[] = "mailnews.message_display.disable_remote_image";
 static const char kAllowPlugins[] = "mailnews.message_display.allow_plugins";
 static const char kTrustedDomains[] =  "mail.trusteddomains";
 
 using namespace mozilla::mailnews;
 
 // Per message headder flags to keep track of whether the user is allowing remote
@@ -844,16 +845,23 @@ nsresult nsMsgContentPolicy::SetDisableI
   if (!isAllowedContent) {
     // Disable JavaScript on message URLs.
     rv = docShell->SetAllowJavascript(false);
     NS_ENSURE_SUCCESS(rv, rv);
     rv = docShell->SetAllowContentRetargetingOnChildren(false);
     NS_ENSURE_SUCCESS(rv, rv);
     rv = docShell->SetAllowPlugins(mAllowPlugins);
     NS_ENSURE_SUCCESS(rv, rv);
+
+    uint32_t sandboxFlags;
+    rv = docShell->GetSandboxFlags(&sandboxFlags);
+    sandboxFlags |= SANDBOXED_FORMS;
+    NS_ENSURE_SUCCESS(rv, rv);
+    rv = docShell->SetSandboxFlags(sandboxFlags);
+    NS_ENSURE_SUCCESS(rv, rv);
   }
   else {
     // JavaScript and plugins are allowed on non-message URLs.
     rv = docShell->SetAllowJavascript(true);
     NS_ENSURE_SUCCESS(rv, rv);
     rv = docShell->SetAllowContentRetargetingOnChildren(true);
     NS_ENSURE_SUCCESS(rv, rv);
     rv = docShell->SetAllowPlugins(true);