Add an option (default off) to control the passthrough escape sequence.

Like set-clipboard and allow-rename it is safer to forbid this by
default.
This commit is contained in:
nicm
2022-02-15 13:11:29 +00:00
parent f85208602d
commit 5076beb009
3 changed files with 26 additions and 7 deletions

View File

@ -2235,15 +2235,19 @@ input_enter_dcs(struct input_ctx *ictx)
static int
input_dcs_dispatch(struct input_ctx *ictx)
{
struct window_pane *wp = ictx->wp;
struct screen_write_ctx *sctx = &ictx->ctx;
u_char *buf = ictx->input_buf;
size_t len = ictx->input_len;
const char prefix[] = "tmux;";
const u_int prefixlen = (sizeof prefix) - 1;
if (wp == NULL)
return (0);
if (ictx->flags & INPUT_DISCARD)
return (0);
if (!options_get_number(ictx->wp->options, "allow-passthrough"))
return (0);
log_debug("%s: \"%s\"", __func__, buf);
if (len >= prefixlen && strncmp(buf, prefix, prefixlen) == 0)

View File

@ -801,6 +801,14 @@ const struct options_table_entry options_table[] = {
"linked to ('off')."
},
{ .name = "allow-passthrough",
.type = OPTIONS_TABLE_FLAG,
.scope = OPTIONS_TABLE_WINDOW|OPTIONS_TABLE_PANE,
.default_num = 0,
.text = "Whether applications are allowed to use the escape sequence "
"to bypass tmux."
},
{ .name = "allow-rename",
.type = OPTIONS_TABLE_FLAG,
.scope = OPTIONS_TABLE_WINDOW|OPTIONS_TABLE_PANE,

7
tmux.1
View File

@ -4403,6 +4403,13 @@ The default is on.
Available pane options are:
.Pp
.Bl -tag -width Ds -compact
.It Xo Ic allow-passthrough
.Op Ic on | off
.Xc
Allow programs in the pane to bypass
.Nm
using a terminal escape sequence (\eePtmux;...\ee\e\e).
.Pp
.It Xo Ic allow-rename
.Op Ic on | off
.Xc