mirror of
https://github.com/Kitware/CMake.git
synced 2025-10-14 19:08:07 +08:00
cmSystemTools: Fix regression in input path normalization on Windows
Since commit 622596c6b2
(cmSystemTools: Re-implement
ToNormalizedPathOnDisk without translation map, 2024-10-30,
v4.0.0-rc1~528^2~5) we normalize input paths, while resolving symlinks
only if followed by `..` components, by using `cm::PathResolver`'s
`LogicalPath` mode. However, that approach assumes POSIX semantics for
resolving paths with symlinks and is incorrect on Windows.
On Windows, file system operations naively remove any component
preceding `..` regardless of whether it is a symlink. Prior to the
above commit, `ToNormalizedPathOnDisk` matched that behavior using
`CollapseFullPath` followed by `GetActualCaseForPath`. Restore it using
`cm::PathResolver`'s `CasePath` mode.
Issue: #26750
This commit is contained in:
@@ -1991,8 +1991,13 @@ std::vector<std::string> cmSystemTools::SplitEnvPathNormalized(
|
||||
std::string cmSystemTools::ToNormalizedPathOnDisk(std::string p)
|
||||
{
|
||||
using namespace cm::PathResolver;
|
||||
#ifdef _WIN32
|
||||
// IWYU pragma: no_forward_declare cm::PathResolver::Policies::CasePath
|
||||
static Resolver<Policies::CasePath> const resolver(RealOS);
|
||||
#else
|
||||
// IWYU pragma: no_forward_declare cm::PathResolver::Policies::LogicalPath
|
||||
static Resolver<Policies::LogicalPath> const resolver(RealOS);
|
||||
#endif
|
||||
resolver.Resolve(std::move(p), p);
|
||||
return p;
|
||||
}
|
||||
|
Reference in New Issue
Block a user