From ec9690bbf82829d1ba3bd0fc18831a43fe6405fe Mon Sep 17 00:00:00 2001 From: Star Rauchenberger Date: Mon, 4 Nov 2024 13:22:20 -0500 Subject: Add maximum input length for server --- server_main.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/server_main.cpp b/server_main.cpp index 00a4e7a..8d2c4aa 100644 --- a/server_main.cpp +++ b/server_main.cpp @@ -81,6 +81,19 @@ class server { } void cmd_generate(websocketpp::connection_hdl connection, std::string text) { + if (text.size() > 150) { + std::string response = R"( + { + "type": "error", + "msg": "Input is too long (>150 characters)." + } + )"; + + socket_.send(connection, response, + websocketpp::frame::opcode::value::TEXT); + return; + } + asio::post(std::bind(&server::generate_thread, this, connection, text)); } -- cgit 1.4.1