Sanitize pane titles and window and session names more consistently and

strictly, prevents C0 characters and other nonvisible characters causing
problems. Reported (with a different fix) by Chris Monardo in GitHub
issue 4999.
This commit is contained in:
nicm
2026-04-22 07:10:16 +00:00
parent fee70031f6
commit d339ab51eb
11 changed files with 58 additions and 41 deletions

View File

@@ -232,19 +232,28 @@ screen_set_cursor_colour(struct screen *s, int colour)
int
screen_set_title(struct screen *s, const char *title)
{
if (!utf8_isvalid(title))
char *new_title;
new_title = clean_name(title, "#");
if (new_title == NULL)
return (0);
free(s->title);
s->title = xstrdup(title);
s->title = new_title;
return (1);
}
/* Set screen path. */
void
int
screen_set_path(struct screen *s, const char *path)
{
char *new_path;
new_path = clean_name(path, "#");
if (new_path == NULL)
return (0);
free(s->path);
utf8_stravis(&s->path, path, VIS_OCTAL|VIS_CSTYLE|VIS_TAB|VIS_NL);
s->path = new_path;
return (1);
}
/* Push the current title onto the stack. */