On 03/03/2015 12:21 PM, Daniel Tryba wrote:
$var(contact) = $T_rpl($ct); $var(contact) = $(var(contact){re.subst,/^<(sip:\+?
[0-9]+@.*)>$/\1/});
I would recommend, from a best-practical perspective, not doing this substitution, but instead using transformations[1] to extract the URI. The Contact header is a "name-address pair", so you can extract the URI component this way:
$var(contact) = $(T_rpl($ct){nameaddr.uri});
There are many reasons for doing this, but the most significant is that the formal properties of a grammatically correct SIP URI are actually quite complex and certainly go beyond <(sip:+?>[0-9]+@.*)>:
1. The URI scheme doesn't have to be sip:, but can also be sips:.
2. The user part of the RURI doesn't have to be numeric, but can be alphanumeric and also contain quite a lot of symbols (e.g. '+').
3. The @domain portion is optional.
sip:1.2.3.4:5060 is a valid URI.
4. In a name-address header like Contact, the URI is not required to be encapsulated in <>s, although practically, it most often is.
This is a valid Contact header:
Contact: sip:user@1.2.3.4:5060
-- Alex
[1] http://www.kamailio.org/wiki/cookbooks/4.2.x/transformations, specifically:
http://www.kamailio.org/wiki/cookbooks/4.2.x/transformations#nameaddruri