1
0
mirror of https://github.com/moparisthebest/curl synced 2024-12-22 08:08:50 -05:00

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
This commit is contained in:
Jay Satiro 2016-04-29 15:24:10 +02:00 committed by Daniel Stenberg
parent 9dbcab3a0c
commit 0dc4d8e42e
2 changed files with 5 additions and 2 deletions

View File

@ -1297,7 +1297,10 @@ static CURLcode operate_do(struct GlobalConfig *global,
if(config->content_disposition if(config->content_disposition
&& (urlnode->flags & GETOUT_USEREMOTE) && (urlnode->flags & GETOUT_USEREMOTE)
&& (checkprefix("http://", this_url) || && (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; hdrcbdata.honor_cd_filename = TRUE;
else else
hdrcbdata.honor_cd_filename = FALSE; hdrcbdata.honor_cd_filename = FALSE;

View File

@ -40,7 +40,7 @@ HTTP GET with -J, Content-Disposition and ; in filename
CURL_TESTDIR=%PWD/log CURL_TESTDIR=%PWD/log
</setenv> </setenv>
<command option="no-output,no-include"> <command option="no-output,no-include">
http://%HOSTIP:%HTTPPORT/1312 -J -O %HOSTIP:%HTTPPORT/1312 -J -O
</command> </command>
</client> </client>