aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLiam Mitchell <[email protected]>2026-01-28 17:58:55 -0800
committerLiam Mitchell <[email protected]>2026-01-28 17:58:55 -0800
commit7fd067e92de82ca1ba737c95bf3bcaa10a1075ba (patch)
tree5c7f099522c850157e9597dc72816796ab0b2253 /src
parentUse std::mismatch to compare paths and hoist project root canonicalization ou... (diff)
downloadzen-7fd067e92de82ca1ba737c95bf3bcaa10a1075ba.tar.xz
zen-7fd067e92de82ca1ba737c95bf3bcaa10a1075ba.zip
Revert to previous behaviour for path checking in the presence of an empty project root
Diffstat (limited to 'src')
-rw-r--r--src/zenserver/storage/projectstore/httpprojectstore.cpp22
1 files changed, 13 insertions, 9 deletions
diff --git a/src/zenserver/storage/projectstore/httpprojectstore.cpp b/src/zenserver/storage/projectstore/httpprojectstore.cpp
index 0ff628d43..10207a388 100644
--- a/src/zenserver/storage/projectstore/httpprojectstore.cpp
+++ b/src/zenserver/storage/projectstore/httpprojectstore.cpp
@@ -2900,10 +2900,14 @@ HttpProjectService::HandleRpcRequest(HttpRouterRequest& Req)
if (DataHash == IoHash::Zero)
{
- std::string_view ServerPath = View["serverpath"sv].AsString();
- std::error_code Ec;
- const std::filesystem::path CanonicalPath =
- std::filesystem::canonical(Project->RootDir / ServerPath, Ec);
+ std::string_view ServerPath = View["serverpath"sv].AsString();
+ std::error_code Ec;
+ std::filesystem::path FilePath = Project->RootDir / ServerPath;
+ if (!CanonicalRoot.empty())
+ {
+ FilePath = std::filesystem::canonical(FilePath, Ec);
+ }
+
if (Ec)
{
ZEN_WARN("Failed to find file '{}' in project root '{}' for 'snapshot'. Reason: '{}'",
@@ -2914,22 +2918,22 @@ HttpProjectService::HandleRpcRequest(HttpRouterRequest& Req)
continue;
}
- if (std::mismatch(CanonicalRoot.begin(), CanonicalRoot.end(), CanonicalPath.begin()).first !=
+ if (std::mismatch(CanonicalRoot.begin(), CanonicalRoot.end(), FilePath.begin()).first !=
CanonicalRoot.end())
{
- ZEN_WARN("Unable to read file '{}' outside of project root '{}'", CanonicalPath, CanonicalRoot);
+ ZEN_WARN("Unable to read file '{}' outside of project root '{}'", FilePath, CanonicalRoot);
AllOk = false;
continue;
}
BasicFile DataFile;
- DataFile.Open(CanonicalPath, BasicFile::Mode::kRead, Ec);
+ DataFile.Open(FilePath, BasicFile::Mode::kRead, Ec);
if (Ec)
{
// Error...
- ZEN_ERROR("unable to read data from file '{}': {}", CanonicalPath, Ec.message());
+ ZEN_ERROR("unable to read data from file '{}': {}", FilePath, Ec.message());
AllOk = false;
}
@@ -2950,7 +2954,7 @@ HttpProjectService::HandleRpcRequest(HttpRouterRequest& Req)
{
Oid ChunkId = View["id"sv].AsObjectId();
ZEN_ERROR("unable to write external file as compressed chunk '{}', id {}: {}",
- CanonicalPath,
+ FilePath,
ChunkId,
Ec.message());
AllOk = false;