This commit is contained in:
parent
366f5c2d0e
commit
9d4e5f76ce
@ -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
|
Loading…
x
Reference in New Issue
Block a user