FS-7258, FS-7571: [mod_xml_cdr] properly encode xml cdr for post to web server
This commit is contained in:
parent
0c45bee409
commit
49778c34e5
|
@ -1052,6 +1052,7 @@ static inline int switch_needs_url_encode(const char *s)
|
||||||
return 0;
|
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_encode(const char *url, char *buf, size_t len);
|
||||||
SWITCH_DECLARE(char *) switch_url_decode(char *s);
|
SWITCH_DECLARE(char *) switch_url_decode(char *s);
|
||||||
SWITCH_DECLARE(switch_bool_t) switch_simple_email(const char *to,
|
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);
|
memset(xml_text_escaped, 0, need_bytes);
|
||||||
if (globals.encode == ENCODING_DEFAULT) {
|
if (globals.encode == ENCODING_DEFAULT) {
|
||||||
headers = switch_curl_slist_append(headers, "Content-Type: application/x-www-form-urlencoded");
|
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 {
|
} else {
|
||||||
headers = switch_curl_slist_append(headers, "Content-Type: application/x-www-form-base64-encoded");
|
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);
|
switch_b64_encode((unsigned char *) xml_text, need_bytes / 3, (unsigned char *) xml_text_escaped, need_bytes);
|
||||||
|
|
|
@ -3162,7 +3162,7 @@ SWITCH_DECLARE(int) switch_socket_waitfor(switch_pollfd_t *poll, int ms)
|
||||||
return nsds;
|
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);
|
const char *p, *e = end_of_p(url);
|
||||||
size_t x = 0;
|
size_t x = 0;
|
||||||
|
@ -3185,7 +3185,7 @@ SWITCH_DECLARE(char *) switch_url_encode(const char *url, char *buf, size_t len)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (*p == '%' && e-p > 1) {
|
if (!double_encode && *p == '%' && e-p > 1) {
|
||||||
if (strchr(hex, *(p+1)) && strchr(hex, *(p+2))) {
|
if (strchr(hex, *(p+1)) && strchr(hex, *(p+2))) {
|
||||||
ok = 1;
|
ok = 1;
|
||||||
}
|
}
|
||||||
|
@ -3207,6 +3207,11 @@ SWITCH_DECLARE(char *) switch_url_encode(const char *url, char *buf, size_t len)
|
||||||
return buf;
|
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)
|
SWITCH_DECLARE(char *) switch_url_decode(char *s)
|
||||||
{
|
{
|
||||||
char *o;
|
char *o;
|
||||||
|
|
Loading…
Reference in New Issue