[dev] [st patch queue 12/12] Do not eat ESC character if control string is not properly terminated.

From: noname <noname_AT_inventati.org>
Date: Fri, 25 Apr 2014 18:28:11 +0400

Currently tputc handles the case of too long control string waiting for
the end of control string.

Another case is when there is ESC character is encountered but is not
followed by '\\'. In this case st stops processing control string,
but ESC character is ignored.

After this patch st processes ESC characters in control strings properly.

Test case:
printf '\e]0;abc\e[1mBOLD\e[0m'

Also ^[\ is actually processed in the code that handles ST.
According to ECMA-048 ST stands for STRING TERMINATOR and is used to
close control strings.
---
 st.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)
diff --git a/st.c b/st.c
index cb95b8c..5399809 100644
--- a/st.c
+++ b/st.c
_AT_@ -2446,10 +2446,6 @@ tputc(char *c, int len) {
 				csiparse();
 				csihandle();
 			}
-		} else if(term.esc & ESC_STR_END) {
-			term.esc = 0;
-			if(ascii == '\\')
-				strhandle();
 		} else if(term.esc & ESC_ALTCHARSET) {
 			tdeftran(ascii);
 			tselcs();
_AT_@ -2539,7 +2535,9 @@ tputc(char *c, int len) {
 				tcursor(CURSOR_LOAD);
 				term.esc = 0;
 				break;
-			case '\\': /* ST -- Stop */
+			case '\\': /* ST -- String Terminator */
+				if(term.esc & ESC_STR_END)
+					strhandle();
 				term.esc = 0;
 				break;
 			default:
-- 
1.8.4
Received on Fri Apr 25 2014 - 16:28:11 CEST

This archive was generated by hypermail 2.3.0 : Fri Apr 25 2014 - 16:36:46 CEST