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

@@ -52,12 +52,12 @@ cmd_rename_session_exec(struct cmd *self, struct cmdq_item *item)
char *newname, *tmp;
tmp = format_single_from_target(item, args_string(args, 0));
newname = clean_name(tmp, "#:.");
if (newname == NULL) {
cmdq_error(item, "invalid session: %s", tmp);
if (!check_name(tmp, SESSION_NAME_FORBID)) {
cmdq_error(item, "invalid session name: %s", tmp);
free(tmp);
return (CMD_RETURN_ERROR);
}
newname = clean_name(tmp, SESSION_NAME_FORBID);
free(tmp);
if (strcmp(newname, s->name) == 0) {
free(newname);