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

View File

@@ -411,11 +411,11 @@ window_remove_ref(struct window *w, const char *from)
}
void
window_set_name(struct window *w, const char *new_name)
window_set_name(struct window *w, const char *new_name, const char *forbid)
{
char *name;
name = clean_name(new_name, "#");
name = clean_name(new_name, forbid);
if (name != NULL) {
free(w->name);
w->name = name;
@@ -1089,7 +1089,7 @@ window_pane_create(struct window *w, u_int sx, u_int sy, u_int hlimit)
style_ranges_init(&wp->border_status_line.ranges);
if (gethostname(host, sizeof host) == 0)
screen_set_title(&wp->base, host);
screen_set_title(&wp->base, host, 0);
return (wp);
}