[asterisk-users] Perl AGI: read variable with quotes

Tony Mountifield tony at softins.co.uk
Fri Jan 24 10:38:43 CST 2020


In article <20200124154749.46da5eb6 at go.imp.ch>,
Benoit Panizzon <benoit.panizzon at imp.ch> wrote:
> Hi Gang
> 
> I have stumbled of this problem.
> 
> I need the P-Asserted-Identity header in an AGI scrip.
> 
> In the Dial-Plan I do:
> 
> same => n,Set(PAI=${PJSIP_HEADER(read,P-Asserted-Identity)})
> 
> In the AGI I do:
> 
> my $pai = $AGI->get_variable(PAI);
> 
> This works fine, unless the PAI contains quotes:
> 
> P-Asserted-Identity: <sip:1000 at 1.2.3.4:5060;user=phone>
> 
> I get "<sip:1000 at 1.2.3.4:5060;user=phone>" in the variable $pai.
> 
> P-Asserted-Identity: "John Doe" <sip:2000 at 1.2.3.4:5060;user=phone>
> 
> Is getting me $pai containing just "John".
> 
> Anyone a clue how I could get the whole header?

First you need to identify whether the problem is in the Set()
or in the $AGI->get_variable(PAI) (shouldn't that be ("PAI")?)

Add a line to your dialplan just after the line you quoted:

same => n,NoOp(PAI=${PAI})

Then turn on verbose logging and try the call. Look at the logged
NoOp line and see if it contains just the 'John' or the whole value
'"John Doe" <sip:2000 at 1.2.3.4:5060;user=phone>'

If it contains the whole value, then the problem is in the AGI library
reading the variable. If it just contains John, the problem is in the
Set() operation in the dialplan.

Cheers
Tony
-- 
Tony Mountifield
Work: tony at softins.co.uk - http://www.softins.co.uk
Play: tony at mountifield.org - http://tony.mountifield.org



More information about the asterisk-users mailing list