diff options
author | Jay Satiro <raysatiro@yahoo.com> | 2016-05-01 16:07:04 -0400 |
---|---|---|
committer | Jay Satiro <raysatiro@yahoo.com> | 2016-05-01 16:07:04 -0400 |
commit | b9728bca549709a26a5228f1d44f7488dd26811d (patch) | |
tree | 1bbc3d0aa4872f05299c22de7d3d319270384f2b /src/tool_cb_hdr.c | |
parent | 283babfaf8d8f3bab9d3c63cea94eb0b84e79c37 (diff) | |
download | curl-b9728bca549709a26a5228f1d44f7488dd26811d.tar.gz |
tool_cb_hdr: Fix --remote-header-name with schemeless URL
- Move the existing scheme check from tool_operate.
In the case of --remote-header-name we want to parse Content-disposition
for a filename, but only if the scheme is http or https. A recent
adjustment 0dc4d8e was made to account for schemeless URLs however it's
not 100% accurate. To remedy that I've moved the scheme check to the
header callback, since at that point the library has already determined
the scheme.
Bug: https://github.com/curl/curl/issues/760
Reported-by: Kai Noda
Diffstat (limited to 'src/tool_cb_hdr.c')
-rw-r--r-- | src/tool_cb_hdr.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/tool_cb_hdr.c b/src/tool_cb_hdr.c index 5be02aad2..f7d835562 100644 --- a/src/tool_cb_hdr.c +++ b/src/tool_cb_hdr.c @@ -48,6 +48,7 @@ size_t tool_header_cb(void *ptr, size_t size, size_t nmemb, void *userdata) const char *str = ptr; const size_t cb = size * nmemb; const char *end = (char*)ptr + cb; + char *url = NULL; /* * Once that libcurl has called back tool_header_cb() the returned value @@ -88,7 +89,9 @@ size_t tool_header_cb(void *ptr, size_t size, size_t nmemb, void *userdata) */ if(hdrcbdata->honor_cd_filename && - (cb > 20) && checkprefix("Content-disposition:", str)) { + (cb > 20) && checkprefix("Content-disposition:", str) && + !curl_easy_getinfo(outs->config->easy, CURLINFO_EFFECTIVE_URL, &url) && + url && (checkprefix("http://", url) || checkprefix("https://", url))) { const char *p = str + 20; /* look for the 'filename=' parameter |