]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
mod_sofia: Rewrite sofia_glue_get_user_host
authorMathieu Rene <mrene@avgs.ca>
Tue, 2 Jun 2009 00:54:38 +0000 (00:54 +0000)
committerMathieu Rene <mrene@avgs.ca>
Tue, 2 Jun 2009 00:54:38 +0000 (00:54 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@13543 d0543943-73ff-0310-b7d9-9358b9ac24b2

src/mod/endpoints/mod_sofia/sofia_glue.c

index 8e9b6c7da0ae15b60e88d2fcb3ddaefe0a92c071..5c5dbe72455555b60ed561105413435a65f9fbfd 100644 (file)
@@ -3961,20 +3961,30 @@ int sofia_glue_get_user_host(char *in, char **user, char **host)
        *user = NULL;
        *host = NULL;
 
-       if (!strncasecmp(u, "sip:", 4)) {
-               u += 4;
-       }
-
+       /* First isolate the host part from the user part */
        if ((h = strchr(u, '@'))) {
                *h++ = '\0';
        } else {
                return 0;
        }
 
-       p = h + strlen(h) - 1;
+       /* Clean out the user part of its protocol prefix (if any) */
+       if ((p = strchr(u, ':'))) {
+               *p++ = '\0';
+               u = p;
+       }
 
-       if (p && (*p == ':' || *p == ';' || *p == ' ')) {
-               *p = '\0';
+       /* Clean out the host part of any suffix */
+       if ((p = strchr(h, ':'))) {
+               *p = 0;
+       }
+       
+       if ((p = strchr(h, ';'))) {
+               *p = 0;
+       }
+       
+       if ((p = strchr(h, ' '))) {
+               *p = 0;
        }
 
        *user = u;