diff options
| author | Stefan Boberg <[email protected]> | 2022-06-11 23:22:00 +0200 |
|---|---|---|
| committer | Stefan Boberg <[email protected]> | 2022-06-11 23:22:00 +0200 |
| commit | 348ae50c946b541ce935703045ab98a49d809ed4 (patch) | |
| tree | a400285c9e5ae215dc7ef3b2958ce922f48ec7bc /zenserver/cache/structuredcache.cpp | |
| parent | fixed mac build ("unused" variable) (diff) | |
| parent | clang-format fix (diff) | |
| download | zen-348ae50c946b541ce935703045ab98a49d809ed4.tar.xz zen-348ae50c946b541ce935703045ab98a49d809ed4.zip | |
Merge branch 'main' of https://github.com/EpicGames/zen
Diffstat (limited to 'zenserver/cache/structuredcache.cpp')
| -rw-r--r-- | zenserver/cache/structuredcache.cpp | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/zenserver/cache/structuredcache.cpp b/zenserver/cache/structuredcache.cpp index 07866d4f0..45bbe062b 100644 --- a/zenserver/cache/structuredcache.cpp +++ b/zenserver/cache/structuredcache.cpp @@ -77,7 +77,7 @@ struct PutRequestData }; namespace { - static constexpr std::string_view HttpZCacheRPCPrefix = "$rpc"sv; + static constinit std::string_view HttpZCacheRPCPrefix = "$rpc"sv; struct HttpRequestData { @@ -87,8 +87,8 @@ namespace { std::optional<IoHash> ValueContentId; }; - const char* ValidNamespaceNameCharacters = "abcdefghijklmnopqrstuvwxyz0123456789-_.ABCDEFGHIJKLMNOPQRSTUVWXYZ"; - const char* ValidBucketNameCharacters = "abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"; + constinit AsciiSet ValidNamespaceNameCharactersSet{"abcdefghijklmnopqrstuvwxyz0123456789-_.ABCDEFGHIJKLMNOPQRSTUVWXYZ"}; + constinit AsciiSet ValidBucketNameCharactersSet{"abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"}; std::optional<std::string> GetValidNamespaceName(std::string_view Name) { @@ -104,7 +104,7 @@ namespace { return {}; } - if (Name.find_first_not_of(ValidNamespaceNameCharacters) != std::string::npos) + if (!AsciiSet::HasOnly(Name, ValidNamespaceNameCharactersSet)) { ZEN_WARN("Namespace '{}' is invalid, invalid characters detected", Name); return {}; @@ -120,11 +120,13 @@ namespace { ZEN_WARN("Bucket name is invalid, empty bucket name is not allowed"); return {}; } - if (Name.find_first_not_of(ValidBucketNameCharacters) != std::string::npos) + + if (!AsciiSet::HasOnly(Name, ValidBucketNameCharactersSet)) { ZEN_WARN("Bucket name '{}' is invalid, invalid characters detected", Name); return {}; } + return ToLower(Name); } |