diff --git a/backend/src/engine.cpp b/backend/src/engine.cpp index 2c803ff..1745531 100644 --- a/backend/src/engine.cpp +++ b/backend/src/engine.cpp @@ -46,6 +46,10 @@ std::vector BookStoreEngineClass::Execute( std::string head = ""; ss >> head; if (head == "quit" || head == "exit") { + static std::basic_regex quit_regex(R"(^ *(quit|exit) *$)", + std::regex_constants::optimize); + if (!std::regex_match(cmd, quit_regex)) + return std::vector({"Invalid"}); while (login_stack.size()) { login_count[login_stack.top().first]--; login_stack.pop(); @@ -394,9 +398,9 @@ std::vector BookStoreEngineClass::ExecuteShowFinance( std::vector BookStoreEngineClass::ExecuteLog( const std::string &cmd, std::stack> &login_stack) { - static std::basic_regex log_regex( - R"(^ *log *$)", std::regex_constants::optimize); - if(!std::regex_match(cmd, log_regex)) + static std::basic_regex log_regex(R"(^ *log *$)", + std::regex_constants::optimize); + if (!std::regex_match(cmd, log_regex)) return std::vector({"Invalid"}); return std::vector(); }