diff options
| author | littleblack111 <littleblack11111@gmail.com> | 2025-05-27 21:49:52 +0800 |
|---|---|---|
| committer | littleblack111 <littleblack11111@gmail.com> | 2025-05-27 21:49:52 +0800 |
| commit | d96ac911c927ec032f91fde2bed3de26c2353b1c (patch) | |
| tree | 083679496935352230a22c775166e4196eec67b9 /src | |
| parent | 2f522573eea46c72f7e77be60ba9702725dca2fa (diff) | |
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
Diffstat (limited to 'src')
| -rw-r--r-- | src/session.cpp | 4 | ||||
| -rw-r--r-- | src/session.hpp | 2 |
2 files changed, 5 insertions, 1 deletions
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 <algorithm> #include <arpa/inet.h> @@ -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); diff --git a/src/session.hpp b/src/session.hpp index 9b4a970..263dcb6 100644 --- a/src/session.hpp +++ b/src/session.hpp @@ -21,6 +21,8 @@ class CSession { bool isEmpty() const; void sanitize(); + + static constexpr char asciiEscape = 0x1B; // }; const std::string &getName() const; |
