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

18
tmux.c
View File

@@ -34,6 +34,7 @@
#include <time.h>
#include <unistd.h>
#include <util.h>
#include <vis.h>
#include "tmux.h"
@@ -285,6 +286,23 @@ get_timer(void)
return ((ts.tv_sec * 1000ULL) + (ts.tv_nsec / 1000000ULL));
}
char *
clean_name(const char *name, const char* forbid)
{
char *copy, *cp, *new_name;
if (*name == '\0' || !utf8_isvalid(name))
return (NULL);
copy = xstrdup(name);
for (cp = copy; *cp != '\0'; cp++) {
if (strchr(forbid, *cp) != NULL)
*cp = '_';
}
utf8_stravis(&new_name, copy, VIS_OCTAL|VIS_CSTYLE|VIS_TAB|VIS_NL);
free(copy);
return (new_name);
}
const char *
sig2name(int signo)
{