uac_replace_from and global (display name) variables

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

uac_replace_from and global (display name) variables

Andreas Sikkema
Hi,

Because of $reasons (customer equipment misbehaving,
interoperability,etc)I have to change the From header in an
(apparently) not often used way.

I started wanting to add the URI and display name of the P-Asserted-Id
header to the From header. The URI is the only part of the
P-Asserted-Id header available as a global variable. But I would
rather like the display part of the From header also filled in. In
this particular case I knew  I could use the display name part of the
existing From header.

So I had something like this:

....
if (..) {
    uac_replace_from("$fn", "$ai")
}

but this results in an invalid From header:

From: ""+31123456789"" <sip:+31123456789@10.1.1.1>

So I (naively) changed the relevant config line into:

....
if (..) {
    uac_replace_from($fn, "$a"i)
}

Which results in a syntax error.

If I want to spend a little more time on this I can probably grab the
display name part from the P-Asserted-Id into a variable and use that,
but I was surprised that it was this easy to create an invalid From
header using standard OpenSIPS constructs.

Or am I overlooking something obvious?

--
Andreas Sikkema

_______________________________________________
Users mailing list
[hidden email]
http://lists.opensips.org/cgi-bin/mailman/listinfo/users
Reply | Threaded
Open this post in threaded view
|

Re: uac_replace_from and global (display name) variables

Ben Newlin
The quotes are not being added because of the way you are calling the method, the quotes are part of the From Display Name and as such are included in the $fn variable. If you don't want them you have to strip them out. We use a regex substitution to do so:

$(fn{re.subst, /^"(.*)"$/\1/});

It is a bit unintuitive that the quotes are included in the variable and I have wondered if there is a reason for hat, but those answers will not come from me. (

Ben Newlin

´╗┐On 12/5/19, 12:07 PM, "Users on behalf of Andreas Sikkema" <[hidden email] on behalf of [hidden email]> wrote:

    Hi,
   
    Because of $reasons (customer equipment misbehaving,
    interoperability,etc)I have to change the From header in an
    (apparently) not often used way.
   
    I started wanting to add the URI and display name of the P-Asserted-Id
    header to the From header. The URI is the only part of the
    P-Asserted-Id header available as a global variable. But I would
    rather like the display part of the From header also filled in. In
    this particular case I knew  I could use the display name part of the
    existing From header.
   
    So I had something like this:
   
    ....
    if (..) {
        uac_replace_from("$fn", "$ai")
    }
   
    but this results in an invalid From header:
   
    From: ""+31123456789"" <sip:+31123456789@10.1.1.1>
   
    So I (naively) changed the relevant config line into:
   
    ....
    if (..) {
        uac_replace_from($fn, "$a"i)
    }
   
    Which results in a syntax error.
   
    If I want to spend a little more time on this I can probably grab the
    display name part from the P-Asserted-Id into a variable and use that,
    but I was surprised that it was this easy to create an invalid From
    header using standard OpenSIPS constructs.
   
    Or am I overlooking something obvious?
   
    --
    Andreas Sikkema
   
    _______________________________________________
    Users mailing list
    [hidden email]
    http://lists.opensips.org/cgi-bin/mailman/listinfo/users
   
   

_______________________________________________
Users mailing list
[hidden email]
http://lists.opensips.org/cgi-bin/mailman/listinfo/users
Reply | Threaded
Open this post in threaded view
|

Re: uac_replace_from and global (display name) variables

Bogdan-Andrei Iancu-2
In reply to this post by Andreas Sikkema
Hi Andreas,

IF you do not want to have the display name changes, simply do
uac_replace_from("$ai"), see:
https://opensips.org/html/docs/modules/2.4.x/uac.html#func_uac_replace_from_2

Regards,

Bogdan-Andrei Iancu

OpenSIPS Founder and Developer
   https://www.opensips-solutions.com
OpenSIPS Bootcamp Pre-Registration
   https://opensips.org/training/OpenSIPS_Bootcamp/

On 12/5/19 7:06 PM, Andreas Sikkema wrote:

> Hi,
>
> Because of $reasons (customer equipment misbehaving,
> interoperability,etc)I have to change the From header in an
> (apparently) not often used way.
>
> I started wanting to add the URI and display name of the P-Asserted-Id
> header to the From header. The URI is the only part of the
> P-Asserted-Id header available as a global variable. But I would
> rather like the display part of the From header also filled in. In
> this particular case I knew  I could use the display name part of the
> existing From header.
>
> So I had something like this:
>
> ....
> if (..) {
>      uac_replace_from("$fn", "$ai")
> }
>
> but this results in an invalid From header:
>
> From: ""+31123456789"" <sip:+31123456789@10.1.1.1>
>
> So I (naively) changed the relevant config line into:
>
> ....
> if (..) {
>      uac_replace_from($fn, "$a"i)
> }
>
> Which results in a syntax error.
>
> If I want to spend a little more time on this I can probably grab the
> display name part from the P-Asserted-Id into a variable and use that,
> but I was surprised that it was this easy to create an invalid From
> header using standard OpenSIPS constructs.
>
> Or am I overlooking something obvious?
>


_______________________________________________
Users mailing list
[hidden email]
http://lists.opensips.org/cgi-bin/mailman/listinfo/users