From 9d4e5f76cec12e4649d437e52d95c9deafec39c7 Mon Sep 17 00:00:00 2001 From: Your Name Date: Sun, 15 Jun 2025 21:37:21 +1200 Subject: [PATCH] 'Generic Commit' --- source/src/utils/utils.cpp | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/source/src/utils/utils.cpp b/source/src/utils/utils.cpp index 77f9444..fdbc730 100644 --- a/source/src/utils/utils.cpp +++ b/source/src/utils/utils.cpp @@ -650,11 +650,24 @@ bool file_replace_or_add_segment(std::string filepath, std::string segment) return true; } -bool legal_service_name(const std::string &service_name) -{ - // legal characters are alphanumeric, and - and _ - std::regex legal_chars("^[a-zA-Z0-9_-]+$"); - return std::regex_match(service_name, legal_chars); +bool legal_service_name(const std::string &service_name) { + static bool initialized = false; + static bool legal_chars[256] = {false}; // Initialize all to false + + // One-time initialization + if (!initialized) { + // Set true for valid characters + for (unsigned char c : "0123456789" + "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + "abcdefghijklmnopqrstuvwxyz" + "._-") { + legal_chars[c] = true; + } + initialized = true; + } + + return std::all_of(service_name.begin(), service_name.end(), + [](unsigned char c) { return legal_chars[c]; }); } } // namespace dropshell \ No newline at end of file