]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
curl -J: make it work even without http:// scheme on URL
authorJay Satiro <raysatiro@yahoo.com>
Fri, 29 Apr 2016 13:24:10 +0000 (15:24 +0200)
committerDaniel Stenberg <daniel@haxx.se>
Fri, 29 Apr 2016 13:24:10 +0000 (15:24 +0200)
It does open up a miniscule risk that one of the other protocols that
libcurl could use would send back a Content-Disposition header and then
curl would act on it even if not HTTP.

A future mitigation for this risk would be to allow the callback to ask
libcurl which protocol is being used.

Verified with test 1312

Closes #760

src/tool_operate.c
tests/data/test1312

index 99996e142acbcaaea84a9e872a087160f0449843..ab29c00b31ae9d818236ca1e020ab875c681806a 100644 (file)
@@ -1297,7 +1297,10 @@ static CURLcode operate_do(struct GlobalConfig *global,
         if(config->content_disposition
            && (urlnode->flags & GETOUT_USEREMOTE)
            && (checkprefix("http://", this_url) ||
-               checkprefix("https://", this_url)))
+               checkprefix("https://", this_url) ||
+               (!strstr(this_url, "://") &&
+                (!config->proto_default ||
+                 checkprefix("http", config->proto_default)))))
           hdrcbdata.honor_cd_filename = TRUE;
         else
           hdrcbdata.honor_cd_filename = FALSE;
index 92144015a337e2e099c45faafc7160aca5a387fa..bed492c16d705c4d7f110e9deca6626d33fc49ee 100644 (file)
@@ -40,7 +40,7 @@ HTTP GET with -J, Content-Disposition and ; in filename
 CURL_TESTDIR=%PWD/log
 </setenv>
 <command option="no-output,no-include">
-http://%HOSTIP:%HTTPPORT/1312 -J -O
+%HOSTIP:%HTTPPORT/1312 -J -O
 </command>
 </client>