[asterisk-commits] mogorman: branch 1.4 r47490 - in /branches/1.4: ./ include/asterisk/ main/

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Fri Nov 10 19:04:28 MST 2006


Author: mogorman
Date: Fri Nov 10 20:04:28 2006
New Revision: 47490

URL: http://svn.digium.com/view/asterisk?view=rev&rev=47490
Log:
woohoo safe out put!

Modified:
    branches/1.4/   (props changed)
    branches/1.4/include/asterisk/term.h
    branches/1.4/main/logger.c
    branches/1.4/main/term.c

Propchange: branches/1.4/
------------------------------------------------------------------------------
    svnmerge-integrated = /branches/1.4:1-47483

Modified: branches/1.4/include/asterisk/term.h
URL: http://svn.digium.com/view/asterisk/branches/1.4/include/asterisk/term.h?view=diff&rev=47490&r1=47489&r2=47490
==============================================================================
--- branches/1.4/include/asterisk/term.h (original)
+++ branches/1.4/include/asterisk/term.h Fri Nov 10 20:04:28 2006
@@ -59,6 +59,8 @@
 
 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_prep(void);

Modified: branches/1.4/main/logger.c
URL: http://svn.digium.com/view/asterisk/branches/1.4/main/logger.c?view=diff&rev=47490&r1=47489&r2=47490
==============================================================================
--- branches/1.4/main/logger.c (original)
+++ branches/1.4/main/logger.c Fri Nov 10 20:04:28 2006
@@ -700,8 +700,10 @@
 			va_start(ap, fmt);
 			res = ast_dynamic_str_thread_set_va(&buf, BUFSIZ, &log_buf, fmt, 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);
+			}
 		}
 		return;
 	}
@@ -765,7 +767,8 @@
 					term_color(tmp2, file, COLOR_BRWHITE, 0, sizeof(tmp2)),
 					term_color(tmp3, linestr, COLOR_BRWHITE, 0, sizeof(tmp3)),
 					term_color(tmp4, function, COLOR_BRWHITE, 0, sizeof(tmp4)));
-
+				/*filter to the console!*/
+				term_filter_escapes(buf->str);
 				ast_console_puts_mutable(buf->str);
 				
 				va_start(ap, fmt);
@@ -873,6 +876,9 @@
 
 	if (res == AST_DYNSTR_BUILD_FAILED)
 		return;
+	
+	/* filter out possibly hazardous escape sequences */
+	term_filter_escapes(buf->str);
 
 	AST_LIST_LOCK(&verbosers);
 	AST_LIST_TRAVERSE(&verbosers, v, list)

Modified: branches/1.4/main/term.c
URL: http://svn.digium.com/view/asterisk/branches/1.4/main/term.c?view=diff&rev=47490&r1=47489&r2=47490
==============================================================================
--- branches/1.4/main/term.c (original)
+++ branches/1.4/main/term.c Fri Nov 10 20:04:28 2006
@@ -264,6 +264,34 @@
 	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)
 {
 	return prepdata;



More information about the asterisk-commits mailing list