[hackers] [st] Do not eat ESC character if control string is not properly terminated. || noname

From: <git_AT_suckless.org>
Date: Sat, 26 Apr 2014 00:15:17 +0200

commit 02d2df5790d186f16e0e22becd8107a85f328c2f
Author: noname <noname_AT_inventati.org>
Date: Sat Apr 26 00:12:41 2014 +0200

    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.

diff --git a/st.c b/st.c
index cacbe20..d2261e2 100644
--- a/st.c
+++ b/st.c
_AT_@ -2452,10 +2452,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_@ -2545,7 +2541,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:
Received on Sat Apr 26 2014 - 00:15:17 CEST

This archive was generated by hypermail 2.3.0 : Sat Apr 26 2014 - 00:24:07 CEST