It looks to me like the --remote-header-name option for the command-line
tool assumes that everything beyond the filename= field is part of the
filename, but that might not always be the case, for example:

Content-Disposition: attachment; filename=file.txt; modification-date=etc...

This patch chops the filename off at the next semicolon, if there is one.


- Jeff
--- src/main.c.orig	2010-07-17 12:30:17.000000000 -0500
+++ src/main.c	2010-07-17 12:36:32.000000000 -0500
@@ -4388,6 +4388,7 @@
   const char* str = (char*)ptr;
   const size_t cb = size*nmemb;
   const char* end = (char*)ptr + cb;
+  size_t len;
 
   if (cb > 20 && curlx_strnequal(str, "Content-disposition:", 20)) {
     char *p = (char*)str + 20;
@@ -4409,7 +4410,8 @@
         continue;
       }
       p+=9;
-      filename = parse_filename(p, cb - (p - str));
+      len = strchr(p, ';') ? strchr(p, ';') - p : cb - (p - str);
+      filename = parse_filename(p, len);
       if (filename) {
         outs->filename = filename;
         break;
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html

Reply via email to