mirror of
https://github.com/tmux/tmux.git
synced 2026-05-30 14:16:18 +00:00
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:
18
tmux.c
18
tmux.c
@@ -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)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user