while playing with dp_translate(), i noticed the following weird behavior.
i have a rule with dpid=11, where match_exp='^+' and subst_exp and repl_exp are empty.
my test goes like this:
$rU = "+35892345670"; if (dp_translate("11", $rU/$rU")) { xlog("ruri user is '$rU'\n"); };
$var(test) = "+35892345670"; if (dp_translate("11", "$var(test)/$var(test)")) { xlog("var(test) is '$var(test)'\n"); };
and this is produced to syslog:
Mar 29 20:01:39 localhost /usr/sbin/sip-proxy[20533]: ERROR: ruri user is '+35892345670' Mar 29 20:01:39 localhost /usr/sbin/sip-proxy[20533]: ERROR: var(test) is ''
that is, $rU is not translated to empty string, but $var(test) is.
can someone provide an explanation for this? what should the expected behavior be, when subst_exp and repl_exp are empty?
original author of dialplan module is Andreea-Ancuta Onofrei, but i don't know if he is still around.
-- juha
Judah Heinanen writes:
can someone provide an explanation for this? what should the expected behavior be, when subst_exp and repl_exp are empty?
in dialplan.c/dp_update function i found this:
no_change = ((!repl->s) || (!repl->len)) && (src->type == dest->type) && ((src->type == PVT_RURI) || (src->type == PVT_RURI_USERNAME));
that is, if repl_exp is empty, no replacement is done if src/dest is $ru/$ru or $rU/$rU.
dp_repl.c/rule_translate function returns immediately if repl_exp is empty:
if(!repl_comp){ LM_INFO("null replacement\n"); return 0; }
it does that even if subst_exp is not empty, because the above test is before this test:
if(subst_comp){
does anyone object if i change the no_change assignment to
no_change = (!repl->s) || (!repl->len);
that is, dest is left as is when repl_exp is empty no matter what kind of pv dest is?
-- juha