Am pretty new to Asterisk but a fairly seasoned programmer. Am trying to figure out how one would be able to return a literal ‘&’ character using Asterisk’s real time architecture. While there are many ways to accomplish dynamic configs with Asterisk (AMI, AGI, CURL, ODBC, etc), I am currently relying on using ODBC realtime for the core configs, and using CURL for dialplan-related configs. Each of these methods are successfully returning data in the line-by-line method like:
category=something&cat_metric=something&commented=something&var_metric=something&var_name=something&var_val=something&filename=something
This method is okay and we have realtime working very well. But of course there is always one little thing…I would like to return data to Asterisk using the working ODBC and CURL methods but am finding that if I return data via CURL that contains an & character in the var_value data, Asterisk does not like this. Reviewing the res_config_curl.c script shows me that Asterisk uses the & character to exclusively determine the field pairs returned from realtime as outlined in the category= line above. So an & in the var_value data just makes asterisk think it has more fields than it really does.
Two instances where realtime data return with &'s in the data is failing me:
- I am defining hints for SIP extensions. It is very easy to do, but I want to include a standard extension state hint (ie: SIP/nnn) AND also a custom hint for DND (ie: Custom:DNDnnn). In flat file, this hint would be combined as:
exten => nnn,hint,SIP/nnn&Custom:DNDnnn
But when we issue dialplan reload we end up with:
exten => nnn,hint,SIP/nnn
This produces NO error, but we do NOT have our custom DND hint defined as desired.
- I am defining an outbound context that handles invalid dialing patterns. I want this special context to playback a series of audio files if an invalid pattern is matched. The reason the context is dynamic and not programmed in flat extensions.conf is because we want our PBX to prevent users from altering allowed dial patterns. So this [outgoing-restricted] context is loaded dynamically and always contains the invalid patterns. When invalid dialing pattern is matched, we want to run Playback() application using combined audio files. How does Asterisk’s Playback() application expect multiple files? Via an & character, so the realtime return should look like:
exten => _011.,1,Playback(im-sorry&but&the-number-you-dialed&is-curntly-unavail)
But when we issue dialplan reload we end up with:
exten => _011.,1,Playback(im-sorry
And Asterisk produces errors due to missing trailing ).
It seems when attempting to return these values using CURL (which uses the & character to delineate fields as outlined above, the & characters are being viewed by the realtime parser as field separators and not part of the data value, which of course truncates some of the returned data.
While we can easily return one line for every audio file in Playback(), it is even more cumbersome than already, and same method will not work with hints because there can only be one hint (-1) priority for any one extension.
Does anyone have an idea they can share with me to help me overcome this? I know that Asterisk can simply be recompiled and I could change the separator character in res_config_curl.c from an & to something else but I am hesitant to do that and am hoping someone else has run into this in years past and knows an easy work around.
Thanks in advance…