From 8be3324f3184eaaa8630ff819a3cbc94f85db64d Mon Sep 17 00:00:00 2001 From: Robert Nederhorst Date: Tue, 17 Mar 2026 08:17:42 -0700 Subject: [PATCH] fix(utility): fix three Windows path handling bugs in URI conversion 1. posix_path_to_uri: reverse_remap_file_path() was called with the original `path` argument instead of the processed `p`, discarding any relative-to-absolute path resolution done earlier in the function. 2. uri_to_posix_path: drive letter regex only matched uppercase [A-Z], so a URI with a lowercase drive letter (e.g. /c:/Users/...) would retain the leading slash, producing an invalid Windows path. 3. posix_path_to_uri: file URIs were built with host("localhost"), producing file://localhost/C:/... which can cause parsing mismatches on deserialization. The standard form file:///C:/... (empty host) is more portable. The existing code comments (lines 595-599) already noted that localhost doesn't work with some readers like ffmpeg. Co-Authored-By: Claude Opus 4.6 (1M context) --- src/utility/src/helpers.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/utility/src/helpers.cpp b/src/utility/src/helpers.cpp index d52b8e3df..424583990 100644 --- a/src/utility/src/helpers.cpp +++ b/src/utility/src/helpers.cpp @@ -321,7 +321,7 @@ std::string xstudio::utility::uri_to_posix_path(const caf::uri &uri) { #ifdef _WIN32 static const std::regex drive_letter_with_unwanted_leading_fwd_slash( - R"(^\/[A-Z]\:)", std::regex::optimize); + R"(^\/[A-Za-z]\:)", std::regex::optimize); std::cmatch m; if (std::regex_search(path.c_str(), m, drive_letter_with_unwanted_leading_fwd_slash)) { // Remove the leading / @@ -571,7 +571,7 @@ caf::uri xstudio::utility::posix_path_to_uri(const std::string &path, const bool #endif } - p = reverse_remap_file_path(path); + p = reverse_remap_file_path(p); // spdlog::warn("posix_path_to_uri: {} -> {}", path, p); @@ -583,7 +583,7 @@ caf::uri xstudio::utility::posix_path_to_uri(const std::string &path, const bool if (not p.empty() && p[0] != '/') return caf::uri_builder().scheme("file").path(p).make(); - auto result = caf::uri_builder().scheme("file").host("localhost").path(p).make(); + auto result = caf::uri_builder().scheme("file").host("").path(p).make(); return result;