Module: sip-router
Branch: master
Commit: 9287609db4ac64c709aa500e6326ac33af2c2061
URL:    
http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=9287609db4ac64c709aa500e6326ac33af2c2061

Author: Marius Zbihlei <[email protected]>
Committer: Marius Zbihlei <[email protected]>
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:[email protected]). 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})

---

 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 b60f529..4cf2555 100644
--- a/modules_k/pv/pv_trans.c
+++ b/modules_k/pv/pv_trans.c
@@ -1016,6 +1016,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;
@@ -1045,8 +1046,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));


_______________________________________________
sr-dev mailing list
[email protected]
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev

Reply via email to