]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
FS-7258, FS-7571: [mod_xml_cdr] properly encode xml cdr for post to web server
authorMichael Jerris <mike@jerris.com>
Tue, 2 Jun 2015 23:26:28 +0000 (19:26 -0400)
committerBrian <brian@freeswitch.org>
Tue, 2 Jun 2015 23:56:07 +0000 (18:56 -0500)
src/include/switch_utils.h
src/mod/xml_int/mod_xml_cdr/mod_xml_cdr.c
src/switch_utils.c

index 120e3198386a813f11f81261ec644fa104223079..cb92079b099569d078b016d6548dd9d00a0378f1 100644 (file)
@@ -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,
index 71f51d30ceedace3e38fd1a056ddb736b65c6a8d..968e16e4add08a7575639d4d078a44a694bf48f5 100644 (file)
@@ -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);
index c0963aeb9efa61bb469a9ca34d13533c08b20cb9..1e14fb17ea822ee135edcedc5181f68b43a41b10 100644 (file)
@@ -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;