mirror of
https://github.com/asterisk/asterisk.git
synced 2025-11-07 02:18:15 +00:00
Merged revisions 161349-161350 via svnmerge from
https://origsvn.digium.com/svn/asterisk/trunk ........ r161349 | seanbright | 2008-12-05 10:56:15 -0500 (Fri, 05 Dec 2008) | 5 lines When using IMAP_STORAGE, it's important to convert bare newlines (\n) in emailbody and pagerbody to CR-LF so that the IMAP server doesn't spit out an error. This was informally reported on #asterisk-dev a few weeks ago. Reviewed by Mark M. on IRC. ........ r161350 | seanbright | 2008-12-05 11:04:36 -0500 (Fri, 05 Dec 2008) | 2 lines Use ast_free() instead of free(), pointed out by eliel on IRC. ........ git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.6.0@161351 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -8923,6 +8923,51 @@ static void free_vm_zones(void)
|
|||||||
AST_LIST_UNLOCK(&zones);
|
AST_LIST_UNLOCK(&zones);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static char *substitute_escapes(const char *value)
|
||||||
|
{
|
||||||
|
char *current, *result;
|
||||||
|
|
||||||
|
/* Add 16 for fudge factor */
|
||||||
|
struct ast_str *str = ast_str_create(strlen(value) + 16);
|
||||||
|
|
||||||
|
/* Substitute strings \r, \n, and \t into the appropriate characters */
|
||||||
|
for (current = (char *) value; *current; current++) {
|
||||||
|
if (*current == '\\') {
|
||||||
|
current++;
|
||||||
|
if (!*current) {
|
||||||
|
ast_log(LOG_NOTICE, "Incomplete escape at end of value.\n");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
switch (*current) {
|
||||||
|
case 'r':
|
||||||
|
ast_str_append(&str, 0, "\r");
|
||||||
|
break;
|
||||||
|
case 'n':
|
||||||
|
#ifdef IMAP_STORAGE
|
||||||
|
if (!str->used || str->str[str->used - 1] != '\r') {
|
||||||
|
ast_str_append(&str, 0, "\r");
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
ast_str_append(&str, 0, "\n");
|
||||||
|
break;
|
||||||
|
case 't':
|
||||||
|
ast_str_append(&str, 0, "\t");
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
ast_log(LOG_NOTICE, "Substitution routine does not support this character: \\%c\n", *current);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
ast_str_append(&str, 0, "%c", *current);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
result = ast_strdup(str->str);
|
||||||
|
ast_free(str);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
static int load_config(int reload)
|
static int load_config(int reload)
|
||||||
{
|
{
|
||||||
struct ast_vm_user *cur;
|
struct ast_vm_user *cur;
|
||||||
@@ -9487,61 +9532,17 @@ static int load_config(int reload)
|
|||||||
adsiver = atoi(val);
|
adsiver = atoi(val);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ((val = ast_variable_retrieve(cfg, "general", "emailsubject")))
|
if ((val = ast_variable_retrieve(cfg, "general", "emailsubject"))) {
|
||||||
emailsubject = ast_strdup(val);
|
emailsubject = ast_strdup(val);
|
||||||
|
}
|
||||||
if ((val = ast_variable_retrieve(cfg, "general", "emailbody"))) {
|
if ((val = ast_variable_retrieve(cfg, "general", "emailbody"))) {
|
||||||
char *tmpread, *tmpwrite;
|
emailbody = substitute_escapes(val);
|
||||||
emailbody = ast_strdup(val);
|
|
||||||
|
|
||||||
/* substitute strings \t and \n into the appropriate characters */
|
|
||||||
tmpread = tmpwrite = emailbody;
|
|
||||||
while ((tmpwrite = strchr(tmpread, '\\'))) {
|
|
||||||
switch (tmpwrite[1]) {
|
|
||||||
case 'r':
|
|
||||||
memmove(tmpwrite + 1, tmpwrite + 2, strlen(tmpwrite + 2) + 1);
|
|
||||||
*tmpwrite = '\r';
|
|
||||||
break;
|
|
||||||
case 'n':
|
|
||||||
memmove(tmpwrite + 1, tmpwrite + 2, strlen(tmpwrite + 2) + 1);
|
|
||||||
*tmpwrite = '\n';
|
|
||||||
break;
|
|
||||||
case 't':
|
|
||||||
memmove(tmpwrite + 1, tmpwrite + 2, strlen(tmpwrite + 2) + 1);
|
|
||||||
*tmpwrite = '\t';
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
ast_log(LOG_NOTICE, "Substitution routine does not support this character: %c\n", tmpwrite[1]);
|
|
||||||
}
|
}
|
||||||
tmpread = tmpwrite + 1;
|
if ((val = ast_variable_retrieve(cfg, "general", "pagersubject"))) {
|
||||||
}
|
|
||||||
}
|
|
||||||
if ((val = ast_variable_retrieve(cfg, "general", "pagersubject")))
|
|
||||||
pagersubject = ast_strdup(val);
|
pagersubject = ast_strdup(val);
|
||||||
|
}
|
||||||
if ((val = ast_variable_retrieve(cfg, "general", "pagerbody"))) {
|
if ((val = ast_variable_retrieve(cfg, "general", "pagerbody"))) {
|
||||||
char *tmpread, *tmpwrite;
|
pagerbody = substitute_escapes(val);
|
||||||
pagerbody = ast_strdup(val);
|
|
||||||
|
|
||||||
/* substitute strings \t and \n into the appropriate characters */
|
|
||||||
tmpread = tmpwrite = pagerbody;
|
|
||||||
while ((tmpwrite = strchr(tmpread, '\\'))) {
|
|
||||||
switch (tmpwrite[1]) {
|
|
||||||
case 'r':
|
|
||||||
memmove(tmpwrite + 1, tmpwrite + 2, strlen(tmpwrite + 2) + 1);
|
|
||||||
*tmpwrite = '\r';
|
|
||||||
break;
|
|
||||||
case 'n':
|
|
||||||
memmove(tmpwrite + 1, tmpwrite + 2, strlen(tmpwrite + 2) + 1);
|
|
||||||
*tmpwrite = '\n';
|
|
||||||
break;
|
|
||||||
case 't':
|
|
||||||
memmove(tmpwrite + 1, tmpwrite + 2, strlen(tmpwrite + 2) + 1);
|
|
||||||
*tmpwrite = '\t';
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
ast_log(LOG_NOTICE, "Substitution routine does not support this character: %c\n", tmpwrite[1]);
|
|
||||||
}
|
|
||||||
tmpread = tmpwrite + 1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
AST_LIST_UNLOCK(&users);
|
AST_LIST_UNLOCK(&users);
|
||||||
ast_config_destroy(cfg);
|
ast_config_destroy(cfg);
|
||||||
|
|||||||
Reference in New Issue
Block a user