我如何在 Asterisk 中使用 REPLACE 来转义输入
How do I use REPLACE in Asterisk to escape input
我想在 Asterisk 中将 \ 转义为 \\ 和 " 为 \"。我试过使用 REPLACE,但无法正常工作。我目前的做法如下
exten => sms,1,Set(UNSAFESMSTXT=${REPLACE(SMSTXT,\,\\)})
exten => sms,2,Set(SAFESMSTXT=${REPLACE(UNSAFESMSTXT,",\")})
; Echo escaped input to terminal safely
exten => sms,n,System(echo "${SAFESMSTXT}")
当我发送 echo hi"echo hi 时,我得到了错误
ERROR[8239]: func_strings.c:804 replace: The characters to search for and the variable name must not be empty.
如果有帮助,我会使用 chan_mobile。
功能描述中的nto cleat是什么?
Asterisk func REPLACE
Synopsis:
Replace a set of characters in a given string with another character.
Description:
Iterates through a string replacing all the <find-chars> with <replace-ch
ar>. <replace-char> may be either empty or contain one character. If empty,
all <find-chars> will be deleted from the output.
NOTE: The replacement only occurs in the output. The original variable is
not altered.
Syntax:
REPLACE(varname,find-chars[,replace-char])
您使用了 \" 而不是 "
我想在 Asterisk 中将 \ 转义为 \\ 和 " 为 \"。我试过使用 REPLACE,但无法正常工作。我目前的做法如下
exten => sms,1,Set(UNSAFESMSTXT=${REPLACE(SMSTXT,\,\\)})
exten => sms,2,Set(SAFESMSTXT=${REPLACE(UNSAFESMSTXT,",\")})
; Echo escaped input to terminal safely
exten => sms,n,System(echo "${SAFESMSTXT}")
当我发送 echo hi"echo hi 时,我得到了错误
ERROR[8239]: func_strings.c:804 replace: The characters to search for and the variable name must not be empty.
如果有帮助,我会使用 chan_mobile。
功能描述中的nto cleat是什么?
Asterisk func REPLACE
Synopsis:
Replace a set of characters in a given string with another character.
Description:
Iterates through a string replacing all the <find-chars> with <replace-ch
ar>. <replace-char> may be either empty or contain one character. If empty,
all <find-chars> will be deleted from the output.
NOTE: The replacement only occurs in the output. The original variable is
not altered.
Syntax:
REPLACE(varname,find-chars[,replace-char])
您使用了 \" 而不是 "