diff options
author | Richard Mudgett <rmudgett@digium.com> | 2013-11-02 01:15:11 +0000 |
---|---|---|
committer | Richard Mudgett <rmudgett@digium.com> | 2013-11-02 01:15:11 +0000 |
commit | 0721b1de836da3e91ac71d54c972caa80a9e2379 (patch) | |
tree | eda35e14fae8ea28740bec3e7110f4fa68bb6ba2 /main/config.c | |
parent | 5401b2bfbf9c31570439c62a3ed7165052610b51 (diff) |
config: Allow ConfBridge DTMF menus to have '#' as the first digit.
ConfBridge allows custom DTMF menus to be created in the confbridge.conf
file by assigning a DTMF key sequence to a sequence of actions as follows:
DTMF-sequence = action,action...
Unfortunately, the normal config file processing code interprets an
initial '#' character as starting a directive such as #include.
* Add the ability to escape the first non-blank character in a config line
so the '#' character can be used without triggering the directive
processing code.
(closes issue AFS-2)
(closes issue ASTERISK-22478)
Reported by: Nicolas Tanski
Patches:
jira_asterisk_22478_v11.patch (license #5621) patch uploaded by rmudgett (modified)
Review: https://reviewboard.asterisk.org/r/2969/
........
Merged revisions 402407 from http://svn.asterisk.org/svn/asterisk/branches/11
........
Merged revisions 402416 from http://svn.asterisk.org/svn/asterisk/branches/12
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@402417 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'main/config.c')
-rw-r--r-- | main/config.c | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/main/config.c b/main/config.c index 112623104..b8356a9bc 100644 --- a/main/config.c +++ b/main/config.c @@ -1419,14 +1419,26 @@ static int process_text_line(struct ast_config *cfg, struct ast_category **cat, } else { /* Just a line (variable = value) */ int object = 0; + int is_escaped; + if (!(*cat)) { ast_log(LOG_WARNING, "parse error: No category context for line %d of %s\n", lineno, configfile); return -1; } - c = strchr(cur, '='); - if (c && c > cur && (*(c - 1) == '+')) { + is_escaped = cur[0] == '\\'; + if (is_escaped) { + /* First character is escaped. */ + ++cur; + if (cur[0] < 33) { + ast_log(LOG_ERROR, "Invalid escape in line %d of %s\n", lineno, configfile); + return -1; + } + } + c = strchr(cur + is_escaped, '='); + + if (c && c > cur + is_escaped && (*(c - 1) == '+')) { struct ast_variable *var, *replace = NULL; struct ast_str **str = ast_threadstorage_get(&appendbuf, sizeof(*str)); @@ -1462,8 +1474,11 @@ static int process_text_line(struct ast_config *cfg, struct ast_category **cat, object = 1; c++; } + cur = ast_strip(cur); set_new_variable: - if ((v = ast_variable_new(ast_strip(cur), ast_strip(c), S_OR(suggested_include_file, cfg->include_level == 1 ? "" : configfile)))) { + if (ast_strlen_zero(cur)) { + ast_log(LOG_WARNING, "No variable name in line %d of %s\n", lineno, configfile); + } else if ((v = ast_variable_new(cur, ast_strip(c), S_OR(suggested_include_file, cfg->include_level == 1 ? "" : configfile)))) { v->lineno = lineno; v->object = object; *last_cat = 0; |