mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-05 20:20:07 +00:00
woohoo safe out put!
git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@47490 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -59,6 +59,8 @@ char *term_color_code(char *outbuf, int fgcolor, int bgcolor, int maxout);
|
|||||||
|
|
||||||
char *term_strip(char *outbuf, char *inbuf, int maxout);
|
char *term_strip(char *outbuf, char *inbuf, int maxout);
|
||||||
|
|
||||||
|
void term_filter_escapes(char *line);
|
||||||
|
|
||||||
char *term_prompt(char *outbuf, const char *inbuf, int maxout);
|
char *term_prompt(char *outbuf, const char *inbuf, int maxout);
|
||||||
|
|
||||||
char *term_prep(void);
|
char *term_prep(void);
|
||||||
|
@@ -700,8 +700,10 @@ void ast_log(int level, const char *file, int line, const char *function, const
|
|||||||
va_start(ap, fmt);
|
va_start(ap, fmt);
|
||||||
res = ast_dynamic_str_thread_set_va(&buf, BUFSIZ, &log_buf, fmt, ap);
|
res = ast_dynamic_str_thread_set_va(&buf, BUFSIZ, &log_buf, fmt, ap);
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
if (res != AST_DYNSTR_BUILD_FAILED)
|
if (res != AST_DYNSTR_BUILD_FAILED) {
|
||||||
|
term_filter_escapes(buf->str);
|
||||||
fputs(buf->str, stdout);
|
fputs(buf->str, stdout);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -765,7 +767,8 @@ void ast_log(int level, const char *file, int line, const char *function, const
|
|||||||
term_color(tmp2, file, COLOR_BRWHITE, 0, sizeof(tmp2)),
|
term_color(tmp2, file, COLOR_BRWHITE, 0, sizeof(tmp2)),
|
||||||
term_color(tmp3, linestr, COLOR_BRWHITE, 0, sizeof(tmp3)),
|
term_color(tmp3, linestr, COLOR_BRWHITE, 0, sizeof(tmp3)),
|
||||||
term_color(tmp4, function, COLOR_BRWHITE, 0, sizeof(tmp4)));
|
term_color(tmp4, function, COLOR_BRWHITE, 0, sizeof(tmp4)));
|
||||||
|
/*filter to the console!*/
|
||||||
|
term_filter_escapes(buf->str);
|
||||||
ast_console_puts_mutable(buf->str);
|
ast_console_puts_mutable(buf->str);
|
||||||
|
|
||||||
va_start(ap, fmt);
|
va_start(ap, fmt);
|
||||||
@@ -873,6 +876,9 @@ void ast_verbose(const char *fmt, ...)
|
|||||||
|
|
||||||
if (res == AST_DYNSTR_BUILD_FAILED)
|
if (res == AST_DYNSTR_BUILD_FAILED)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
/* filter out possibly hazardous escape sequences */
|
||||||
|
term_filter_escapes(buf->str);
|
||||||
|
|
||||||
AST_LIST_LOCK(&verbosers);
|
AST_LIST_LOCK(&verbosers);
|
||||||
AST_LIST_TRAVERSE(&verbosers, v, list)
|
AST_LIST_TRAVERSE(&verbosers, v, list)
|
||||||
|
28
main/term.c
28
main/term.c
@@ -264,6 +264,34 @@ char *term_prompt(char *outbuf, const char *inbuf, int maxout)
|
|||||||
return outbuf;
|
return outbuf;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* filter escape sequences */
|
||||||
|
void term_filter_escapes(char *line)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for (i=0; i < strlen(line); i++) {
|
||||||
|
if (line[i] == ESC) {
|
||||||
|
if (line[i+1] == '\x5b') {
|
||||||
|
switch (line[i+2]) {
|
||||||
|
case '\x30':
|
||||||
|
break;
|
||||||
|
case '\x31':
|
||||||
|
break;
|
||||||
|
case '\x33':
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
/* replace ESC with a space */
|
||||||
|
line[i] = ' ';
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
/* replace ESC with a space */
|
||||||
|
line[i] = ' ';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
char *term_prep(void)
|
char *term_prep(void)
|
||||||
{
|
{
|
||||||
return prepdata;
|
return prepdata;
|
||||||
|
Reference in New Issue
Block a user