[Freeswitch-users] originate api: Escaping variable names/values
sm at opencluster.com.au
Tue Nov 23 06:48:30 UTC 2021
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 at 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)
While this doesn't:
In fact, for an even number of quotes, none survive, while for an odd number of quotes, only the last quote ever survives:
Wrapping the entire argument with single quotes does not change the behavior:
Besides single quotes, backslashes also act strangely. Many times they work properly:
But when escape sequences are in a sequence, they act unexpectedly:
The next example becomes truncated. My guess is that it is interpreting "\n" as a new line.
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)
More information about the FreeSWITCH-users