1
0
mirror of https://github.com/openbsd/src.git synced 2026-06-18 15:23:33 +02:00

Add a five second limit on pasting for terminals which mysteriously lose

the end sequence if the paste is too big (that is, Terminal.app).
Reported by Garri Djavadyan in GitHub issue 4527.
This commit is contained in:
nicm
2026-05-17 13:01:04 +00:00
parent 4c0773583a
commit 73f00a0b34
2 changed files with 15 additions and 2 deletions
+10 -1
View File
@@ -1,4 +1,4 @@
/* $OpenBSD: server-client.c,v 1.457 2026/05/13 08:25:05 nicm Exp $ */
/* $OpenBSD: server-client.c,v 1.458 2026/05/17 13:01:04 nicm Exp $ */
/*
* Copyright (c) 2009 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -1037,6 +1037,7 @@ server_client_is_bracket_paste(struct client *c, key_code key)
{
if ((key & KEYC_MASK_KEY) == KEYC_PASTE_START) {
c->flags |= CLIENT_BRACKETPASTING;
c->paste_time = current_time;
log_debug("%s: bracket paste on", c->name);
return (0);
}
@@ -1070,6 +1071,7 @@ server_client_is_assume_paste(struct client *c)
if (c->flags & CLIENT_ASSUMEPASTING)
return (1);
c->flags |= CLIENT_ASSUMEPASTING;
c->paste_time = current_time;
log_debug("%s: assume paste on", c->name);
return (0);
}
@@ -2504,6 +2506,13 @@ server_client_dispatch_identify(struct client *c, struct imsg *imsg)
c->out_fd = -1;
}
/* If pasting has taken too long, turn it off. */
if (c->flags & (CLIENT_BRACKETPASTING|CLIENT_ASSUMEPASTING) &&
current_time - c->paste_time > CLIENT_PASTE_TIME_LIMIT) {
log_debug("%s: paste time limit exceeded", c->name);
c->flags &= ~(CLIENT_BRACKETPASTING|CLIENT_ASSUMEPASTING);
}
/*
* If this is the first client, load configuration files. Any later
* clients are allowed to continue with their command even if the
+5 -1
View File
@@ -1,4 +1,4 @@
/* $OpenBSD: tmux.h,v 1.1314 2026/05/17 10:44:53 nicm Exp $ */
/* $OpenBSD: tmux.h,v 1.1315 2026/05/17 13:01:04 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -1945,6 +1945,9 @@ struct client_window {
};
RB_HEAD(client_windows, client_window);
/* Maximum time to be pasting. */
#define CLIENT_PASTE_TIME_LIMIT 5
/* Client connection. */
typedef int (*prompt_input_cb)(struct client *, void *, const char *, int);
typedef void (*prompt_free_cb)(void *);
@@ -2084,6 +2087,7 @@ struct client {
struct key_table *keytable;
key_code last_key;
time_t paste_time;
uint64_t redraw_panes;
uint64_t redraw_scrollbars;