[asterisk-commits] tilghman: branch 1.6.0 r124964 - in /branches/1.6.0: ./ apps/app_voicemail.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Jun 24 16:39:38 CDT 2008


Author: tilghman
Date: Tue Jun 24 16:39:37 2008
New Revision: 124964

URL: http://svn.digium.com/view/asterisk?view=rev&rev=124964
Log:
Merged revisions 124912 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/trunk

................
r124912 | tilghman | 2008-06-24 16:18:52 -0500 (Tue, 24 Jun 2008) | 16 lines

Merged revisions 124910 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
r124910 | tilghman | 2008-06-24 16:08:52 -0500 (Tue, 24 Jun 2008) | 8 lines

Occasionally control characters find their way into CallerID.  These need to
be stripped prior to placing CallerID in the headers of an email.
(closes issue #12759)
 Reported by: RobH
 Patches: 
       20080602__bug12759__2.diff.txt uploaded by Corydon76 (license 14)
 Tested by: RobH

........

................

Modified:
    branches/1.6.0/   (props changed)
    branches/1.6.0/apps/app_voicemail.c

Propchange: branches/1.6.0/
------------------------------------------------------------------------------
Binary property 'trunk-merged' - no diff available.

Modified: branches/1.6.0/apps/app_voicemail.c
URL: http://svn.digium.com/view/asterisk/branches/1.6.0/apps/app_voicemail.c?view=diff&rev=124964&r1=124963&r2=124964
==============================================================================
--- branches/1.6.0/apps/app_voicemail.c (original)
+++ branches/1.6.0/apps/app_voicemail.c Tue Jun 24 16:39:37 2008
@@ -677,6 +677,21 @@
 static int __has_voicemail(const char *context, const char *mailbox, const char *folder, int shortcircuit);
 #endif
 
+static char *strip_control(const char *input, char *buf, size_t buflen)
+{
+	char *bufptr = buf;
+	for (; *input; input++) {
+		if (*input < 32) {
+			continue;
+		}
+		*bufptr++ = *input;
+		if (bufptr == buf + buflen - 1) {
+			break;
+		}
+	}
+	*bufptr = '\0';
+	return buf;
+}
 
 
 static void populate_defaults(struct ast_vm_user *vmu)
@@ -1966,6 +1981,7 @@
 	char dur[256];
 	char tmpcmd[256];
 	struct ast_tm tm;
+	char enc_cidnum[256], enc_cidname[256];
 	char *passdata2;
 	size_t len_passdata;
 	char *greeting_attachment;
@@ -1976,6 +1992,8 @@
 #define ENDL "\n"
 #endif
 
+	strip_control(cidnum, enc_cidnum, sizeof(enc_cidnum));
+	strip_control(cidname, enc_cidname, sizeof(enc_cidname));
 	gethostname(host, sizeof(host) - 1);
 
 	if (strchr(srcemail, '@'))
@@ -2001,16 +2019,18 @@
 			int vmlen = strlen(fromstring) * 3 + 200;
 			passdata = alloca(vmlen);
 			memset(passdata, 0, vmlen);
-			prep_email_sub_vars(ast, vmu, msgnum + 1, context, mailbox, cidnum, cidname, dur, date, passdata, vmlen, category);
+			prep_email_sub_vars(ast, vmu, msgnum + 1, context, mailbox, enc_cidnum, enc_cidname, dur, date, passdata, vmlen, category);
 			pbx_substitute_variables_helper(ast, fromstring, passdata, vmlen);
 			len_passdata = strlen(passdata) * 2 + 3;
 			passdata2 = alloca(len_passdata);
 			fprintf(p, "From: %s <%s>" ENDL, quote(passdata, passdata2, len_passdata), who);
 			ast_channel_free(ast);
-		} else
+		} else {
 			ast_log(LOG_WARNING, "Cannot allocate the channel for variables substitution\n");
-	} else
+		}
+	} else {
 		fprintf(p, "From: Asterisk PBX <%s>" ENDL, who);
+	}
 	len_passdata = strlen(vmu->fullname) * 2 + 3;
 	passdata2 = alloca(len_passdata);
 	fprintf(p, "To: %s <%s>" ENDL, quote(vmu->fullname, passdata2, len_passdata), vmu->email);
