From aa88eea800da5063845b99f5c8be9eafc16001ee Mon Sep 17 00:00:00 2001 From: C0DELEVEL Date: Wed, 3 Dec 2025 12:57:51 +0100 Subject: [PATCH] feat(chat): censor register command in input history Extend command censoring logic to include the `/register` command, similar to `/login`. This prevents sensitive information, such as passwords, from being stored in chat input history while still recording the command for history navigation. --- Client/core/CChat.cpp | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/Client/core/CChat.cpp b/Client/core/CChat.cpp index b4b7e3b95b..d5adada293 100644 --- a/Client/core/CChat.cpp +++ b/Client/core/CChat.cpp @@ -657,9 +657,9 @@ bool CChat::CharacterKeyHandler(CGUIKeyEventArgs KeyboardArgs) // If the input is not a command, store it m_pInputHistory->Add(m_strInputText); } - else if (m_strCommand.compare("login") != 0) + else { - // If the input is a command, check that it isn't the 'login' command, if it is censor it + // If the input is a command, check that it isn't the 'login' or 'register' command, if it is censor it char szInput[256]; unsigned int uiLength = sizeof(szInput) - 1; @@ -667,11 +667,24 @@ bool CChat::CharacterKeyHandler(CGUIKeyEventArgs KeyboardArgs) szInput[uiLength] = '\0'; const char* szCommand = strtok(szInput, " "); - - if (szCommand && (strcmp(szCommand, "login") != 0)) + + if (szCommand && (strcmp(szCommand, "login") == 0)) + { + // Censor the login command + if (m_pInputHistory->Empty() || m_pInputHistory->GetLast() != std::string("/login")) + m_pInputHistory->Add("/login"); + } + else if (szCommand && (strcmp(szCommand, "register") == 0)) + { + // Censor the register command + if (m_pInputHistory->Empty() || m_pInputHistory->GetLast() != std::string("/register")) + m_pInputHistory->Add("/register"); + } + else + { + // Store the command as-is m_pInputHistory->Add(m_strInputText); - else if ((m_pInputHistory->Empty() || m_pInputHistory->GetLast() != std::string("/login"))) - m_pInputHistory->Add("/login"); + } } }