[asterisk-bugs] [JIRA] (ASTERISK-28459) Asterisk is dropping part of a string passed to functions
Jan Blom (JIRA)
noreply at issues.asterisk.org
Mon Jun 24 05:08:47 CDT 2019
[ https://issues.asterisk.org/jira/browse/ASTERISK-28459?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Jan Blom updated ASTERISK-28459:
--------------------------------
Description:
We need to pass around variables containing special characters, i.e. non-alfanumeric chars. This typically include SIP Call-Id from some vendors.
We have so far managed to deal with all situations using quotes and escape character in accordance with https://wiki.asterisk.org/wiki/display/AST/Parameter+Quoting.
However when having a string containing a closing parenthesis _and_ a colon, the string gets cut-off when passing it to a function. This becomes a big issue for us since this affects ODBC database calls as well as for example SQL_ESC() function.
Calling this dialplan results in the output below:
{code}
[test]
exten => main,1,NoOp
same => n,Set(LOCAL(input)=1234ab)cd:efg)
same => n,Verbose(0,--- Test 1 ---)
same => n,Verbose(0,Input: ${input})
same => n,Gosub(sub,1(${input}))
same => n,Set(LOCAL(output)=${GOSUB_RETVAL})
same => n,Verbose(0,Output: ${output})
same => n,Verbose(0,Function: ${PASSTHRU(${input})})
same => n,Verbose(0,--- Test 2 ---)
same => n,Verbose(0,Input: ${input})
same => n,Gosub(sub,1("${input}"))
same => n,Set(LOCAL(output)=${GOSUB_RETVAL})
same => n,Verbose(0,Output: ${output})
same => n,Verbose(0,Function: ${PASSTHRU("${input}")})
same => n,Verbose(0,--- Test done ---)
same => n,Return
exten => sub,1,NoOp
same => n,Verbose(0,In sub: ${ARG1})
same => n,Return(${ARG1})
{code}
Result:
{noformat}
--- Test 1 ---
Input: 1234ab)cd:efg
In sub: 1234ab)cd:efg
Output: 1234ab)cd:efg
Function: 1234ab
--- Test 2 ---
Input: 1234ab)cd:efg
In sub: "1234ab)cd:efg"
Output: "1234ab)cd:efg"
Function: "1234ab
--- Test done ---
{noformat}
You can see the cut-off string returned from PASSTHRU(). We could use any function that takes a string as input and have the same result. The test shows that calling subroutines with Gosub works fine though.
It doesn't matter if we surround the string in quotes (the difference between Test 1 ans Test 2) or if we escape the parenthesis and/or colon in any combination with a backslash. We always get the corrupted string passed into the function.
We haven't been able to find any workaround to this problem. It breaks our database calling, using ODBC.
was:
We need to pass around variables containing special characters, i.e. non-alfanumeric chars. This typically include SIP Call-Id from some vendors.
We have so far managed to deal with all situations using quotes and escape character in accordance with https://wiki.asterisk.org/wiki/display/AST/Parameter+Quoting.
However when having a string containing a closing parenthesis _and_ a colon, the string gets cut-off when passing it to a function. This becomes a big issue for us since this affects ODBC database calls as well as for example SQL_ESC() function.
Calling this dialplan results in the output below:
{code}
[test]
exten => main,1,NoOp
same => n,Set(LOCAL(input)=1234ab)cd:efg)
same => n,Verbose(0,--- Test 1 ---)
same => n,Verbose(0,Input: ${input})
same => n,Gosub(sub,1(${input}))
same => n,Set(LOCAL(output)=${GOSUB_RETVAL})
same => n,Verbose(0,Output: ${output})
same => n,Verbose(0,Function: ${PASSTHRU(${input})})
same => n,Verbose(0,--- Test 2 ---)
same => n,Verbose(0,Input: ${input})
same => n,Gosub(sub,1("${input}"))
same => n,Set(LOCAL(output)=${GOSUB_RETVAL})
same => n,Verbose(0,Output: ${output})
same => n,Verbose(0,Function: ${PASSTHRU("${input}")})
same => n,Verbose(0,--- Test done ---)
same => n,Return
exten => sub,1,NoOp
same => n,Verbose(0,In sub: ${ARG1})
same => n,Return(${ARG1})
{code}
Result:
{noformat}
--- Test 1 ---
Input: 1234ab)cd:efg
In sub: 1234ab)cd:efg
Output: 1234ab)cd:efg
Function: 1234ab
--- Test 2 ---
Input: 1234ab)cd:efg
In sub: "1234ab)cd:efg"
Output: "1234ab)cd:efg"
Function: "1234ab
--- Test done ---
{noformat}
You can see the cut-off string returned from PASSTHRU(). We could use any function that takes a string as input and have the same result. The test shows that calling subroutines with Gosub works fine though.
It doesn't matter if we surround the string in quotes (the difference between Test 1 ans Test 2) or if we escape the parenthesis and/or colon in any combination with a backslash. We always get the corrupted string passed into the function.
We haven't been to find any workaround to this problem. It breaks our database calling, using ODBC.
> Asterisk is dropping part of a string passed to functions
> ---------------------------------------------------------
>
> Key: ASTERISK-28459
> URL: https://issues.asterisk.org/jira/browse/ASTERISK-28459
> Project: Asterisk
> Issue Type: Bug
> Security Level: None
> Components: Functions/General
> Affects Versions: 16.4.0
> Environment: CentOS Linux release 7.6 with Asterisk 16.4.0
> Reporter: Jan Blom
> Severity: Minor
>
> We need to pass around variables containing special characters, i.e. non-alfanumeric chars. This typically include SIP Call-Id from some vendors.
> We have so far managed to deal with all situations using quotes and escape character in accordance with https://wiki.asterisk.org/wiki/display/AST/Parameter+Quoting.
> However when having a string containing a closing parenthesis _and_ a colon, the string gets cut-off when passing it to a function. This becomes a big issue for us since this affects ODBC database calls as well as for example SQL_ESC() function.
> Calling this dialplan results in the output below:
> {code}
> [test]
> exten => main,1,NoOp
> same => n,Set(LOCAL(input)=1234ab)cd:efg)
> same => n,Verbose(0,--- Test 1 ---)
> same => n,Verbose(0,Input: ${input})
> same => n,Gosub(sub,1(${input}))
> same => n,Set(LOCAL(output)=${GOSUB_RETVAL})
> same => n,Verbose(0,Output: ${output})
> same => n,Verbose(0,Function: ${PASSTHRU(${input})})
> same => n,Verbose(0,--- Test 2 ---)
> same => n,Verbose(0,Input: ${input})
> same => n,Gosub(sub,1("${input}"))
> same => n,Set(LOCAL(output)=${GOSUB_RETVAL})
> same => n,Verbose(0,Output: ${output})
> same => n,Verbose(0,Function: ${PASSTHRU("${input}")})
> same => n,Verbose(0,--- Test done ---)
> same => n,Return
> exten => sub,1,NoOp
> same => n,Verbose(0,In sub: ${ARG1})
> same => n,Return(${ARG1})
> {code}
> Result:
> {noformat}
> --- Test 1 ---
> Input: 1234ab)cd:efg
> In sub: 1234ab)cd:efg
> Output: 1234ab)cd:efg
> Function: 1234ab
> --- Test 2 ---
> Input: 1234ab)cd:efg
> In sub: "1234ab)cd:efg"
> Output: "1234ab)cd:efg"
> Function: "1234ab
> --- Test done ---
> {noformat}
> You can see the cut-off string returned from PASSTHRU(). We could use any function that takes a string as input and have the same result. The test shows that calling subroutines with Gosub works fine though.
> It doesn't matter if we surround the string in quotes (the difference between Test 1 ans Test 2) or if we escape the parenthesis and/or colon in any combination with a backslash. We always get the corrupted string passed into the function.
> We haven't been able to find any workaround to this problem. It breaks our database calling, using ODBC.
--
This message was sent by Atlassian JIRA
(v6.2#6252)
More information about the asterisk-bugs
mailing list