diff options
author | Kinsey Moore <kmoore@digium.com> | 2014-08-27 15:39:35 +0000 |
---|---|---|
committer | Kinsey Moore <kmoore@digium.com> | 2014-08-27 15:39:35 +0000 |
commit | bf850181076c786d2c9e5e7f23e205547c7140cb (patch) | |
tree | 3a384bb94539e77298c351ae79dcff9453bc0b25 /main/utils.c | |
parent | d199536a04690e3034d02243e197071d70fc4f9c (diff) |
CallerID: Fix parsing of malformed callerid
This allows the callerid parsing function to handle malformed input
strings and strings containing escaped and unescaped double quotes.
This also adds a unittest to cover many of the cases where the parsing
algorithm previously failed.
Review: https://reviewboard.asterisk.org/r/3923/
Review: https://reviewboard.asterisk.org/r/3933/
........
Merged revisions 422112 from http://svn.asterisk.org/svn/asterisk/branches/1.8
........
Merged revisions 422113 from http://svn.asterisk.org/svn/asterisk/branches/11
........
Merged revisions 422114 from http://svn.asterisk.org/svn/asterisk/branches/12
........
Merged revisions 422154 from http://svn.asterisk.org/svn/asterisk/branches/13
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@422158 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'main/utils.c')
-rw-r--r-- | main/utils.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/main/utils.c b/main/utils.c index ba646c44b..229080b83 100644 --- a/main/utils.c +++ b/main/utils.c @@ -483,6 +483,29 @@ char *ast_escape_quoted(const char *string, char *outbuf, int buflen) return outbuf; } + +void ast_unescape_quoted(char *quote_str) +{ + int esc_pos; + int unesc_pos; + int quote_str_len = strlen(quote_str); + + for (esc_pos = 0, unesc_pos = 0; + esc_pos < quote_str_len; + esc_pos++, unesc_pos++) { + if (quote_str[esc_pos] == '\\') { + /* at least one more char and current is \\ */ + esc_pos++; + if (esc_pos >= quote_str_len) { + break; + } + } + + quote_str[unesc_pos] = quote_str[esc_pos]; + } + quote_str[unesc_pos] = '\0'; +} + int ast_xml_escape(const char *string, char * const outbuf, const size_t buflen) { char *dst = outbuf; |