From ee63982defe4f153e0ebc0a7756f3aeccd47e9d0 Mon Sep 17 00:00:00 2001 From: roytam1 Date: Thu, 15 Nov 2018 22:09:09 +0800 Subject: [PATCH] allow accessing non-standard port of gopher by toggling network.gopher.port-restricted to false (default: true) --- modules/libpref/src/init/all.js | 3 +++ netwerk/protocol/gopher/src/nsGopherChannel.cpp | 16 ++++++++++++---- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/modules/libpref/src/init/all.js b/modules/libpref/src/init/all.js index 03179400..683f7de8 100644 --- a/modules/libpref/src/init/all.js +++ b/modules/libpref/src/init/all.js @@ -2390,3 +2390,6 @@ pref("print.print_command", "lp -c -s ${MOZ_PRINTER_NAME:+'-d '}${MOZ_PRINTER_NA #ifdef MOZ_X11 pref("network.gnomevfs.supported-protocols", "smb:,sftp:"); #endif + +// restrict gopher port to port 70 only +pref("network.gopher.port-restricted", true); diff --git a/netwerk/protocol/gopher/src/nsGopherChannel.cpp b/netwerk/protocol/gopher/src/nsGopherChannel.cpp index c286cd97..8196b235 100644 --- a/netwerk/protocol/gopher/src/nsGopherChannel.cpp +++ b/netwerk/protocol/gopher/src/nsGopherChannel.cpp @@ -122,13 +122,21 @@ nsGopherChannel::Init(nsIURI* uri, nsIProxyInfo* proxyInfo) if (NS_FAILED(rv)) return rv; + PRBool restrictedPort = PR_TRUE; + nsCOMPtr branch; + nsCOMPtr prefs = do_GetService("@mozilla.org/preferences-service;1", &rv); + if (!NS_FAILED(rv)) { + branch = do_QueryInterface(prefs); + + branch->GetBoolPref("network.gopher.port-restricted" , &restrictedPort); + } // For security reasons, don't allow anything expect the default // gopher port (70). See bug 71916 - bbaetz@cs.mcgill.ca -/* - if (mPort==-1) + if(!restrictedPort) { + if (mPort==-1) + mPort=GOPHER_PORT; + } else mPort=GOPHER_PORT; -*/ - mPort=GOPHER_PORT; // No path given if (buffer[0]=='\0' || (buffer[0]=='/' && buffer[1]=='\0')) {