From 7efeabbd88e81ee368de6ced32fed06c8035097b Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Wed, 12 Feb 2014 23:11:11 +0500 Subject: [PATCH] fix switch_split_user_domain to parse sip:foo.com properly --- src/switch_utils.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/switch_utils.c b/src/switch_utils.c index 4ed7f82445..3c8f18c668 100644 --- a/src/switch_utils.c +++ b/src/switch_utils.c @@ -3115,19 +3115,29 @@ SWITCH_DECLARE(int) switch_tod_cmp(const char *exp, int val) SWITCH_DECLARE(int) switch_split_user_domain(char *in, char **user, char **domain) { - char *p = NULL, *h = NULL, *u = in; + char *p = NULL, *h = NULL, *u; if (!in) { return 0; } + if (!strncasecmp(in, "sip", 3)) { + in += 3; + while(*in == ':' || *in == 's') in++; + } + + u = in; + /* First isolate the host part from the user part */ if ((h = strchr(u, '@'))) { *h++ = '\0'; + } else { + u = NULL; + h = in; } /* Clean out the user part of its protocol prefix (if any) */ - if ((p = strchr(u, ':'))) { + if (u && (p = strchr(u, ':'))) { *p++ = '\0'; u = p; }