aboutsummaryrefslogtreecommitdiff
path: root/src/zenserver/storage/projectstore
diff options
context:
space:
mode:
authorDan Engelbrecht <[email protected]>2026-02-04 13:20:20 +0100
committerGitHub Enterprise <[email protected]>2026-02-04 13:20:20 +0100
commit05108dad394952733838daf442ffdd553a62b727 (patch)
tree8fd64eb6ba26e93da5b1a165750a9f7ad2fc67de /src/zenserver/storage/projectstore
parentimplemented chunking for TransmitFile path (#736) (diff)
downloadzen-05108dad394952733838daf442ffdd553a62b727.tar.xz
zen-05108dad394952733838daf442ffdd553a62b727.zip
use matcher over regex (#744)
* replace http router AddPattern with AddMatcher * fix scrub logging
Diffstat (limited to 'src/zenserver/storage/projectstore')
-rw-r--r--src/zenserver/storage/projectstore/httpprojectstore.cpp22
1 files changed, 17 insertions, 5 deletions
diff --git a/src/zenserver/storage/projectstore/httpprojectstore.cpp b/src/zenserver/storage/projectstore/httpprojectstore.cpp
index 86b4d7100..416e2ed69 100644
--- a/src/zenserver/storage/projectstore/httpprojectstore.cpp
+++ b/src/zenserver/storage/projectstore/httpprojectstore.cpp
@@ -549,11 +549,23 @@ HttpProjectService::HttpProjectService(CidStore& Store,
using namespace std::literals;
- m_Router.AddPattern("project", "([[:alnum:]_.]+)");
- m_Router.AddPattern("log", "([[:alnum:]_.]+)");
- m_Router.AddPattern("op", "([[:digit:]]+?)");
- m_Router.AddPattern("chunk", "([[:xdigit:]]{24})");
- m_Router.AddPattern("hash", "([[:xdigit:]]{40})");
+ static constexpr AsciiSet ValidProjectCharactersSet{"abcdefghijklmnopqrstuvwxyz0123456789_.ABCDEFGHIJKLMNOPQRSTUVWXYZ"};
+ static constexpr AsciiSet ValidOplogCharactersSet{"abcdefghijklmnopqrstuvwxyz0123456789_.ABCDEFGHIJKLMNOPQRSTUVWXYZ"};
+ static constexpr AsciiSet ValidNumberCharactersSet{"0123456789"};
+ static constexpr AsciiSet ValidHexCharactersSet{"0123456789abcdefABCDEF"};
+
+ m_Router.AddMatcher("project",
+ [](std::string_view Str) -> bool { return !Str.empty() && AsciiSet::HasOnly(Str, ValidProjectCharactersSet); });
+ m_Router.AddMatcher("log",
+ [](std::string_view Str) -> bool { return !Str.empty() && AsciiSet::HasOnly(Str, ValidOplogCharactersSet); });
+ m_Router.AddMatcher("op",
+ [](std::string_view Str) -> bool { return !Str.empty() && AsciiSet::HasOnly(Str, ValidNumberCharactersSet); });
+ m_Router.AddMatcher("chunk", [](std::string_view Str) -> bool {
+ return Str.length() == Oid::StringLength && AsciiSet::HasOnly(Str, ValidHexCharactersSet);
+ });
+ m_Router.AddMatcher("hash", [](std::string_view Str) -> bool {
+ return Str.length() == IoHash::StringLength && AsciiSet::HasOnly(Str, ValidHexCharactersSet);
+ });
m_Router.RegisterRoute(
"",