check for even number of escape characters

to allow colored names, while preventing invalid escape characters
This commit is contained in:
Isaac0-dev 2025-02-21 10:13:00 +10:00
parent 6ddb7388cc
commit c3c4ba6b0a

View file

@ -329,13 +329,15 @@ static void djui_panel_player_edit_palette_create(struct DjuiBase* caller) {
bool djui_panel_player_name_valid(char* buffer) {
if (buffer[0] == '\0') { return false; }
u16 numEscapeChars = 0;
char* c = buffer;
while (*c != '\0') {
if (*c == ' ') { return false; }
if (*c == '\\') { return false; }
if (!djui_unicode_valid_char(c)) { return false; }
if (*c == '\\') { numEscapeChars++; }
c = djui_unicode_next_char(c);
}
if (numEscapeChars % 2 != 0) { return false; }
return true;
}