提交 f2ca3c52 authored 作者: Travis Cross's avatar Travis Cross

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
上级 7bbdbadb
......@@ -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);
}
}
}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论