From 0959c115746277e8c5fb6a98188b8690a812f4f2 Mon Sep 17 00:00:00 2001 From: arch1t3cht Date: Tue, 21 Jan 2025 22:37:58 +0100 Subject: [PATCH] Fix path decoding on Windows After switching to std::filesystem, Decode("?foo\\bar.txt") would resolve to C:\bar.txt on Windows, since joining a path starting with a backslash will remove any relative path from the left-hand side. Fix this by stripping a leading backslash on Windows just like a leading forward slash is stripped. --- libaegisub/common/path.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libaegisub/common/path.cpp b/libaegisub/common/path.cpp index 9b29e652c5..cae341506a 100644 --- a/libaegisub/common/path.cpp +++ b/libaegisub/common/path.cpp @@ -68,7 +68,7 @@ fs::path Path::Decode(std::string_view path) const { if (idx == -1 || paths[idx].empty()) return fs::path(path).make_preferred(); path = path.substr(tokens[idx].size()); - if (path.size() && path[0] == '/') path.remove_prefix(1); + if (path.size() && (path[0] == '/' || path[0] == std::filesystem::path::preferred_separator)) path.remove_prefix(1); if (path.empty()) return paths[idx]; return (paths[idx]/path).make_preferred(); }