[sr-dev] git:3.1: module_k/ pv Changed the nameaddr transformation by relaxing the requirements on the input .
Marius Zbihlei
marius.zbihlei at 1and1.ro
Mon Jun 6 15:00:31 CEST 2011
Module: sip-router
Branch: 3.1
Commit: b981181c4dc90eee4b324180716bc786433507f7
URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=b981181c4dc90eee4b324180716bc786433507f7
Author: Marius Zbihlei <marius.zbihlei at 1and1.ro>
Committer: Marius Zbihlei <marius.zbihlei at 1and1.ro>
Date: Thu Apr 28 10:30:55 2011 +0300
module_k/pv Changed the nameaddr transformation by relaxing the requirements on the input.
As some headers might be either uri or nameaddr form, using a single transformation for parsing them was
impossible, as nameaddr.uri returns "" on an uri input(e.g. sip:12345 at example.com). With this change, the
nameaddr transformation succedes and the resulting transformation places the whole string in the .uri field,
.name field being empty. A transformation chaning like the one below will work as expected on both SIP URIs and
SIP Nameaddr
$(val(test){nameaddr.uri}{uri.domain})
(cherry picked from commit 9287609db4ac64c709aa500e6326ac33af2c2061)
---
modules_k/pv/pv_trans.c | 11 +++++++++--
1 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/modules_k/pv/pv_trans.c b/modules_k/pv/pv_trans.c
index e568ddb..faa9376 100644
--- a/modules_k/pv/pv_trans.c
+++ b/modules_k/pv/pv_trans.c
@@ -880,6 +880,7 @@ int tr_eval_nameaddr(struct sip_msg *msg, tr_param_t *tp, int subtype,
pv_value_t *val)
{
str sv;
+ int ret;
if(val==NULL || (!(val->flags&PV_VAL_STR)) || val->rs.len<=0)
return -1;
@@ -909,8 +910,14 @@ int tr_eval_nameaddr(struct sip_msg *msg, tr_param_t *tp, int subtype,
/* parse params */
sv = _tr_nameaddr_str;
- if (parse_nameaddr(&sv, &_tr_nameaddr)<0)
- return -1;
+ ret = parse_nameaddr(&sv, &_tr_nameaddr);
+ if (ret < 0) {
+ if(ret != -3) return -1;
+ /* -3 means no "<" found so treat whole nameaddr as an URI */
+ _tr_nameaddr.uri = _tr_nameaddr_str;
+ _tr_nameaddr.name = _tr_empty;
+ _tr_nameaddr.len = _tr_nameaddr_str.len;
+ }
}
memset(val, 0, sizeof(pv_value_t));
More information about the sr-dev
mailing list