diff options
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; |
