Bug 1028195 - make proxy bypass rule consistent; r?bagder draft
authorLiang-Heng Chen <xeonchen@gmail.com>
Wed, 08 Feb 2017 15:10:02 +0800
changeset 482529 dc3da298366d909016aeda9e71cd039453540fa9
parent 480238 f4f374622111022d41dd8d5eb9220624135c534a
child 545443 c2a46bdb8bbeaf852d246c5ead2d3592679b627b
push id45094
push userbmo:xeonchen@mozilla.com
push dateMon, 13 Feb 2017 03:41:57 +0000
reviewersbagder
bugs1028195
milestone54.0a1
Bug 1028195 - make proxy bypass rule consistent; r?bagder MozReview-Commit-ID: CMAUt1p3L3u
netwerk/base/nsProtocolProxyService.cpp
toolkit/system/windowsproxy/nsWindowsSystemProxySettings.cpp
--- a/netwerk/base/nsProtocolProxyService.cpp
+++ b/netwerk/base/nsProtocolProxyService.cpp
@@ -721,17 +721,19 @@ nsProtocolProxyService::CanUseProxy(nsIU
         }
         else {
             NS_WARNING("unknown address family");
             return true; // allow proxying
         }
     }
 
     // Don't use proxy for local hosts (plain hostname, no dots)
-    if (!is_ipaddr && mFilterLocalHosts && !host.Contains('.')) {
+    if ((!is_ipaddr && mFilterLocalHosts && !host.Contains('.')) ||
+        host.EqualsLiteral("127.0.0.1") ||
+        host.EqualsLiteral("::1")) {
         LOG(("Not using proxy for this local host [%s]!\n", host.get()));
         return false; // don't allow proxying
     }
 
     int32_t index = -1;
     while (++index < int32_t(mHostFiltersArray.Length())) {
         HostInfo *hinfo = mHostFiltersArray[index];
 
--- a/toolkit/system/windowsproxy/nsWindowsSystemProxySettings.cpp
+++ b/toolkit/system/windowsproxy/nsWindowsSystemProxySettings.cpp
@@ -12,16 +12,17 @@
 #include "nsISystemProxySettings.h"
 #include "nsIServiceManager.h"
 #include "mozilla/ModuleUtils.h"
 #include "nsPrintfCString.h"
 #include "nsNetCID.h"
 #include "nsISupportsPrimitives.h"
 #include "nsIURI.h"
 #include "GeckoProfiler.h"
+#include "prnetdb.h"
 #include "ProxyUtils.h"
 
 class nsWindowsSystemProxySettings final : public nsISystemProxySettings
 {
 public:
     NS_DECL_THREADSAFE_ISUPPORTS
     NS_DECL_NSISYSTEMPROXYSETTINGS
 
@@ -143,20 +144,28 @@ nsWindowsSystemProxySettings::MatchOverr
         int32_t delimiter = cbuf.FindCharInSet(" ;", start);
         if (delimiter == -1)
             delimiter = end;
 
         if (delimiter != start) {
             const nsAutoCString override(Substring(cbuf, start,
                                                    delimiter - start));
             if (override.EqualsLiteral("<local>")) {
-                // This override matches local addresses.
-                if (host.EqualsLiteral("localhost") ||
-                    host.EqualsLiteral("127.0.0.1"))
+                PRNetAddr addr;
+                bool isIpAddr = (PR_StringToNetAddr(host.get(), &addr) == PR_SUCCESS);
+
+                // Don't use proxy for local hosts (plain hostname, no dots)
+                if (!isIpAddr && !host.Contains('.')) {
                     return true;
+                }
+
+                if (host.EqualsLiteral("127.0.0.1") ||
+                    host.EqualsLiteral("::1")) {
+                    return true;
+                }
             } else if (PatternMatch(host, override)) {
                 return true;
             }
         }
 
         if (delimiter == end)
             break;
         start = ++delimiter;