mirror of
https://github.com/tmate-io/tmate.git
synced 2024-11-27 02:23:15 +01:00
Don't interpret #() for display-message, it usually doesn't make sense and may
leak commands.
This commit is contained in:
parent
8d4eae5662
commit
ac5b7d518e
@ -55,7 +55,7 @@ cmd_display_message_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||
else
|
||||
template = data->arg;
|
||||
|
||||
msg = status_replace(c, template, time(NULL));
|
||||
msg = status_replace(c, template, time(NULL), 0);
|
||||
status_message_set(c, "%s", msg);
|
||||
xfree(msg);
|
||||
|
||||
|
@ -489,7 +489,7 @@ server_client_set_title(struct client *c)
|
||||
|
||||
template = options_get_string(&s->options, "set-titles-string");
|
||||
|
||||
title = status_replace(c, template, time(NULL));
|
||||
title = status_replace(c, template, time(NULL), 1);
|
||||
if (c->title == NULL || strcmp(title, c->title) != 0) {
|
||||
if (c->title != NULL)
|
||||
xfree(c->title);
|
||||
|
20
status.c
20
status.c
@ -107,14 +107,14 @@ status_redraw(struct client *c)
|
||||
|
||||
/* Work out the left and right strings. */
|
||||
left = status_replace(c, options_get_string(
|
||||
&s->options, "status-left"), c->status_timer.tv_sec);
|
||||
&s->options, "status-left"), c->status_timer.tv_sec, 1);
|
||||
llen = options_get_number(&s->options, "status-left-length");
|
||||
llen2 = screen_write_cstrlen(utf8flag, "%s", left);
|
||||
if (llen2 < llen)
|
||||
llen = llen2;
|
||||
|
||||
right = status_replace(c, options_get_string(
|
||||
&s->options, "status-right"), c->status_timer.tv_sec);
|
||||
&s->options, "status-right"), c->status_timer.tv_sec, 1);
|
||||
rlen = options_get_number(&s->options, "status-right-length");
|
||||
rlen2 = screen_write_cstrlen(utf8flag, "%s", right);
|
||||
if (rlen2 < rlen)
|
||||
@ -319,7 +319,7 @@ out:
|
||||
}
|
||||
|
||||
char *
|
||||
status_replace(struct client *c, const char *fmt, time_t t)
|
||||
status_replace(struct client *c, const char *fmt, time_t t, int run_jobs)
|
||||
{
|
||||
struct session *s = c->session;
|
||||
struct winlink *wl = s->curw;
|
||||
@ -355,12 +355,26 @@ status_replace(struct client *c, const char *fmt, time_t t)
|
||||
ptr = NULL;
|
||||
switch (*iptr++) {
|
||||
case '(':
|
||||
if (run_jobs) {
|
||||
if (ptr == NULL) {
|
||||
ptr = status_job(c, &iptr);
|
||||
if (ptr == NULL)
|
||||
break;
|
||||
savedptr = ptr;
|
||||
}
|
||||
} else {
|
||||
/* Don't run jobs. Copy to ). */
|
||||
*optr++ = '#';
|
||||
|
||||
iptr--; /* include [ */
|
||||
while (*iptr != ')' && *iptr != '\0') {
|
||||
if (optr >=
|
||||
out + (sizeof out) - 1)
|
||||
break;
|
||||
*optr++ = *iptr++;
|
||||
}
|
||||
break;
|
||||
}
|
||||
/* FALLTHROUGH */
|
||||
case 'H':
|
||||
if (ptr == NULL) {
|
||||
|
9
tmux.1
9
tmux.1
@ -1992,10 +1992,11 @@ This command works only from inside
|
||||
.Op Ar message
|
||||
.Xc
|
||||
.D1 (alias: Ic display )
|
||||
Display a message (see the
|
||||
.Ic status-left
|
||||
option below)
|
||||
in the status line.
|
||||
Display a message in the status line.
|
||||
The format of
|
||||
.Ar message is as for
|
||||
.Ic status-left ,
|
||||
with the exception that #() are not handled.
|
||||
.It Ic select-prompt Op Fl t Ar target-client
|
||||
Open a prompt inside
|
||||
.Ar target-client
|
||||
|
2
tmux.h
2
tmux.h
@ -1617,7 +1617,7 @@ void server_update_event(struct client *);
|
||||
|
||||
/* status.c */
|
||||
int status_redraw(struct client *);
|
||||
char *status_replace(struct client *, const char *, time_t);
|
||||
char *status_replace(struct client *, const char *, time_t, int);
|
||||
void printflike2 status_message_set(struct client *, const char *, ...);
|
||||
void status_message_clear(struct client *);
|
||||
int status_message_redraw(struct client *);
|
||||
|
Loading…
Reference in New Issue
Block a user