]> granicus.if.org Git - curl/commitdiff
proxy: reject attempts to use unsupported proxy schemes
authorDaniel Stenberg <daniel@haxx.se>
Mon, 15 Aug 2016 08:46:27 +0000 (10:46 +0200)
committerDaniel Stenberg <daniel@haxx.se>
Mon, 15 Aug 2016 08:46:27 +0000 (10:46 +0200)
I discovered some people have been using "https://example.com" style
strings as proxy and it "works" (curl doesn't complain) because curl
ignores unknown schemes and then assumes plain HTTP instead.

I think this misleads users into believing curl uses HTTPS to proxies
when it doesn't. Now curl rejects proxy strings using unsupported
schemes instead of just ignoring and defaulting to HTTP.

lib/url.c

index bda3ccddbb155385ec02a52c5eeced9846b9459c..153a05492cc5ce730ed8b6885cd547aa3d59768d 100644 (file)
--- a/lib/url.c
+++ b/lib/url.c
@@ -4706,7 +4706,13 @@ static CURLcode parse_proxy(struct Curl_easy *data,
       conn->proxytype = CURLPROXY_SOCKS4A;
     else if(checkprefix("socks4", proxy) || checkprefix("socks", proxy))
       conn->proxytype = CURLPROXY_SOCKS4;
-    /* Any other xxx:// : change to http proxy */
+    else if(checkprefix("http:", proxy))
+      ; /* leave it as HTTP or HTTP/1.0 */
+    else {
+      /* Any other xxx:// reject! */
+      failf(data, "No support for proxy over the \'%s\' scheme", proxy);
+      return CURLE_COULDNT_CONNECT;
+    }
   }
   else
     proxyptr = proxy; /* No xxx:// head: It's a HTTP proxy */