Index: apps/app_voicemail.c =================================================================== --- apps/app_voicemail.c (revision 115812) +++ apps/app_voicemail.c (working copy) @@ -1790,6 +1790,7 @@ char fname[256]; char dur[256]; char tmpcmd[256]; + char enc_cidnum[256], enc_cidname[256]; struct tm tm; char *passdata2; size_t len_passdata; @@ -1799,6 +1800,8 @@ #define ENDL "\n" #endif + ast_uri_encode(cidnum, enc_cidnum, sizeof(enc_cidnum), 0); + ast_uri_encode(cidname, enc_cidname, sizeof(enc_cidname), 0); gethostname(host, sizeof(host) - 1); if (strchr(srcemail, '@')) ast_copy_string(who, srcemail, sizeof(who)); @@ -1819,7 +1822,7 @@ int vmlen = strlen(fromstring)*3 + 200; if ((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); @@ -1866,8 +1869,8 @@ 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)) fprintf(p, "X-Asterisk-VM-Category: %s" ENDL, category); @@ -1875,9 +1878,9 @@ 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); + fprintf(p, "X-Asterisk-CallerID: %s" ENDL, enc_cidnum); if (!ast_strlen_zero(cidname)) - fprintf(p, "X-Asterisk-CallerIDName: %s" ENDL, cidname); + fprintf(p, "X-Asterisk-CallerIDName: %s" ENDL, enc_cidname); fprintf(p, "MIME-Version: 1.0" ENDL); if (attach_user_voicemail) { /* Something unique. */ Index: main/utils.c =================================================================== --- main/utils.c (revision 115812) +++ main/utils.c (working copy) @@ -456,7 +456,7 @@ /* If there's no characters to convert, just go through and don't do anything */ while (*ptr) { - if (((unsigned char) *ptr) > 127 || (doreserved && strchr(reserved, *ptr)) ) { + if (((unsigned char) *ptr) > 127 || ((unsigned char) *ptr) < 32 || (doreserved && strchr(reserved, *ptr)) ) { /* Oops, we need to start working here */ if (!buf) { buf = outbuf;