]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
Decode params to `curl_sendfile`
authorTravis Cross <tc@traviscross.com>
Wed, 20 Aug 2014 10:22:27 +0000 (10:22 +0000)
committerTravis Cross <tc@traviscross.com>
Wed, 20 Aug 2014 10:37:24 +0000 (10:37 +0000)
`curl_sendfile` generates a multipart message with Content-Type:
multipart/form-data with no separate Content-Type headers in the parts
for each non-file argument.  These parts therefore default to
text/plain.  However, prior to this commit, we were putting the URL
encoded POST data into these parts, which is not correct.  We should
be putting raw text into the parts.

With this commit, we urldecode each argument key and value before
composing the multipart message.

See:

  http://www.w3.org/TR/html401/interact/forms.html#h-17.13.4.2

src/mod/applications/mod_curl/mod_curl.c

index 03c0eda5c825478eb06c1de39f0d1e49093f6a33..61f9a78d2a0969d5b84a0134f2048bfb07c0ea74 100644 (file)
@@ -400,8 +400,11 @@ static void http_sendfile_initialize_curl(http_sendfile_data_t *http_data)
                        char *argv2[4] = { 0 };
                        uint32_t argc2 = switch_separate_string(argv[count], '=', argv2, (sizeof(argv2) / sizeof(argv2[0])));
                        
-                       if(argc2 == 2)
+                       if(argc2 == 2) {
+                               switch_url_decode(argv2[0]);
+                               switch_url_decode(argv2[1]);
                                curl_formadd(&http_data->formpost, &http_data->lastptr, CURLFORM_COPYNAME, argv2[0], CURLFORM_COPYCONTENTS, argv2[1], CURLFORM_END);
+                       }
                }
        }