diff options
Diffstat (limited to 'src/zenserver/storage/projectstore/httpprojectstore.cpp')
| -rw-r--r-- | src/zenserver/storage/projectstore/httpprojectstore.cpp | 22 |
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; |