Skip to content

Commit

Permalink
Fix path decoding on Windows
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
arch1t3cht committed Jan 21, 2025
1 parent 0f268ed commit 0959c11
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion libaegisub/common/path.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down

0 comments on commit 0959c11

Please sign in to comment.