From dbacd807604d2e9fc833e998c6bcff393c5a5784 Mon Sep 17 00:00:00 2001 From: nytmyr <53322305+nytmyr@users.noreply.github.com> Date: Thu, 14 Nov 2024 20:08:57 -0600 Subject: [PATCH] Add more checks to bot names to prevent spacing or invalid characters --- zone/bot.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/zone/bot.cpp b/zone/bot.cpp index 139bcbbd9..b4679b396 100644 --- a/zone/bot.cpp +++ b/zone/bot.cpp @@ -1323,7 +1323,7 @@ bool Bot::IsValidName() bool Bot::IsValidName(std::string& name) { - if (name.length() < 4 || name.length() > 15) { + if (name.empty() || name.length() < 4 || name.length() > 15) { return false; } @@ -1332,10 +1332,15 @@ bool Bot::IsValidName(std::string& name) } for (char c : name.substr(1)) { - if (!RuleB(Bots, AllowCamelCaseNames) && !islower(c)) { + if (c == '_') { return false; } - if (isdigit(c) || ispunct(c)) { + + if (!isalpha(c)) { + return false; + } + + if (!RuleB(Bots, AllowCamelCaseNames) && !islower(c)) { return false; } }