From 7c5d7a70cce9cff841f7e6a4e233621cdf3767ca Mon Sep 17 00:00:00 2001 From: Titan <70135297+darkredtitan@users.noreply.github.com> Date: Sun, 29 Nov 2020 18:23:17 +0200 Subject: [PATCH] Fix enter key sending '\n' in passwords --- src/CNLoginServer.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/CNLoginServer.cpp b/src/CNLoginServer.cpp index f77af98..448f754 100644 --- a/src/CNLoginServer.cpp +++ b/src/CNLoginServer.cpp @@ -112,6 +112,11 @@ void CNLoginServer::login(CNSocket* sock, CNPacketData* data) { userPassword = std::string(U16toU8(login->szPassword).c_str()); } + // the client inserts a "\n" in the password if you press enter key in the middle of the password + // (not at the start or the end of the password field) + if (int(userPassword.find("\n")) > 0) + userPassword.erase(userPassword.find("\n"), 1); + // check regex if (!CNLoginServer::isLoginDataGood(userLogin, userPassword)) return loginFail(LoginError::LOGIN_ERROR, userLogin, sock);