Decode params to `curl_sendfile`

`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
This commit is contained in:
Travis Cross 2014-08-20 10:22:27 +00:00
parent 7bbdbadb42
commit f2ca3c5211
1 changed files with 4 additions and 1 deletions

View 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);
}
}
}