@@ -2021,16 +2041,19 @@
 			int vmlen = strlen(emailsubject) * 3 + 200;
 			passdata = alloca(vmlen);
 			memset(passdata, 0, vmlen);
-			prep_email_sub_vars(ast, vmu, msgnum + 1, context, mailbox, cidnum, cidname, dur, date, passdata, vmlen, category);
+			prep_email_sub_vars(ast, vmu, msgnum + 1, context, mailbox, enc_cidnum, enc_cidname, dur, date, passdata, vmlen, category);
 			pbx_substitute_variables_helper(ast, emailsubject, passdata, vmlen);
 			fprintf(p, "Subject: %s" ENDL, passdata);
 			ast_channel_free(ast);
-		} else
+		} else {
 			ast_log(LOG_WARNING, "Cannot allocate the channel for variables substitution\n");
-	} else if (ast_test_flag((&globalflags), VM_PBXSKIP))
+		}
+	} else if (ast_test_flag((&globalflags), VM_PBXSKIP)) {
 		fprintf(p, "Subject: New message %d in mailbox %s" ENDL, msgnum + 1, mailbox);
-	else
+	} else {
 		fprintf(p, "Subject: [PBX]: New message %d in mailbox %s" ENDL, msgnum + 1, mailbox);
+	}
+
 	fprintf(p, "Message-ID: <Asterisk-%d-%d-%s-%d@%s>" ENDL, msgnum + 1, (unsigned int)ast_random(), mailbox, (int)getpid(), host);
 	if (imap) {
 		/* additional information needed for IMAP searching */
@@ -2041,19 +2064,22 @@
 		fprintf(p, "X-Asterisk-VM-Extension: %s" ENDL, mailbox);
 		fprintf(p, "X-Asterisk-VM-Priority: %d" ENDL, chan->priority);
 		fprintf(p, "X-Asterisk-VM-Caller-channel: %s" ENDL, chan->name);
-		fprintf(p, "X-Asterisk-VM-Caller-ID-Num: %s" ENDL, cidnum);
-		fprintf(p, "X-Asterisk-VM-Caller-ID-Name: %s" ENDL, cidname);
+		fprintf(p, "X-Asterisk-VM-Caller-ID-Num: %s" ENDL, enc_cidnum);
+		fprintf(p, "X-Asterisk-VM-Caller-ID-Name: %s" ENDL, enc_cidname);
 		fprintf(p, "X-Asterisk-VM-Duration: %d" ENDL, duration);
-		if (!ast_strlen_zero(category)) 
+		if (!ast_strlen_zero(category)) {
 			fprintf(p, "X-Asterisk-VM-Category: %s" ENDL, category);
+		}
 		fprintf(p, "X-Asterisk-VM-Message-Type: %s" ENDL, msgnum > -1 ? "Message" : greeting_attachment);
 		fprintf(p, "X-Asterisk-VM-Orig-date: %s" ENDL, date);
 		fprintf(p, "X-Asterisk-VM-Orig-time: %ld" ENDL, (long)time(NULL));
 	}
-	if (!ast_strlen_zero(cidnum))
-		fprintf(p, "X-Asterisk-CallerID: %s" ENDL, cidnum);
-	if (!ast_strlen_zero(cidname))
-		fprintf(p, "X-Asterisk-CallerIDName: %s" ENDL, cidname);
+	if (!ast_strlen_zero(cidnum)) {
+		fprintf(p, "X-Asterisk-CallerID: %s" ENDL, enc_cidnum);
+	}
+	if (!ast_strlen_zero(cidname)) {
+		fprintf(p, "X-Asterisk-CallerIDName: %s" ENDL, enc_cidname);
+	}
 	fprintf(p, "MIME-Version: 1.0" ENDL);
 	if (attach_user_voicemail) {
 		/* Something unique. */




More information about the asterisk-commits mailing list