]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
improve parsing
authorAnthony Minessale <anthm@freeswitch.org>
Wed, 15 Aug 2012 16:19:11 +0000 (11:19 -0500)
committerAnthony Minessale <anthm@freeswitch.org>
Wed, 15 Aug 2012 16:19:16 +0000 (11:19 -0500)
src/mod/endpoints/mod_sofia/sofia.c

index 08f06866255373e1a0fd343a9174662b7df3e1f4..f21d92b5c4d3d6b457221b60f49343a084562cbb 100644 (file)
@@ -1224,7 +1224,7 @@ static void our_sofia_event_callback(nua_event_t event,
                } else {
                        const char *req_user = NULL, *req_host = NULL, *action = NULL, *ref_by_user = NULL, *ref_to_user = NULL, *ref_to_host = NULL;
                        char *refer_to = NULL, *referred_by = NULL, *method = NULL, *full_url = NULL;
-                       char *params = NULL;
+                       char *params = NULL, *iparams = NULL;
                        switch_event_t *event;
                        char *tmp;
 
@@ -1232,20 +1232,23 @@ static void our_sofia_event_callback(nua_event_t event,
                                ref_to_user = sip->sip_refer_to->r_url->url_user;
                                ref_to_host = sip->sip_refer_to->r_url->url_host;
 
-                               if ((refer_to = sip_header_as_string(nua_handle_home(nh), (void *) sip->sip_refer_to))) {
+                               if (sip->sip_refer_to->r_url->url_params && switch_stristr("method=", sip->sip_refer_to->r_url->url_params)) {
+                                       params = su_strdup(nua_handle_home(nh), sip->sip_refer_to->r_url->url_params);
+                               }
 
-                                       if ((params = strrchr(refer_to, ';'))) {
-                                               *params++ = '\0';
-                                       }
+
+                               if ((refer_to = sip_header_as_string(nua_handle_home(nh), (void *) sip->sip_refer_to))) {
                                        
                                        if ((tmp = sofia_glue_get_url_from_contact(refer_to, 0))) {
                                                refer_to = tmp;
                                        }
-                               }
 
-                               if (!params || !switch_stristr("method=", params)) {
-                                       if ((params = strchr(refer_to, ';'))) {
-                                               *params++ = '\0';
+                                       if ((iparams = strrchr(refer_to, ';'))) {
+                                               *iparams++ = '\0';
+
+                                               if (!switch_stristr("method=", iparams)) {
+                                                       params = iparams;
+                                               }
                                        }
                                }