1
0
mirror of https://github.com/tmux/tmux.git synced 2025-04-11 03:28:49 +00:00

Sync OpenBSD patchset 549:

Don't interpret #() for display-message, it usually doesn't make sense and may
leak commands.
This commit is contained in:
Tiago Cunha 2009-11-19 22:25:52 +00:00
parent a5ae0dc216
commit 563f34477a
5 changed files with 36 additions and 21 deletions

View File

@ -1,4 +1,4 @@
/* $Id: cmd-display-message.c,v 1.4 2009-11-14 17:56:39 tcunha Exp $ */ /* $Id: cmd-display-message.c,v 1.5 2009-11-19 22:25:52 tcunha Exp $ */
/* /*
* Copyright (c) 2009 Tiago Cunha <me@tiagocunha.org> * Copyright (c) 2009 Tiago Cunha <me@tiagocunha.org>
@ -55,7 +55,7 @@ cmd_display_message_exec(struct cmd *self, struct cmd_ctx *ctx)
else else
template = data->arg; template = data->arg;
msg = status_replace(c, template, time(NULL)); msg = status_replace(c, template, time(NULL), 0);
status_message_set(c, "%s", msg); status_message_set(c, "%s", msg);
xfree(msg); xfree(msg);

View File

@ -1,4 +1,4 @@
/* $Id: server-client.c,v 1.22 2009-11-19 22:20:04 tcunha Exp $ */ /* $Id: server-client.c,v 1.23 2009-11-19 22:25:52 tcunha Exp $ */
/* /*
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net> * Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
@ -488,7 +488,7 @@ server_client_set_title(struct client *c)
template = options_get_string(&s->options, "set-titles-string"); 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 || strcmp(title, c->title) != 0) {
if (c->title != NULL) if (c->title != NULL)
xfree(c->title); xfree(c->title);

View File

@ -1,4 +1,4 @@
/* $Id: status.c,v 1.129 2009-11-19 22:20:04 tcunha Exp $ */ /* $Id: status.c,v 1.130 2009-11-19 22:25:52 tcunha Exp $ */
/* /*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -107,14 +107,14 @@ status_redraw(struct client *c)
/* Work out the left and right strings. */ /* Work out the left and right strings. */
left = status_replace(c, options_get_string( 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"); llen = options_get_number(&s->options, "status-left-length");
llen2 = screen_write_cstrlen(utf8flag, "%s", left); llen2 = screen_write_cstrlen(utf8flag, "%s", left);
if (llen2 < llen) if (llen2 < llen)
llen = llen2; llen = llen2;
right = status_replace(c, options_get_string( 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"); rlen = options_get_number(&s->options, "status-right-length");
rlen2 = screen_write_cstrlen(utf8flag, "%s", right); rlen2 = screen_write_cstrlen(utf8flag, "%s", right);
if (rlen2 < rlen) if (rlen2 < rlen)
@ -319,7 +319,7 @@ out:
} }
char * 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 session *s = c->session;
struct winlink *wl = s->curw; struct winlink *wl = s->curw;
@ -355,11 +355,25 @@ status_replace(struct client *c, const char *fmt, time_t t)
ptr = NULL; ptr = NULL;
switch (*iptr++) { switch (*iptr++) {
case '(': case '(':
if (ptr == NULL) { if (run_jobs) {
ptr = status_job(c, &iptr); if (ptr == NULL) {
if (ptr == NULL) ptr = status_job(c, &iptr);
break; if (ptr == NULL)
savedptr = ptr; 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 */ /* FALLTHROUGH */
case 'H': case 'H':

13
tmux.1
View File

@ -1,4 +1,4 @@
.\" $Id: tmux.1,v 1.203 2009-11-19 22:23:27 tcunha Exp $ .\" $Id: tmux.1,v 1.204 2009-11-19 22:25:52 tcunha Exp $
.\" .\"
.\" Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> .\" Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
.\" .\"
@ -14,7 +14,7 @@
.\" IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING .\" IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
.\" OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\" .\"
.Dd $Mdocdate: November 18 2009 $ .Dd $Mdocdate: November 19 2009 $
.Dt TMUX 1 .Dt TMUX 1
.Os .Os
.Sh NAME .Sh NAME
@ -1992,10 +1992,11 @@ This command works only from inside
.Op Ar message .Op Ar message
.Xc .Xc
.D1 (alias: Ic display ) .D1 (alias: Ic display )
Display a message (see the Display a message in the status line.
.Ic status-left The format of
option below) .Ar message is as for
in the status line. .Ic status-left ,
with the exception that #() are not handled.
.It Ic select-prompt Op Fl t Ar target-client .It Ic select-prompt Op Fl t Ar target-client
Open a prompt inside Open a prompt inside
.Ar target-client .Ar target-client

4
tmux.h
View File

@ -1,4 +1,4 @@
/* $Id: tmux.h,v 1.519 2009-11-19 22:23:27 tcunha Exp $ */ /* $Id: tmux.h,v 1.520 2009-11-19 22:25:52 tcunha Exp $ */
/* /*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -1616,7 +1616,7 @@ void server_update_event(struct client *);
/* status.c */ /* status.c */
int status_redraw(struct client *); 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 printflike2 status_message_set(struct client *, const char *, ...);
void status_message_clear(struct client *); void status_message_clear(struct client *);
int status_message_redraw(struct client *); int status_message_redraw(struct client *);