aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJay Satiro <raysatiro@yahoo.com>2016-04-29 15:24:10 +0200
committerDaniel Stenberg <daniel@haxx.se>2016-04-29 15:24:10 +0200
commit0dc4d8e42e44224b00a028b467749eede8f08a6e (patch)
tree125ad6e7f68c0104b7627c2c2fe0e47eff91bc1b
parent9dbcab3a0c3f2e22f68081653f8e5f5e596a555b (diff)
curl -J: make it work even without http:// scheme on URL
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
-rw-r--r--src/tool_operate.c5
-rw-r--r--tests/data/test13122
2 files changed, 5 insertions, 2 deletions
diff --git a/src/tool_operate.c b/src/tool_operate.c
index 99996e142..ab29c00b3 100644
--- a/src/tool_operate.c
+++ b/src/tool_operate.c
@@ -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;
diff --git a/tests/data/test1312 b/tests/data/test1312
index 92144015a..bed492c16 100644
--- a/tests/data/test1312
+++ b/tests/data/test1312
@@ -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>