[SR-Users] weird dp_translate() behavior

Juha Heinanen jh at tutpro.com
Mon Mar 29 21:16:39 CEST 2010


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




More information about the sr-users mailing list