aboutsummaryrefslogtreecommitdiffstats
path: root/apps/app_voicemail.c
diff options
context:
space:
mode:
authortilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b>2007-01-09 13:45:14 +0000
committertilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b>2007-01-09 13:45:14 +0000
commitc5664a7a2b50e05c6443b894333e50bb5fd0f556 (patch)
tree949f4c2c578cd424f29ca063fe99da8c90e1d21f /apps/app_voicemail.c
parentbd5fd68b95a80eaac18e611c34181b7ae3f2b293 (diff)
Merged revisions 50151 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4 ................ r50151 | tilghman | 2007-01-09 07:40:45 -0600 (Tue, 09 Jan 2007) | 12 lines Merged revisions 50150 via svnmerge from https://origsvn.digium.com/svn/asterisk/branches/1.2 ........ r50150 | tilghman | 2007-01-09 07:30:04 -0600 (Tue, 09 Jan 2007) | 4 lines The advent of realtime has enabled people to use commas in the fullname field. This could cause an issue with sending voicemails, when the field is unquoted. (Issue 8595) ........ ................ git-svn-id: http://svn.digium.com/svn/asterisk/trunk@50152 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'apps/app_voicemail.c')
-rw-r--r--apps/app_voicemail.c26
1 files changed, 24 insertions, 2 deletions
diff --git a/apps/app_voicemail.c b/apps/app_voicemail.c
index a4bcd9ea8..6a1ce5f5d 100644
--- a/apps/app_voicemail.c
+++ b/apps/app_voicemail.c
@@ -1848,6 +1848,22 @@ static void prep_email_sub_vars(struct ast_channel *ast, struct ast_vm_user *vmu
pbx_builtin_setvar_helper(ast, "VM_CATEGORY", category ? ast_strdupa(category) : "no category");
}
+static char *quote(const char *from, char *to, size_t len)
+{
+ char *ptr = to;
+ *ptr++ = '"';
+ for (; ptr < to + len - 1; from++) {
+ if (*from == '"')
+ *ptr++ = '\\';
+ else if (*from == '\0')
+ break;
+ *ptr++ = *from;
+ }
+ if (ptr < to + len - 1)
+ *ptr++ = '"';
+ *ptr = '\0';
+ return to;
+}
/*
* fill in *tm for current time according to the proper timezone, if any.
* Return tm so it can be used as a function argument.
@@ -1896,6 +1912,8 @@ static void make_email_file(FILE *p, char *srcemail, struct ast_vm_user *vmu, in
char dur[256];
char tmpcmd[256];
struct tm tm;
+ char *passdata2;
+ size_t len_passdata;
gethostname(host, sizeof(host)-1);
if (strchr(srcemail, '@'))
@@ -1919,7 +1937,9 @@ static void make_email_file(FILE *p, char *srcemail, struct ast_vm_user *vmu, in
memset(passdata, 0, vmlen);
prep_email_sub_vars(ast, vmu, msgnum + 1, context, mailbox, cidnum, cidname, dur, date, passdata, vmlen, category);
pbx_substitute_variables_helper(ast, fromstring, passdata, vmlen);
- fprintf(p, "From: %s <%s>\r\n",passdata,who);
+ len_passdata = strlen(passdata) * 2 + 1;
+ passdata2 = alloca(len_passdata);
+ fprintf(p, "From: %s <%s>\r\n", quote(passdata, passdata2, len_passdata), who);
} else
ast_log(LOG_WARNING, "Cannot allocate workspace for variable substitution\n");
ast_channel_free(ast);
@@ -1927,7 +1947,9 @@ static void make_email_file(FILE *p, char *srcemail, struct ast_vm_user *vmu, in
ast_log(LOG_WARNING, "Cannot allocate the channel for variables substitution\n");
} else
fprintf(p, "From: Asterisk PBX <%s>\r\n", who);
- fprintf(p, "To: %s <%s>\r\n", vmu->fullname, vmu->email);
+ len_passdata = strlen(vmu->fullname) * 2 + 1;
+ passdata2 = alloca(len_passdata);
+ fprintf(p, "To: %s <%s>\r\n", quote(vmu->fullname, passdata2, len_passdata), vmu->email);
if (emailsubject) {
struct ast_channel *ast;
if ((ast = ast_channel_alloc(0, AST_STATE_DOWN, 0, 0, 0))) {