--- chan_sip.c 2007-04-01 14:04:19.000000000 +0200 +++ chan_sip-new.c 2007-04-01 14:51:52.396454154 +0200 @@ -2422,6 +2422,49 @@ } /*! + * Strip the options part from the uri. + * Take into account the URIs of the form: + * sip:5551234;phone-context=+1212@example.net;user=phone + * from RFC 4504, where we have semicolon before '@'. + * return pointer to the beginning of the token, replace the semicolon, + * just before the options with '\0' and advance *uri to point at the begining + * of the options + */ +static char *strip_uri_options(char **uri) +{ + char *atsign, *semi; + char *ret = *uri; + + atsign = strchr(*uri, '@'); + semi = strchr(*uri, ';'); + + if (!semi) { + *uri = 0; + return ret; + } + + if (!atsign) { + *semi = 0; + *uri = semi + 1; + return ret; + } + + if (semi < atsign) { + semi = strchr(atsign + 1, ';'); + + if (!semi) { + *uri = 0; + return ret; + } + + } + + *semi = 0; + *uri = semi + 1; + return ret; +} + +/*! * parses a URI in its components. * If scheme is specified, drop it from the top. * If a component is not requested, do not split around it. @@ -2444,7 +2487,7 @@ *pass = ""; if (port) *port = ""; - name = strsep(&uri, ";"); /* remove options */ + name = strip_uri_options(&uri); /* remove options */ if (scheme) { int l = strlen(scheme); if (!strncmp(name, scheme, l))