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
committed by Nicholas Marriott
parent 762e503978
commit 64e83caf04
17 changed files with 146 additions and 82 deletions

19
tmux.c
View File

@@ -298,6 +298,25 @@ clean_name(const char *name, const char* forbid)
return (new_name);
}
/*
* Check a name given by a command: reject it if it is empty, not valid UTF-8,
* or contains a forbidden character. Other characters that clean_name would
* change (for example with utf8_stravis) are allowed and fixed silently.
*/
int
check_name(const char *name, const char *forbid)
{
const char *cp;
if (*name == '\0' || !utf8_isvalid(name))
return (0);
for (cp = name; *cp != '\0'; cp++) {
if (strchr(forbid, *cp) != NULL)
return (0);
}
return (1);
}
const char *
sig2name(int signo)
{