diff --git a/backend/src/engine.cpp b/backend/src/engine.cpp index 38e2425..1e00162 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(); @@ -313,7 +317,7 @@ std::vector BookStoreEngineClass::ExecuteMOdify( return std::vector({"Invalid"}); // debugPrint("successfully lexed modify"); // debugPrint("modify", new_ISBN, ' ', name, ' ', author, ' ', keyword, ' ', - // price); + // price); if (login_stack.empty() || user_data_base.GetPrevilege(login_stack.top().first) < 3) return std::vector({"Invalid"}); @@ -392,9 +396,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(); }