[sr-dev] git:master:004190b2: core: evaluate replacement expression for substdef

Daniel-Constantin Mierla miconda at gmail.com
Wed Dec 23 14:02:41 CET 2020


Module: kamailio
Branch: master
Commit: 004190b2ebe62681ae1f4f65f18de1a9e430742d
URL: https://github.com/kamailio/kamailio/commit/004190b2ebe62681ae1f4f65f18de1a9e430742d

Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date: 2020-12-23T14:00:48+01:00

core: evaluate replacement expression for substdef

- done fore define when it includes variables, to be coherent with subst

---

Modified: src/core/ppcfg.c

---

Diff:  https://github.com/kamailio/kamailio/commit/004190b2ebe62681ae1f4f65f18de1a9e430742d.diff
Patch: https://github.com/kamailio/kamailio/commit/004190b2ebe62681ae1f4f65f18de1a9e430742d.patch

---

diff --git a/src/core/ppcfg.c b/src/core/ppcfg.c
index c6b7d2e14d..627402ba66 100644
--- a/src/core/ppcfg.c
+++ b/src/core/ppcfg.c
@@ -29,6 +29,7 @@
 #include "mem/mem.h"
 #include "ut.h"
 #include "re.h"
+#include "pvar.h"
 #include "dprint.h"
 
 #include "ppcfg.h"
@@ -91,6 +92,8 @@ int pp_substdef_add(char *data, int mode)
 	char *p;
 	str defname;
 	str defvalue;
+	str newval;
+	sip_msg_t *fmsg;
 
 	if(pp_subst_add(data)<0) {
 		LM_ERR("subst rule cannot be added\n");
@@ -147,6 +150,12 @@ int pp_substdef_add(char *data, int mode)
 		defvalue.s--;
 		defvalue.len += 2;
 	}
+	if(memchr(defvalue.s, '$', defvalue.len) != NULL) {
+		fmsg = faked_msg_get_next();
+		if(pv_eval_str(fmsg, &newval, &defvalue)>=0) {
+			defvalue = newval;
+		}
+	}
 	if(pp_define_set(defvalue.len, defvalue.s)<0) {
 		LM_ERR("cannot set define value\n");
 		goto error;




More information about the sr-dev mailing list