[sr-dev] git:master:1c4af823: pv: relax uri and params transfromation parsing when separator is last char

Daniel-Constantin Mierla miconda at gmail.com
Fri Jun 28 16:03:18 CEST 2019


Module: kamailio
Branch: master
Commit: 1c4af823c39d28b694c1dec607d8d72c5b726456
URL: https://github.com/kamailio/kamailio/commit/1c4af823c39d28b694c1dec607d8d72c5b726456

Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date: 2019-06-28T16:01:43+02:00

pv: relax uri and params transfromation parsing when separator is last char

- more flexible in parsing custom values, detection done in
transformations code

---

Modified: src/modules/pv/pv_trans.c

---

Diff:  https://github.com/kamailio/kamailio/commit/1c4af823c39d28b694c1dec607d8d72c5b726456.diff
Patch: https://github.com/kamailio/kamailio/commit/1c4af823c39d28b694c1dec607d8d72c5b726456.patch

---

diff --git a/src/modules/pv/pv_trans.c b/src/modules/pv/pv_trans.c
index 17c6a3e204..8ab46d328f 100644
--- a/src/modules/pv/pv_trans.c
+++ b/src/modules/pv/pv_trans.c
@@ -1232,6 +1232,7 @@ int tr_eval_uri(struct sip_msg *msg, tr_param_t *tp, int subtype,
 	param_hooks_t phooks;
 	param_t *pit=NULL;
 	str sproto;
+	int dlen = 0;
 
 	if(val==NULL || (!(val->flags&PV_VAL_STR)) || val->rs.len<=0)
 		return -1;
@@ -1266,8 +1267,11 @@ int tr_eval_uri(struct sip_msg *msg, tr_param_t *tp, int subtype,
 			free_params(_tr_uri_params);
 			_tr_uri_params = 0;
 		}
+		if(_tr_uri.len>4 && _tr_uri.s[_tr_uri.len-1]==';') {
+			dlen = 1;
+		}
 		/* parse uri -- params only when requested */
-		if(parse_uri(_tr_uri.s, _tr_uri.len, &_tr_parsed_uri)!=0)
+		if(parse_uri(_tr_uri.s, _tr_uri.len - dlen, &_tr_parsed_uri)!=0)
 		{
 			LM_ERR("invalid uri [%.*s]\n", val->rs.len,
 					val->rs.s);
@@ -1505,6 +1509,9 @@ int tr_eval_paramlist(struct sip_msg *msg, tr_param_t *tp, int subtype,
 
 		/* parse params */
 		sv = _tr_params_str;
+		if(sv.len>1 && sv.s[sv.len - 1] == _tr_params_separator) {
+			sv.len--;
+		}
 		if (parse_params2(&sv, CLASS_ANY, &phooks, &_tr_params_list,
 					_tr_params_separator)<0)
 			return -1;




More information about the sr-dev mailing list