提交 436bb68d authored 作者: Michael Jerris's avatar Michael Jerris 提交者: Brian

FS-7258, FS-7571: [mod_xml_cdr] properly encode xml cdr for post to web server

上级 797c0579
......@@ -997,6 +997,7 @@ static inline int switch_needs_url_encode(const char *s)
return 0;
}
SWITCH_DECLARE(char *) switch_url_encode_opt(const char *url, char *buf, size_t len, switch_bool_t double_encode);
SWITCH_DECLARE(char *) switch_url_encode(const char *url, char *buf, size_t len);
SWITCH_DECLARE(char *) switch_url_decode(char *s);
SWITCH_DECLARE(switch_bool_t) switch_simple_email(const char *to,
......
......@@ -272,7 +272,7 @@ static switch_status_t my_on_reporting(switch_core_session_t *session)
memset(xml_text_escaped, 0, need_bytes);
if (globals.encode == ENCODING_DEFAULT) {
headers = switch_curl_slist_append(headers, "Content-Type: application/x-www-form-urlencoded");
switch_url_encode(xml_text, xml_text_escaped, need_bytes);
switch_url_encode_opt(xml_text, xml_text_escaped, need_bytes, SWITCH_TRUE);
} else {
headers = switch_curl_slist_append(headers, "Content-Type: application/x-www-form-base64-encoded");
switch_b64_encode((unsigned char *) xml_text, need_bytes / 3, (unsigned char *) xml_text_escaped, need_bytes);
......
......@@ -2921,7 +2921,7 @@ SWITCH_DECLARE(int) switch_socket_waitfor(switch_pollfd_t *poll, int ms)
return nsds;
}
SWITCH_DECLARE(char *) switch_url_encode(const char *url, char *buf, size_t len)
SWITCH_DECLARE(char *) switch_url_encode_opt(const char *url, char *buf, size_t len, switch_bool_t double_encode)
{
const char *p, *e = end_of_p(url);
size_t x = 0;
......@@ -2944,7 +2944,7 @@ SWITCH_DECLARE(char *) switch_url_encode(const char *url, char *buf, size_t len)
break;
}
if (*p == '%' && e-p > 1) {
if (!double_encode && *p == '%' && e-p > 1) {
if (strchr(hex, *(p+1)) && strchr(hex, *(p+2))) {
ok = 1;
}
......@@ -2966,6 +2966,11 @@ SWITCH_DECLARE(char *) switch_url_encode(const char *url, char *buf, size_t len)
return buf;
}
SWITCH_DECLARE(char *) switch_url_encode(const char *url, char *buf, size_t len)
{
return switch_url_encode_opt(url, buf, len, SWITCH_FALSE);
}
SWITCH_DECLARE(char *) switch_url_decode(char *s)
{
char *o;
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论