[asterisk-users] Escaping parameter for ODBC function

Leandro Dardini ldardini at gmail.com
Mon Aug 31 10:05:02 CDT 2015


Hello,
I just noticed a weird behavior when using ODBC functions. If the content
of any of the paramter has a "=" inside, then the function is not processed
correctly by asterisk.

Let's take for example the following ODBC function in func_odbc.conf

[LOG_SMS]
dsn=asterisk1,asterisk2
synopsis=Log the route of a SMS
writesql=INSERT INTO
sm_smslogs(sm_te_id,sm_date,sm_direction,sm_sourceraw,sm_destraw,sm_from,sm_to,sm_body,sm_fullresult,sm_response)
values
('${ARG1}',NOW(),'${ARG2}','${ARG3}','${ARG4}','${ARG5}','${ARG6}','${SQL_ESC(${ARG7})}','${SQL_ESC(${ARG8})}','${SQL_ESC(${VAL1})}')

When it is called using:

[2015-08-31 16:35:16] VERBOSE[29562][C-00000001] pbx.c: Executing
[103 at astsms:37] Set("Message/ast_msg_queue", "ODBC_LOG_SMS(1,ONNET,<
sip:102-DEVEL at devel.mirtapbx.com;transport=UDP>,sip:103 at devel.mirtapbx.com;transport=UDP,102,103,Second
test 4,)=SUCCESS") in new stack

Asterisk interprets the first "=" as assignment. In the debug log I found:

Variable: ODBC_LOG_SMS(1,ONNET,<sip:102-DEVEL at devel.mirtapbx.com;transport
AppData: UDP>,sip:103 at devel.mirtapbx.com;transport=UDP,102,103,Second test
4,)=SUCCESS

And the ODBC function is not executed.

Is there a way, beside using REPLACE, to avoid this problem?

Leandro
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-users/attachments/20150831/915ced97/attachment.html>


More information about the asterisk-users mailing list