diff --git a/conf.h b/conf.h index 5dbcb751..c8ad4785 100644 --- a/conf.h +++ b/conf.h @@ -903,6 +903,11 @@ CONF_OPTION(no_bidi, DEFAULT_BOOL(false), SAVE_KEYWORD("DisableBidi"), ) +CONF_OPTION(no_bracketed_paste, + VALUE_TYPE(BOOL), + DEFAULT_BOOL(false), + SAVE_KEYWORD("DisableBracketedPaste"), +) /* Colour options */ CONF_OPTION(ansi_colour, diff --git a/config.c b/config.c index 17298f78..1329239c 100644 --- a/config.c +++ b/config.c @@ -2190,6 +2190,9 @@ void setup_config_box(struct controlbox *b, bool midsession, ctrl_checkbox(s, "Disable bidirectional text display", 'd', HELPCTX(features_bidi), conf_checkbox_handler, I(CONF_no_bidi)); + ctrl_checkbox(s, "Disable bracketed paste mode", + 'p', HELPCTX(features_bracketed_paste), conf_checkbox_handler, + I(CONF_no_bracketed_paste)); /* * The Window panel. diff --git a/doc/config.but b/doc/config.but index 8b3191fa..a28e866c 100644 --- a/doc/config.but +++ b/doc/config.but @@ -984,6 +984,34 @@ right in all situations. You may also find you need to disable Arabic text shaping; see \k{config-features-shaping}. +\S{config-features-bracketed paste} Disabling \i{bracketed paste} mode + +By default, when you paste text into the terminal window, it's sent to +the server as terminal input, exactly as if you'd typed the same text +into the terminal window using the keyboard (except that it's all sent +at once, much faster than you could type it). + +However, a terminal application can change that, by asking the +terminal to enable \q{bracketed paste mode}. In this mode, pasted data +is marked in the input stream, by sending a special control sequence +before the paste, and another one at the end. + +A terminal application can use this information to treat pasted data +differently from keyboard input. For example, a terminal-based text +editor can treat the input as literal data, even if some of its +characters would normally trigger special editor functions. A shell +can treat pasted input as less trusted, in case another application +somehow sneaked a malicious shell command into your clipboard: modern +versions of \cw{bash} will highlight pasted data on the command line, +and not run it until you've confirmed it by pressing Return, even if +the pasted data contained a newline character. + +In edge cases, it's possible that bracketed paste mode introduces +bigger problems than the ones it solves. So you can use this checkbox +to turn it off completely. If you do that, then PuTTY will always send +your paste data exactly as if it had been typed at the keyboard, +whether or not the server asked for bracketed paste mode. + \H{config-window} The Window panel The Window configuration panel allows you to control aspects of the diff --git a/doc/index.but b/doc/index.but index 86c6f931..aed37ce4 100644 --- a/doc/index.but +++ b/doc/index.but @@ -77,6 +77,8 @@ from other protocols \IM{copy and paste} cut and paste \IM{copy and paste} paste, copy and +\IM{bracketed paste} paste, bracketed + \IM{three-button mouse} three-button mouse \IM{three-button mouse} mouse, three-button diff --git a/terminal/terminal.c b/terminal/terminal.c index 08df6e59..5798bb14 100644 --- a/terminal/terminal.c +++ b/terminal/terminal.c @@ -1639,6 +1639,7 @@ static void term_copy_stuff_from_conf(Terminal *term) term->bellovl_s = conf_get_int(term->conf, CONF_bellovl_s); term->bellovl_t = conf_get_int(term->conf, CONF_bellovl_t); term->no_bidi = conf_get_bool(term->conf, CONF_no_bidi); + term->no_bracketed_paste = conf_get_bool(term->conf, CONF_no_bracketed_paste); term->bksp_is_delete = conf_get_bool(term->conf, CONF_bksp_is_delete); term->blink_cur = conf_get_bool(term->conf, CONF_blink_cur); term->blinktext = conf_get_bool(term->conf, CONF_blinktext); @@ -7130,7 +7131,7 @@ void term_do_paste(Terminal *term, const wchar_t *data, int len) term->paste_pos = term->paste_len = 0; term->paste_buffer = snewn(len + 12, wchar_t); - if (term->bracketed_paste) + if (term->bracketed_paste && !term->no_bracketed_paste) term_bracketed_paste_start(term); p = data; diff --git a/terminal/terminal.h b/terminal/terminal.h index 056e770c..c8f3f8f8 100644 --- a/terminal/terminal.h +++ b/terminal/terminal.h @@ -157,6 +157,7 @@ struct terminal_tag { int raw_mouse_reported_y; bool bracketed_paste, bracketed_paste_active; + bool no_bracketed_paste; /* disabled in configuration */ int cset_attr[2]; diff --git a/windows/help.h b/windows/help.h index cfca4e1c..8430da58 100644 --- a/windows/help.h +++ b/windows/help.h @@ -45,6 +45,7 @@ typedef const char *HelpCtx; #define WINHELP_CTX_features_clearscroll "config-features-clearscroll" #define WINHELP_CTX_features_arabicshaping "config-features-shaping" #define WINHELP_CTX_features_bidi "config-features-bidi" +#define WINHELP_CTX_features_bracketed_paste "config-features-bracketed-paste" #define WINHELP_CTX_terminal_autowrap "config-autowrap" #define WINHELP_CTX_terminal_decom "config-decom" #define WINHELP_CTX_terminal_lfhascr "config-crlf"