From fa91b55eec241374d3eda4fbeac6f2dc372f1df2 Mon Sep 17 00:00:00 2001 From: Simon Tatham Date: Thu, 17 Nov 2016 20:25:27 +0000 Subject: [PATCH] Make ESC[3J (clear scrollback) a disableable escape sequence. A user complained that it was being done nonconsensually, and it seems reasonable that the user should have the choice to prevent it. --- config.c | 4 ++++ doc/config.but | 9 +++++++++ putty.h | 1 + settings.c | 2 ++ terminal.c | 4 +++- terminal.h | 1 + windows/winhelp.h | 1 + 7 files changed, 21 insertions(+), 1 deletion(-) diff --git a/config.c b/config.c index 1b4bd91e..ceeab877 100644 --- a/config.c +++ b/config.c @@ -1690,6 +1690,10 @@ void setup_config_box(struct controlbox *b, int midsession, HELPCTX(features_retitle), conf_checkbox_handler, I(CONF_no_remote_wintitle)); + ctrl_checkbox(s, "Disable remote-controlled clearing of scrollback", 'e', + HELPCTX(features_clearscroll), + conf_checkbox_handler, + I(CONF_no_remote_clearscroll)); ctrl_radiobuttons(s, "Response to remote title query (SECURITY):", 'q', 3, HELPCTX(features_qtitle), conf_radiobutton_handler, diff --git a/doc/config.but b/doc/config.but index a21d9279..7455fab4 100644 --- a/doc/config.but +++ b/doc/config.but @@ -934,6 +934,15 @@ setting you want if you have no better ideas. \dd PuTTY responds with the actual window title. This is dangerous for the reasons described above. +\S{config-features-clearscroll} Disabling remote \i{scrollback clearing} + +\cfg{winhelp-topic}{features.clearscroll} + +PuTTY has the ability to clear the terminal's scrollback buffer in +response to a command from the server. If you find PuTTY is doing this +unexpectedly or inconveniently, you can tell PuTTY not to respond to +that server command. + \S{config-features-dbackspace} Disabling \i{destructive backspace} \cfg{winhelp-topic}{features.dbackspace} diff --git a/putty.h b/putty.h index cefb5364..943ccbf9 100644 --- a/putty.h +++ b/putty.h @@ -770,6 +770,7 @@ void cleanup_exit(int); X(INT, NONE, no_remote_resize) /* disable remote resizing */ \ X(INT, NONE, no_alt_screen) /* disable alternate screen */ \ X(INT, NONE, no_remote_wintitle) /* disable remote retitling */ \ + X(INT, NONE, no_remote_clearscroll) /* disable ESC[3J */ \ X(INT, NONE, no_dbackspace) /* disable destructive backspace */ \ X(INT, NONE, no_remote_charset) /* disable remote charset config */ \ X(INT, NONE, remote_qtitle_action) /* remote win title query action */ \ diff --git a/settings.c b/settings.c index fcccb850..72a7c4ff 100644 --- a/settings.c +++ b/settings.c @@ -545,6 +545,7 @@ void save_open_settings(void *sesskey, Conf *conf) write_setting_i(sesskey, "NoRemoteResize", conf_get_int(conf, CONF_no_remote_resize)); write_setting_i(sesskey, "NoAltScreen", conf_get_int(conf, CONF_no_alt_screen)); write_setting_i(sesskey, "NoRemoteWinTitle", conf_get_int(conf, CONF_no_remote_wintitle)); + write_setting_i(sesskey, "NoRemoteClearScroll", conf_get_int(conf, CONF_no_remote_clearscroll)); write_setting_i(sesskey, "RemoteQTitleAction", conf_get_int(conf, CONF_remote_qtitle_action)); write_setting_i(sesskey, "NoDBackspace", conf_get_int(conf, CONF_no_dbackspace)); write_setting_i(sesskey, "NoRemoteCharset", conf_get_int(conf, CONF_no_remote_charset)); @@ -876,6 +877,7 @@ void load_open_settings(void *sesskey, Conf *conf) gppi(sesskey, "NoRemoteResize", 0, conf, CONF_no_remote_resize); gppi(sesskey, "NoAltScreen", 0, conf, CONF_no_alt_screen); gppi(sesskey, "NoRemoteWinTitle", 0, conf, CONF_no_remote_wintitle); + gppi(sesskey, "NoRemoteClearScroll", 0, conf, CONF_no_remote_clearscroll); { /* Backward compatibility */ int no_remote_qtitle = gppi_raw(sesskey, "NoRemoteQTitle", 1); diff --git a/terminal.c b/terminal.c index 5b37fe79..c79944cd 100644 --- a/terminal.c +++ b/terminal.c @@ -1403,6 +1403,7 @@ void term_copy_stuff_from_conf(Terminal *term) term->no_remote_charset = conf_get_int(term->conf, CONF_no_remote_charset); term->no_remote_resize = conf_get_int(term->conf, CONF_no_remote_resize); term->no_remote_wintitle = conf_get_int(term->conf, CONF_no_remote_wintitle); + term->no_remote_clearscroll = conf_get_int(term->conf, CONF_no_remote_clearscroll); term->rawcnp = conf_get_int(term->conf, CONF_rawcnp); term->rect_select = conf_get_int(term->conf, CONF_rect_select); term->remote_qtitle_action = conf_get_int(term->conf, CONF_remote_qtitle_action); @@ -3606,7 +3607,8 @@ static void term_out(Terminal *term) if (i == 3) { /* Erase Saved Lines (xterm) * This follows Thomas Dickey's xterm. */ - term_clrsb(term); + if (!term->no_remote_clearscroll) + term_clrsb(term); } else { i++; if (i > 3) diff --git a/terminal.h b/terminal.h index 01d5f57a..2ed9e6ef 100644 --- a/terminal.h +++ b/terminal.h @@ -315,6 +315,7 @@ struct terminal_tag { int no_remote_charset; int no_remote_resize; int no_remote_wintitle; + int no_remote_clearscroll; int rawcnp; int rect_select; int remote_qtitle_action; diff --git a/windows/winhelp.h b/windows/winhelp.h index 2e40938e..65fc0362 100644 --- a/windows/winhelp.h +++ b/windows/winhelp.h @@ -41,6 +41,7 @@ #define WINHELP_CTX_features_qtitle "features.qtitle:config-features-qtitle" #define WINHELP_CTX_features_dbackspace "features.dbackspace:config-features-dbackspace" #define WINHELP_CTX_features_charset "features.charset:config-features-charset" +#define WINHELP_CTX_features_clearscroll "features.clearscroll:config-features-clearscroll" #define WINHELP_CTX_features_arabicshaping "features.arabicshaping:config-features-shaping" #define WINHELP_CTX_features_bidi "features.bidi:config-features-bidi" #define WINHELP_CTX_terminal_autowrap "terminal.autowrap:config-autowrap" -- 2.45.2