]> granicus.if.org Git - curl/commitdiff
curl: don't pass semicolons when parsing Content-Disposition
authorKristiyan Tsaklev <cuki@cukii.tk>
Sat, 7 Oct 2017 14:47:11 +0000 (17:47 +0300)
committerDaniel Stenberg <daniel@haxx.se>
Mon, 9 Oct 2017 08:37:27 +0000 (10:37 +0200)
Test 1422 updated to verify.

Closes #1964

src/tool_cb_hdr.c
tests/data/test1422

index bb982d2e4f98e5b15e2978842ecf0e9b3a8421fd..7f2181f404ea1dd08dd0ab6898b28be448100661 100644 (file)
@@ -161,8 +161,13 @@ static char *parse_filename(const char *ptr, size_t len)
   else
     stop = ';';
 
+  /* scan for the end letter and stop there */
+  q = strchr(p, stop);
+  if(q)
+    *q = '\0';
+
   /* if the filename contains a path, only use filename portion */
-  q = strrchr(copy, '/');
+  q = strrchr(p, '/');
   if(q) {
     p = q + 1;
     if(!*p) {
@@ -183,14 +188,6 @@ static char *parse_filename(const char *ptr, size_t len)
     }
   }
 
-  /* scan for the end letter and stop there */
-  for(q = p; *q; ++q) {
-    if(*q == stop) {
-      *q = '\0';
-      break;
-    }
-  }
-
   /* make sure the file name doesn't end in \r or \n */
   q = strchr(p, '\r');
   if(q)
index 9b436cc4eac57b9bc139c39a19236b0b205133c6..df9d750ddeb890b339cd06c7ad4dc838217eda0f 100644 (file)
@@ -16,7 +16,7 @@ Server: test-server/fake
 Content-Length: 0\r
 Connection: close\r
 Content-Type: text/html\r
-Content-Disposition: filename=name1422; charset=funny; option=strange\r
+Content-Disposition: filename=name1422; charset=funny; option=str//nge\r
 \r
 </data>
 </reply>