Sponsor: VoiceMeUp - Corporate & Wholesale VoIP Services

VoIP Mailing List Archives
Mailing list archives for the VoIP community
 SearchSearch 

[Freeswitch-users] originate api: Escaping variable names/values


 
Post new topic   Reply to topic    VoIP Mailing List Archives Forum Index -> freeSWITCH Users
View previous topic :: View next topic  
Author Message
sm at opencluster.com.au
Guest





PostPosted: Tue Nov 23, 2021 9:44 am    Post subject: [Freeswitch-users] originate api: Escaping variable names/va Reply with quote

Using the originate API and enterprise origination: I am attempting to specify various variables, such as custom headers and digest credentials, and am trying to understand how escaping is implemented, as I am inserting user-specified values into the string. I need to set it all up in one API call due to the various ways originate is being used. Here's a simple example:

originate [sip_h_X-Custom=ESCAPED]sofia/public/user@example.com $park()

I have searched the docs and source code, and have a solution that works most of the time, but there are edge cases I can't seem to resolve.

I've tried URL encoding but it seems to have no effect here. Escaping with back-slash seems to have an effect, so I've experimented with it below.

For example, this works:

Escaped: \'123 (inserted in above API command)
Actual: '123 (the value of X-Custom observed in the generated INVITE)
Expected: '123

While this doesn't:

Escaped: \'1\'23
Actual: 123
Expected: '1'23

In fact, for an even number of quotes, none survive, while for an odd number of quotes, only the last quote ever survives:

Escaped: \'1\'2\'3
Actual: 12'3
Expected: '1'2'3

Escaped: \'1\'2\'3\'4\'5\'6\'7\'8\'9
Actual: 12345678'9
Expected: '1'2'3'4'5'6'7'8'9

Wrapping the entire argument with single quotes does not change the behavior:

Escaped: '\'1\'2\'3\'4\'5\'6\'7\'8\'9'
Actual: 12345678'9
Expected: '1'2'3'4'5'6'7'8'9

Besides single quotes, backslashes also act strangely. Many times they work properly:

Escaped: a\\b\\c
Actual: a\b\c
Expected: a\b\c

But when escape sequences are in a sequence, they act unexpectedly:

Escaped: \\\\
Actual: \
Expected: \\

Escaped: a\\\'b
Actual: a'b
Expected: a\'b

The next example becomes truncated. My guess is that it is interpreting "\n" as a new line.

Escaped: a\\nice\\day
Actual: a
Expected: a\nice\day

Can anyone advise if I'm using the correct syntax/this is an issue, or if there's something I'm missing/doing wrong?

Version: FreeSWITCH Version 1.10.7-release-19-883d2cb662~64bit (-release-19-883d2cb662 64bit)


_________________________________________________________________________

The FreeSWITCH project is sponsored by SignalWire https://signalwire.com
Enhance your FreeSWITCH install with disruptive priced SMS and PSTN services.
Build your next product on our scalable cloud platform.

Join our online community to chat in real time https://signalwire.community

Professional FreeSWITCH Services
sales@freeswitch.com
https://freeswitch.com

Official FreeSWITCH Sites
https://freeswitch.com/oss
https://freeswitch.org/confluence
https://cluecon.com

FreeSWITCH-users mailing list
FreeSWITCH-users@lists.freeswitch.org
http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users
https://freeswitch.com
Back to top
Display posts from previous:   
Post new topic   Reply to topic    VoIP Mailing List Archives Forum Index -> freeSWITCH Users All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group

VoiceMeUp - Corporate & Wholesale VoIP Services