[OpenSIPS-Users] Error in re.subst transformation

Liviu Chircu liviu at opensips.org
Thu Jan 18 12:48:38 UTC 2024


On 18.01.2024 12:51, Alexander Kogan wrote:
> Hi,
>
> There's an error in re.subst transformation, it's not whitespace-safe. 
> Is this patch OK?
>
> Index: transformations.c
> ===================================================================
> --- transformations.c   (revision 13886)
> +++ transformations.c   (working copy)
> @@ -3630,7 +3630,7 @@
>                 }
>                 p++;
>                 LM_DBG("preparing to parse param\n");
> -               if (tr_parse_sparam(p, in, &tp, 0) == NULL)
> +               if (tr_parse_sparam(p, in, &tp, 1) == NULL)
>                         goto error;
>                 t->params = tp;
>                 tp = 0;
>
Hi Alexander,

Looks OK to me, for example this quick test seems to PASS after your 
patch without any side-effects on other tests:

     $var(in) = "+443 493 2212";
     assert($(var(in){re.subst, /([0-9]) ([0-9])/\1.\2/g}) == 
"+443.493.2212", "test-subst-2");

If you do a Pull Request on `master`, it will most likely get merged.  
For the stable branches, this limitation can be bypassed by assigning 
the regex to a variable:

     $var(in) = "+443 493 2212";
     $var(re) = "/([0-9]) ([0-9])/\1.\2/g";
     assert($(var(in){re.subst, $var(re)}) == "+443.493.2212", 
"test-subst-2");

Best regards,

-- 
Liviu Chircu
www.twitter.com/liviuchircu | www.opensips-solutions.com
OpenSIPS Summit 2024 May 14-17 Valencia | www.opensips.org/events




More information about the Users mailing list