diff --git a/src/terminal/terminal-handlers.c b/src/terminal/terminal-handlers.c index cbdf922d1..e9de88f52 100644 --- a/src/terminal/terminal-handlers.c +++ b/src/terminal/terminal-handlers.c @@ -1309,7 +1309,7 @@ int guac_terminal_set_directory(guac_terminal* term, unsigned char c) { static char filename[2048]; static int length = 0; - /* Stop on ECMA-48 ST (String Terminator */ + /* Stop on ECMA-48 ST (String Terminator) */ if (c == 0x9C || c == 0x5C || c == 0x07) { filename[length++] = '\0'; term->char_handler = guac_terminal_echo; @@ -1334,7 +1334,7 @@ int guac_terminal_download(guac_terminal* term, unsigned char c) { static char filename[2048]; static int length = 0; - /* Stop on ECMA-48 ST (String Terminator */ + /* Stop on ECMA-48 ST (String Terminator) */ if (c == 0x9C || c == 0x5C || c == 0x07) { filename[length++] = '\0'; term->char_handler = guac_terminal_echo; @@ -1456,7 +1456,7 @@ int guac_terminal_window_title(guac_terminal* term, unsigned char c) { guac_socket* socket = term->client->socket; - /* Stop on ECMA-48 ST (String Terminator */ + /* Stop on ECMA-48 ST (String Terminator) */ if (c == 0x9C || c == 0x5C || c == 0x07) { /* Terminate and reset stored title */ @@ -1552,7 +1552,7 @@ int guac_terminal_xterm_palette(guac_terminal* term, unsigned char c) { } - /* Stop on ECMA-48 ST (String Terminator */ + /* Stop on ECMA-48 ST (String Terminator) */ if (c == 0x9C || c == 0x5C || c == 0x07) term->char_handler = guac_terminal_echo; @@ -1560,6 +1560,14 @@ int guac_terminal_xterm_palette(guac_terminal* term, unsigned char c) { } +int guac_terminal_unknown_osc(guac_terminal* term, unsigned char c) { + /* Stop on ECMA-48 ST (String Terminator) */ + if (c == 0x9C || c == 0x5C || c == 0x07) + term->char_handler = guac_terminal_echo; + + return 0; +} + int guac_terminal_osc(guac_terminal* term, unsigned char c) { static int operation = 0; @@ -1599,12 +1607,16 @@ int guac_terminal_osc(guac_terminal* term, unsigned char c) { else if (operation == 4) term->char_handler = guac_terminal_xterm_palette; + /* Unknown OSC */ + else + term->char_handler = guac_terminal_unknown_osc; + /* Reset parameter for next OSC */ operation = 0; } - /* Stop on ECMA-48 ST (String Terminator */ + /* Stop on ECMA-48 ST (String Terminator) */ else if (c == 0x9C || c == 0x5C || c == 0x07) term->char_handler = guac_terminal_echo; diff --git a/src/terminal/terminal/terminal-handlers.h b/src/terminal/terminal/terminal-handlers.h index 2f9b547c8..c3ddb4761 100644 --- a/src/terminal/terminal/terminal-handlers.h +++ b/src/terminal/terminal/terminal-handlers.h @@ -185,6 +185,21 @@ int guac_terminal_window_title(guac_terminal* term, unsigned char c); */ int guac_terminal_xterm_palette(guac_terminal* term, unsigned char c); +/** + * Handles the remaining characters of an unrecognized OSC sequence, discarding + * them until the sequence is terminated. OSC sequences are terminated by either + * the ECMA-48 String Terminator (ST), which may appear as ESC \ (0x1B 0x5C), + * the single-character ST (0x9C), or BEL (0x07). This handler is used when the + * OSC operation code is not recognized by the terminal emulator. + * + * @param term + * The terminal that received the given character of data. + * + * @param c + * The character that was received by the given terminal. + */ +int guac_terminal_unknown_osc(guac_terminal* term, unsigned char c); + /** * Handles the remaining characters of an Operating System Code (OSC) sequence, * typically initiated with "ESC ]".