'Generic Commit'
Some checks failed
Dropshell Test / Build_and_Test (push) Failing after 3m12s

This commit is contained in:
Your Name 2025-06-15 21:37:21 +12:00
parent 366f5c2d0e
commit 9d4e5f76ce

View File

@ -650,11 +650,24 @@ bool file_replace_or_add_segment(std::string filepath, std::string segment)
return true; return true;
} }
bool legal_service_name(const std::string &service_name) bool legal_service_name(const std::string &service_name) {
{ static bool initialized = false;
// legal characters are alphanumeric, and - and _ static bool legal_chars[256] = {false}; // Initialize all to false
std::regex legal_chars("^[a-zA-Z0-9_-]+$");
return std::regex_match(service_name, legal_chars); // 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 } // namespace dropshell