Skip to content

Commit 1042720

Browse files
committed
Fix UNC paths
If the input file was a network path then the raw path returned by GetFinalPathByHandle may return a UNC path. If so, and if the original path wasn't a UNC path, and the original path doesn't need normalization, we want to use the original path.
1 parent 00ba6d5 commit 1042720

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/native/corehost/hostmisc/pal.windows.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -898,8 +898,12 @@ bool pal::realpath(pal::string_t* path, bool skip_error_logging)
898898
}
899899
}
900900

901-
// Remove the \\?\ prefix, unless it is necessary or was already there
902-
if (LongFile::IsExtended(str) && !LongFile::IsExtended(*path) &&
901+
// Remove the UNC prefix (\\?\UNC\) or extended prefix (\\?\) unless it is necessary or was already there
902+
if (LongFile::IsUNCExtended(str) && !LongFile::IsUNCExtended(*path) && !LongFile::ShouldNormalize(*path))
903+
{
904+
str = *path;
905+
}
906+
else if (LongFile::IsExtended(str) && !LongFile::IsExtended(*path) &&
903907
!LongFile::ShouldNormalize(str.substr(LongFile::ExtendedPrefix.size())))
904908
{
905909
str.erase(0, LongFile::ExtendedPrefix.size());

0 commit comments

Comments
 (0)