From b154475e36677215e94fb4f753d1635088720b62 Mon Sep 17 00:00:00 2001 From: WinterSolstice8 <60417494+wintersolstice8@users.noreply.github.com> Date: Thu, 29 Jan 2026 17:21:20 -0700 Subject: [PATCH] [core] Don't send bad blacklist packets Co-Authored-By: atom0s --- src/map/utils/blacklistutils.cpp | 34 +++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 12 deletions(-) diff --git a/src/map/utils/blacklistutils.cpp b/src/map/utils/blacklistutils.cpp index 27968e1ec77..7707abeb512 100644 --- a/src/map/utils/blacklistutils.cpp +++ b/src/map/utils/blacklistutils.cpp @@ -80,24 +80,34 @@ void SendBlacklist(CCharEntity* PChar) int totalCount = 0; const int rowCount = rset->rowsCount(); + auto isNameCharactersOnly = [](const std::string& name) -> bool + { + // null terminator added for paranoia, the docs say `find_first_not_of` _will_ check those. + // https://en.cppreference.com/w/cpp/string/basic_string/find_first_not_of + return to_lower(name).find_first_not_of("abcdefghijklmnopqrstuvwxyz\0") == std::string::npos; + }; + while (rset->next()) { auto accid_target = rset->get(0); auto targetName = rset->get(1); - blacklist.emplace_back(accid_target, targetName); - currentCount++; - totalCount++; - - if (currentCount == 12) + if (isNameCharactersOnly(targetName)) { - PChar->pushPacket( - blacklist, - GP_SERV_COMMAND_BLACK_LIST::ResetClientBlacklist{ totalCount <= 12 }, - GP_SERV_COMMAND_BLACK_LIST::LastBlacklistPacket{ totalCount == rowCount }); - - blacklist.clear(); - currentCount = 0; + blacklist.emplace_back(accid_target, targetName); + currentCount++; + totalCount++; + + if (currentCount == 12) + { + PChar->pushPacket( + blacklist, + GP_SERV_COMMAND_BLACK_LIST::ResetClientBlacklist{ totalCount <= 12 }, + GP_SERV_COMMAND_BLACK_LIST::LastBlacklistPacket{ totalCount == rowCount }); + + blacklist.clear(); + currentCount = 0; + } } }