From 10180095d8ff1618412843338ed5493c96ec2b32 Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Sun, 23 Apr 2017 13:59:03 -0700 Subject: [PATCH] GUACAMOLE-278: Handle (but ignore) xterm's 256-color palette redefinition OSC. --- src/terminal/terminal/terminal_handlers.h | 12 ++++++++++++ src/terminal/terminal_handlers.c | 17 +++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/src/terminal/terminal/terminal_handlers.h b/src/terminal/terminal/terminal_handlers.h index cc976862..0a8fdcef 100644 --- a/src/terminal/terminal/terminal_handlers.h +++ b/src/terminal/terminal/terminal_handlers.h @@ -138,6 +138,18 @@ int guac_terminal_open_pipe_stream(guac_terminal* term, unsigned char c); */ int guac_terminal_close_pipe_stream(guac_terminal* term, unsigned char c); +/** + * Parses the remainder of xterm's OSC sequence for redefining the terminal + * emulator's palette. + * + * @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_xterm_palette(guac_terminal* term, unsigned char c); + /** * Handles the remaining characters of an Operating System Code (OSC) sequence, * typically initiated with "ESC ]". diff --git a/src/terminal/terminal_handlers.c b/src/terminal/terminal_handlers.c index defca4b4..8e83fb11 100644 --- a/src/terminal/terminal_handlers.c +++ b/src/terminal/terminal_handlers.c @@ -1156,6 +1156,19 @@ int guac_terminal_close_pipe_stream(guac_terminal* term, unsigned char c) { } +int guac_terminal_xterm_palette(guac_terminal* term, unsigned char c) { + + /* NOTE: Currently unimplemented. Attempts to set the 256-color palette + * are ignored. */ + + /* 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; @@ -1183,6 +1196,10 @@ int guac_terminal_osc(guac_terminal* term, unsigned char c) { else if (operation == 482203) term->char_handler = guac_terminal_close_pipe_stream; + /* xterm 256-color palette redefinition */ + else if (operation == 4) + term->char_handler = guac_terminal_xterm_palette; + /* Reset parameter for next OSC */ operation = 0;