Browse code

core: evaluate replacement expression for substdef

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

Daniel-Constantin Mierla authored on 23/12/2020 13:00:48
Showing 1 changed files
... ...
@@ -29,6 +29,7 @@
29 29
 #include "mem/mem.h"
30 30
 #include "ut.h"
31 31
 #include "re.h"
32
+#include "pvar.h"
32 33
 #include "dprint.h"
33 34
 
34 35
 #include "ppcfg.h"
... ...
@@ -91,6 +92,8 @@ int pp_substdef_add(char *data, int mode)
91 92
 	char *p;
92 93
 	str defname;
93 94
 	str defvalue;
95
+	str newval;
96
+	sip_msg_t *fmsg;
94 97
 
95 98
 	if(pp_subst_add(data)<0) {
96 99
 		LM_ERR("subst rule cannot be added\n");
... ...
@@ -147,6 +150,12 @@ found_repl:
147 150
 		defvalue.s--;
148 151
 		defvalue.len += 2;
149 152
 	}
153
+	if(memchr(defvalue.s, '$', defvalue.len) != NULL) {
154
+		fmsg = faked_msg_get_next();
155
+		if(pv_eval_str(fmsg, &newval, &defvalue)>=0) {
156
+			defvalue = newval;
157
+		}
158
+	}
150 159
 	if(pp_define_set(defvalue.len, defvalue.s)<0) {
151 160
 		LM_ERR("cannot set define value\n");
152 161
 		goto error;