From 074f66eb7f7ed7805807a736aaf7af67ea775ff1 Mon Sep 17 00:00:00 2001 From: Chris Miles Date: Wed, 21 May 2025 16:31:10 -0500 Subject: [PATCH] [World API] Input Validation --- world/console.cpp | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/world/console.cpp b/world/console.cpp index b24ae4797..2fcc878bf 100644 --- a/world/console.cpp +++ b/world/console.cpp @@ -95,9 +95,22 @@ void ConsoleApi( BenchTimer timer; timer.reset(); - EQEmuApiWorldDataService::get(response, args); + std::string method = args.empty() ? "" : args[0]; - std::string method = args[0]; + if (method.empty()) { + root["execution_time"] = std::to_string(timer.elapsed()); + root["method"] = method; + root["data"] = response; + root["error"] = "No method specified"; + + std::stringstream payload; + payload << root; + connection->SendLine(payload.str()); + return; + } + + // Safe to call now that args[0] is known to exist + EQEmuApiWorldDataService::get(response, args); root["execution_time"] = std::to_string(timer.elapsed()); root["method"] = method; @@ -105,7 +118,6 @@ void ConsoleApi( std::stringstream payload; payload << root; - connection->SendLine(payload.str()); }