aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornoname <noname@inventati.org>2014-04-26 00:12:41 +0200
committerRoberto E. Vargas Caballero <k0ga@shike2.com>2014-04-26 00:14:42 +0200
commit02d2df5790d186f16e0e22becd8107a85f328c2f (patch)
tree61c96de5be4d48e91364c7478a9199d6648a60b0
parentc4b79b055df9ef0126f05dd6dbd2bbf935dcb980 (diff)
downloadst-02d2df5790d186f16e0e22becd8107a85f328c2f.tar.gz
st-02d2df5790d186f16e0e22becd8107a85f328c2f.zip
Do not eat ESC character if control string is not properly terminated.
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.
-rw-r--r--st.c8
1 files changed, 3 insertions, 5 deletions
diff --git a/st.c b/st.c
index cacbe20..d2261e2 100644
--- a/st.c
+++ b/st.c
@@ -2452,10 +2452,6 @@ tputc(char *c, int len) {
2452 csiparse(); 2452 csiparse();
2453 csihandle(); 2453 csihandle();
2454 } 2454 }
2455 } else if(term.esc & ESC_STR_END) {
2456 term.esc = 0;
2457 if(ascii == '\\')
2458 strhandle();
2459 } else if(term.esc & ESC_ALTCHARSET) { 2455 } else if(term.esc & ESC_ALTCHARSET) {
2460 tdeftran(ascii); 2456 tdeftran(ascii);
2461 tselcs(); 2457 tselcs();
@@ -2545,7 +2541,9 @@ tputc(char *c, int len) {
2545 tcursor(CURSOR_LOAD); 2541 tcursor(CURSOR_LOAD);
2546 term.esc = 0; 2542 term.esc = 0;
2547 break; 2543 break;
2548 case '\\': /* ST -- Stop */ 2544 case '\\': /* ST -- String Terminator */
2545 if(term.esc & ESC_STR_END)
2546 strhandle();
2549 term.esc = 0; 2547 term.esc = 0;
2550 break; 2548 break;
2551 default: 2549 default: