]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
FS-2881: SIP-header History-Info might exist multiple times, but only last header...
authorBrian West <brian@freeswitch.org>
Thu, 2 Dec 2010 22:55:02 +0000 (16:55 -0600)
committerBrian West <brian@freeswitch.org>
Thu, 2 Dec 2010 22:55:02 +0000 (16:55 -0600)
src/mod/endpoints/mod_sofia/sofia.c

index e20d868548c4de88006025eb798084c65045667c..2e13b544d0cd35472d595d2420c1238304bfb840 100644 (file)
@@ -7001,6 +7001,8 @@ void sofia_handle_sip_i_invite(nua_t *nua, sofia_profile_t *profile, nua_handle_
 
        if (tech_pvt->caller_profile) {
 
+               int first_history_info = 1;
+
                if (rpid) {
                        if (rpid->rpid_privacy) {
                                if (!strcasecmp(rpid->rpid_privacy, "yes")) {
@@ -7045,7 +7047,25 @@ void sofia_handle_sip_i_invite(nua_t *nua, sofia_profile_t *profile, nua_handle_
                                        }
                                }
                        } else if (!strncasecmp(un->un_name, "History-Info", 12)) {
-                               switch_channel_set_variable(channel, "sip_history_info", un->un_value);
+                               if (first_history_info) {
+                                       /* If the header exists first time, make sure to remove old info and re-set the variable */
+                                       switch_channel_set_variable(channel, "sip_history_info", un->un_value);
+                                       first_history_info = 0;
+                               } else {
+                                       /* Append the History-Info into one long string */
+                                       const char *history_var = switch_channel_get_variable(channel, "sip_history_info");
+                                       if (!zstr(history_var)) {
+                                               char *tmp_str;
+                                               if ((tmp_str = switch_mprintf("%s, %s", history_var, un->un_value))) {
+                                                       switch_channel_set_variable(channel, "sip_history_info", tmp_str);
+                                                       free(tmp_str);
+                                               } else {
+                                                       switch_channel_set_variable(channel, "sip_history_info", un->un_value);
+                                               }
+                                       } else {
+                                               switch_channel_set_variable(channel, "sip_history_info", un->un_value);
+                                       }
+                               }
                        } else if (!strcasecmp(un->un_name, "X-FS-Support")) {
                                tech_pvt->x_freeswitch_support_remote = switch_core_session_strdup(session, un->un_value);
                        } else if (!strncasecmp(un->un_name, "X-", 2) || !strncasecmp(un->un_name, "P-", 2)) {