mirror of
https://github.com/asterisk/asterisk.git
synced 2025-10-12 15:45:18 +00:00
app_read does not break from prompt loop with user terminated empty string
In app.c, ast_app_getdata is called to stream the prompts and receive DTMF input. If ast_app_getdata() receives an empty string caused by the user inputing the end of string character, in this case '#', it should break from the prompt loop and return to app_read, but instead it cycles through all the prompts. I've added a return value for this special case in ast_readstring() which uses an enum I've delcared in apps.h. This enum is now used as a return value for ast_app_getdata(). (closes issue #14279) Reported by: Marquis Patches: fix_app_read.patch uploaded by Marquis (license 32) read-ampersanmd.patch2 uploaded by dvossel (license 671) Tested by: Marquis, dvossel Review: http://reviewboard.digium.com/r/177/ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@180032 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
10
main/app.c
10
main/app.c
@@ -121,7 +121,7 @@ int ast_app_dtget(struct ast_channel *chan, const char *context, char *collect,
|
||||
* \param maxlen How many digits to read (maximum)
|
||||
* \param timeout set timeout to 0 for "standard" timeouts. Set timeout to -1 for
|
||||
* "ludicrous time" (essentially never times out) */
|
||||
int ast_app_getdata(struct ast_channel *c, const char *prompt, char *s, int maxlen, int timeout)
|
||||
enum ast_getdata_result ast_app_getdata(struct ast_channel *c, const char *prompt, char *s, int maxlen, int timeout)
|
||||
{
|
||||
int res = 0, to, fto;
|
||||
char *front, *filename;
|
||||
@@ -158,10 +158,14 @@ int ast_app_getdata(struct ast_channel *c, const char *prompt, char *s, int maxl
|
||||
to = c->pbx ? c->pbx->dtimeoutms : 2000;
|
||||
}
|
||||
res = ast_readstring(c, s, maxlen, to, fto, "#");
|
||||
if (!ast_strlen_zero(s))
|
||||
if (res == AST_GETDATA_EMPTY_END_TERMINATED) {
|
||||
return res;
|
||||
}
|
||||
if (!ast_strlen_zero(s)) {
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user