]> granicus.if.org Git - curl/commitdiff
When we append stuff to the URL, we must make sure the text is properly
authorDaniel Stenberg <daniel@haxx.se>
Wed, 12 Mar 2003 14:20:16 +0000 (14:20 +0000)
committerDaniel Stenberg <daniel@haxx.se>
Wed, 12 Mar 2003 14:20:16 +0000 (14:20 +0000)
URL encoded before. Test case 58 added to verify this.

src/main.c

index 4e6f8aed4aad26304839e76c9747bf694178db15..e5e6d540a26a8efbb83a0b6c3e06ee458600c7cc 100644 (file)
@@ -2657,19 +2657,28 @@ operate(struct Configurable *config, int argc, char *argv[])
           else
             filep = config->infile;
 
-          urlbuffer=(char *)malloc(strlen(url) + strlen(filep) + 3);
-          if(!urlbuffer) {
-            helpf("out of memory\n");
-            return CURLE_OUT_OF_MEMORY;
+          /* URL encode the file name */
+          filep = curl_escape(filep, 0 /* use strlen */);
+
+          if(filep) {
+
+            urlbuffer=(char *)malloc(strlen(url) + strlen(filep) + 3);
+            if(!urlbuffer) {
+              helpf("out of memory\n");
+              return CURLE_OUT_OF_MEMORY;
+            }
+            if(ptr)
+              /* there is a trailing slash on the URL */
+              sprintf(urlbuffer, "%s%s", url, filep);
+            else
+              /* thers is no trailing slash on the URL */
+              sprintf(urlbuffer, "%s/%s", url, filep);
+            
+            curl_free(filep);
+
+            free(url);
+            url = urlbuffer; /* use our new URL instead! */
           }
-          if(ptr)
-            /* there is a trailing slash on the URL */
-            sprintf(urlbuffer, "%s%s", url, filep);
-          else
-            /* thers is no trailing slash on the URL */
-            sprintf(urlbuffer, "%s/%s", url, filep);
-          
-          url = urlbuffer; /* use our new URL instead! */
         }
 /*VMS??-- Reading binary from files can be a problem... */
 /*VMS??   Only FIXED, VAR etc WITHOUT implied CC will work */