diff -NaurbB old/chan_sip.c new/chan_sip.c --- old/chan_sip.c 2009-01-07 17:51:32.000000000 +0000 +++ new/chan_sip.c 2009-01-08 17:45:27.000000000 +0000 @@ -6124,15 +6124,18 @@ ast_log(LOG_WARNING, "Format for registration is [transport://]user[:secret[:authuser]]@host[:port][/contact][~expiry] at line %d\n", lineno); return -1; } - /* split user[:secret[:authuser]] */ - secret = strchr(username, ':'); - if (secret) { - *secret++ = '\0'; - authuser = strchr(secret, ':'); - if (authuser) + /* split user[:secret[:authuser]] from the end to allow : character in user portion*/ + authuser = strrchr(username, ':'); + if (authuser) { *authuser++ = '\0'; + secret = strrchr(username, ':'); + if (secret) + *secret++ = '\0'; + else { + secret = authuser; + authuser = NULL; + } } - if (!(reg = ast_calloc(1, sizeof(*reg)))) { ast_log(LOG_ERROR, "Out of memory. Can't allocate SIP registry entry\n"); @@ -9315,6 +9318,7 @@ char addr[80]; struct sip_pvt *p; char *fromdomain; + char *domainport; /* exit if we are already in process with this registrar ?*/ if ( r == NULL || ((auth==NULL) && (r->regstate==REG_STATE_REGSENT || r->regstate==REG_STATE_AUTHSENT))) { @@ -9437,10 +9440,21 @@ /* Fromdomain is what we are registering to, regardless of actual host name from SRV */ if (!ast_strlen_zero(p->fromdomain)) { + domainport = strrchr(p->fromdomain, ':'); + if (domainport) { + *domainport++ = '\0'; /* trim off domainport from p->fromdomain */ + + if (atoi(domainport) != STANDARD_SIP_PORT) + snprintf(addr, sizeof(addr), "sip:%s:%s", p->fromdomain, domainport); + else + snprintf(addr, sizeof(addr), "sip:%s", p->fromdomain); + } else { + if (r->portno && r->portno != STANDARD_SIP_PORT) snprintf(addr, sizeof(addr), "sip:%s:%d", p->fromdomain, r->portno); else snprintf(addr, sizeof(addr), "sip:%s", p->fromdomain); + } } else { if (r->portno && r->portno != STANDARD_SIP_PORT) snprintf(addr, sizeof(addr), "sip:%s:%d", r->hostname, r->portno);