Browse code

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

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

Daniel-Constantin Mierla authored on 28/06/2019 14:01:43
Showing 1 changed files
... ...
@@ -1232,6 +1232,7 @@ int tr_eval_uri(struct sip_msg *msg, tr_param_t *tp, int subtype,
1232 1232
 	param_hooks_t phooks;
1233 1233
 	param_t *pit=NULL;
1234 1234
 	str sproto;
1235
+	int dlen = 0;
1235 1236
 
1236 1237
 	if(val==NULL || (!(val->flags&PV_VAL_STR)) || val->rs.len<=0)
1237 1238
 		return -1;
... ...
@@ -1266,8 +1267,11 @@ int tr_eval_uri(struct sip_msg *msg, tr_param_t *tp, int subtype,
1266 1267
 			free_params(_tr_uri_params);
1267 1268
 			_tr_uri_params = 0;
1268 1269
 		}
1270
+		if(_tr_uri.len>4 && _tr_uri.s[_tr_uri.len-1]==';') {
1271
+			dlen = 1;
1272
+		}
1269 1273
 		/* parse uri -- params only when requested */
1270
-		if(parse_uri(_tr_uri.s, _tr_uri.len, &_tr_parsed_uri)!=0)
1274
+		if(parse_uri(_tr_uri.s, _tr_uri.len - dlen, &_tr_parsed_uri)!=0)
1271 1275
 		{
1272 1276
 			LM_ERR("invalid uri [%.*s]\n", val->rs.len,
1273 1277
 					val->rs.s);
... ...
@@ -1505,6 +1509,9 @@ int tr_eval_paramlist(struct sip_msg *msg, tr_param_t *tp, int subtype,
1505 1509
 
1506 1510
 		/* parse params */
1507 1511
 		sv = _tr_params_str;
1512
+		if(sv.len>1 && sv.s[sv.len - 1] == _tr_params_separator) {
1513
+			sv.len--;
1514
+		}
1508 1515
 		if (parse_params2(&sv, CLASS_ANY, &phooks, &_tr_params_list,
1509 1516
 					_tr_params_separator)<0)
1510 1517
 			return -1;