From d96ac911c927ec032f91fde2bed3de26c2353b1c Mon Sep 17 00:00:00 2001 From: littleblack111 Date: Tue, 27 May 2025 21:49:52 +0800 Subject: fix: don't accept ascii seq(0x1B) this can mess up terminals of others won't really affect the server as we using ftxui and it seems to not affect the output somehow --- src/session.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/session.cpp') diff --git a/src/session.cpp b/src/session.cpp index 2faab20..be1e3cd 100644 --- a/src/session.cpp +++ b/src/session.cpp @@ -1,9 +1,9 @@ -#include "session.hpp" #include "chatManager.hpp" #include "commandHandler.hpp" #include "format.hpp" #include "log.hpp" #include "server.hpp" +#include "session.hpp" #include "sessionManager.hpp" #include #include @@ -101,6 +101,8 @@ void CSession::SRecvData::sanitize() { if (!data.empty() && data.back() == '\n') data.pop_back(); + data.erase(std::remove(data.begin(), data.end(), asciiEscape), data.end()); // don't accept ASCII code, might mess up terminal + if (const auto start = data.find_first_not_of(" \t\r\n"); start != std::string::npos) { const auto end = data.find_last_not_of(" \t\r\n"); data = data.substr(start, end - start + 1); -- cgit v1.2.3