summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJay Satiro <raysatiro@yahoo.com>2016-02-07 04:49:07 -0500
committerJay Satiro <raysatiro@yahoo.com>2016-02-08 03:14:04 -0500
commitd572d2664d82fb8a14b838910018b5683b0af837 (patch)
treebdfeceeeff6614a672765d9c3437daddbf510add
parentb97307047cffd579ded7cc346daf924b39931e1f (diff)
downloadcurl-d572d2664d82fb8a14b838910018b5683b0af837.tar.gz
tool_operhlp: Check for backslashes in get_url_file_name
Extract the filename from the last slash or backslash. Prior to this change backslashes could be part of the filename. This change needed for the curl tool built for Cygwin. Refer to the CYGWIN addendum in advisory 20160127B. Bug: https://curl.haxx.se/docs/adv_20160127B.html
-rw-r--r--src/tool_operhlp.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/tool_operhlp.c b/src/tool_operhlp.c
index fb344f65d..b43dc9548 100644
--- a/src/tool_operhlp.c
+++ b/src/tool_operhlp.c
@@ -129,7 +129,7 @@ char *add_file_name_to_url(CURL *curl, char *url, const char *filename)
*/
CURLcode get_url_file_name(char **filename, const char *url)
{
- const char *pc;
+ const char *pc, *pc2;
*filename = NULL;
@@ -139,7 +139,11 @@ CURLcode get_url_file_name(char **filename, const char *url)
pc += 3;
else
pc = url;
+
+ pc2 = strrchr(pc, '\\');
pc = strrchr(pc, '/');
+ if(pc2 && (!pc || pc < pc2))
+ pc = pc2;
if(pc)
/* duplicate the string beyond the slash */