Index: channels/chan_sip.c =================================================================== --- channels/chan_sip.c (revision 280629) +++ channels/chan_sip.c (working copy) @@ -14476,17 +14476,27 @@ if ((ptr = strchr(refer_to, '@'))) { /* Separate domain */ char *urioption = NULL, *domain; + int bracket = 0; *ptr++ = '\0'; if ((urioption = strchr(ptr, ';'))) { /* Separate urioptions */ *urioption++ = '\0'; } - + domain = ptr; - if ((ptr = strchr(domain, ':'))) { /* Remove :port */ - *ptr = '\0'; + + /* Remove :port */ + for (; *ptr != '\0'; ++ptr) { + if (*ptr == ':' && bracket == 0) { + *ptr = '\0'; + break; + } else if (*ptr == '[') { + ++bracket; + } else if (*ptr == ']') { + --bracket; + } } - + SIP_PEDANTIC_DECODE(domain); SIP_PEDANTIC_DECODE(urioption);