Be more strict about what names and titles we allow and reject them

immediately when possible, but allow # again for those directly set by
commands (but not escape sequences). From Barrett Ruth in GitHub issue
5175.
This commit is contained in:
nicm
2026-06-15 21:41:39 +00:00
parent b86bd1fcd0
commit eb65331403
17 changed files with 144 additions and 81 deletions

10
input.c
View File

@@ -2664,7 +2664,7 @@ input_exit_osc(struct input_ctx *ictx)
case 2:
if (wp != NULL &&
options_get_number(wp->options, "allow-set-title") &&
screen_set_title(sctx->s, p)) {
screen_set_title(sctx->s, p, 1)) {
notify_pane("pane-title-changed", wp);
server_redraw_window_borders(wp->window);
server_status_window(wp->window);
@@ -2674,7 +2674,7 @@ input_exit_osc(struct input_ctx *ictx)
input_osc_4(ictx, p);
break;
case 7:
if (screen_set_path(sctx->s, p) && wp != NULL) {
if (wp != NULL && screen_set_path(sctx->s, p, 1)) {
server_redraw_window_borders(wp->window);
server_status_window(wp->window);
}
@@ -2742,7 +2742,7 @@ input_exit_apc(struct input_ctx *ictx)
if (wp != NULL &&
options_get_number(wp->options, "allow-set-title") &&
screen_set_title(sctx->s, ictx->input_buf)) {
screen_set_title(sctx->s, ictx->input_buf, 1)) {
notify_pane("pane-title-changed", wp);
server_redraw_window_borders(wp->window);
server_status_window(wp->window);
@@ -2785,10 +2785,10 @@ input_exit_rename(struct input_ctx *ictx)
if (o != NULL)
options_remove_or_default(o, -1, NULL);
if (!options_get_number(w->options, "automatic-rename"))
window_set_name(w, "");
window_set_name(w, "", WINDOW_NAME_FORBID_EXT);
} else {
options_set_number(w->options, "automatic-rename", 0);
window_set_name(w, ictx->input_buf);
window_set_name(w, ictx->input_buf, WINDOW_NAME_FORBID_EXT);
}
server_redraw_window_borders(w);
server_status_window(w);