Bug 1540065 - Guard about:config access with 'general.aboutConfig.enable' pref r=Ehsan
authorJames Willcox <snorp@snorp.net>
Wed, 18 Sep 2019 15:25:35 +0000
changeset 493826 82c4e08d98907a2dfee21b41b80d53ab81095bd1
parent 493825 2b4d285d8caa26da661d3100c9f9db8a19ea3dc7
child 493827 6736ed7f58054ef2add4c0339603903e5bce07e1
push id36589
push usernerli@mozilla.com
push dateWed, 18 Sep 2019 21:49:27 +0000
treeherdermozilla-central@21aff209f5a9 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersEhsan
bugs1540065
milestone71.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1540065 - Guard about:config access with 'general.aboutConfig.enable' pref r=Ehsan Differential Revision: https://phabricator.services.mozilla.com/D36608
docshell/base/nsAboutRedirector.cpp
modules/libpref/init/StaticPrefList.yaml
--- a/docshell/base/nsAboutRedirector.cpp
+++ b/docshell/base/nsAboutRedirector.cpp
@@ -5,24 +5,19 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "nsAboutRedirector.h"
 #include "nsNetUtil.h"
 #include "nsAboutProtocolUtils.h"
 #include "nsBaseChannel.h"
 #include "mozilla/ArrayUtils.h"
 #include "nsIProtocolHandler.h"
+#include "mozilla/Preferences.h"
 
-#if defined(MOZ_WIDGET_ANDROID) && defined(RELEASE_OR_BETA)
-#  define ABOUT_CONFIG_BLOCKED_GV
-#endif
-
-#ifdef ABOUT_CONFIG_BLOCKED_GV
-#  include "mozilla/jni/Utils.h"  // for mozilla::jni::IsFennec()
-#endif
+#define ABOUT_CONFIG_ENABLED_PREF "general.aboutConfig.enable"
 
 NS_IMPL_ISUPPORTS(nsAboutRedirector, nsIAboutModule)
 
 struct RedirEntry {
   const char* id;
   const char* url;
   uint32_t flags;
 };
@@ -158,23 +153,20 @@ nsAboutRedirector::NewChannel(nsIURI* aU
     }
 
     nsCOMPtr<nsIChannel> channel = new CrashChannel(aURI);
     channel->SetLoadInfo(aLoadInfo);
     channel.forget(aResult);
     return NS_OK;
   }
 
-#ifdef ABOUT_CONFIG_BLOCKED_GV
-  // We don't want to allow access to about:config from
-  // GeckoView on release or beta, but it's fine for Fennec.
-  if (path.EqualsASCII("config") && !mozilla::jni::IsFennec()) {
+  if (path.EqualsASCII("config") &&
+      !mozilla::Preferences::GetBool(ABOUT_CONFIG_ENABLED_PREF, true)) {
     return NS_ERROR_NOT_AVAILABLE;
   }
-#endif
 
   for (int i = 0; i < kRedirTotal; i++) {
     if (!strcmp(path.get(), kRedirMap[i].id)) {
       nsCOMPtr<nsIChannel> tempChannel;
       nsCOMPtr<nsIURI> tempURI;
       rv = NS_NewURI(getter_AddRefs(tempURI), kRedirMap[i].url);
       NS_ENSURE_SUCCESS(rv, rv);
 
--- a/modules/libpref/init/StaticPrefList.yaml
+++ b/modules/libpref/init/StaticPrefList.yaml
@@ -2917,16 +2917,21 @@
     value: false
     mirror: always
 #endif
 
 #---------------------------------------------------------------------------
 # Prefs starting with "general."
 #---------------------------------------------------------------------------
 
+- name: general.aboutConfig.enable
+  type: bool
+  value: true
+  mirror: always
+
 - name: general.smoothScroll
   type: RelaxedAtomicBool
   value: true
   mirror: always
 
 # This pref and general.smoothScroll.stopDecelerationWeighting determine
 # the timing function.
 - name: general.smoothScroll.currentVelocityWeighting