Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/corert.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnirudh Agnihotry <anirudhagnihotry098@gmail.com>2018-03-02 08:53:25 +0300
committerJan Kotas <jkotas@microsoft.com>2018-03-03 04:11:24 +0300
commitb1151798464be3729857576fd02027158daf8c32 (patch)
treea150bcb62e2f44fec39012468e0d2a42b45e9ed5
parentbd1bc87e521df5ff17ce83ce38b1d825ab807c4a (diff)
Fixing GetFullPath (dotnet/coreclr#16670)
Signed-off-by: dotnet-bot <dotnet-bot@microsoft.com>
-rw-r--r--src/System.Private.CoreLib/shared/System/IO/Path.Windows.cs8
-rw-r--r--src/System.Private.CoreLib/shared/System/IO/Path.cs2
2 files changed, 7 insertions, 3 deletions
diff --git a/src/System.Private.CoreLib/shared/System/IO/Path.Windows.cs b/src/System.Private.CoreLib/shared/System/IO/Path.Windows.cs
index b921db9e6..044833773 100644
--- a/src/System.Private.CoreLib/shared/System/IO/Path.Windows.cs
+++ b/src/System.Private.CoreLib/shared/System/IO/Path.Windows.cs
@@ -72,6 +72,9 @@ namespace System.IO
if (IsPathFullyQualified(path))
return GetFullPath(path);
+ if (PathInternal.IsEffectivelyEmpty(path))
+ return basePath;
+
int length = path.Length;
string combinedPath = null;
@@ -80,7 +83,7 @@ namespace System.IO
// Path is current drive rooted i.e. starts with \:
// "\Foo" and "C:\Bar" => "C:\Foo"
// "\Foo" and "\\?\C:\Bar" => "\\?\C:\Foo"
- combinedPath = Join(GetPathRoot(basePath.AsSpan()), path);
+ combinedPath = Join(GetPathRoot(basePath.AsSpan()), path.AsSpan().Slice(1)); // Cut the separator to ensure we don't end up with two separators when joining with the root.
}
else if (length >= 2 && PathInternal.IsValidDriveChar(path[0]) && path[1] == PathInternal.VolumeSeparatorChar)
{
@@ -118,7 +121,8 @@ namespace System.IO
// to GetFullPath() won't do anything by design. Additionally, GetFullPathName() in
// Windows doesn't root them properly. As such we need to manually remove segments.
return PathInternal.IsDevice(combinedPath)
- ? RemoveRelativeSegments(combinedPath, PathInternal.GetRootLength(combinedPath))
+ // Paths at this point are in the form of \\?\C:\.\tmp we skip to the last character of the root when calling RemoveRelativeSegments to remove relative paths in such cases.
+ ? RemoveRelativeSegments(combinedPath, PathInternal.GetRootLength(combinedPath) - 1)
: GetFullPath(combinedPath);
}
diff --git a/src/System.Private.CoreLib/shared/System/IO/Path.cs b/src/System.Private.CoreLib/shared/System/IO/Path.cs
index 41ae1cd0b..fe6234cc7 100644
--- a/src/System.Private.CoreLib/shared/System/IO/Path.cs
+++ b/src/System.Private.CoreLib/shared/System/IO/Path.cs
@@ -738,7 +738,7 @@ namespace System.IO
{
if (PathInternal.IsDirectorySeparator(sb[s]))
{
- sb.Length = s;
+ sb.Length = (i + 3 >= path.Length && s <= skip ) ? s + 1 : s; // to avoid removing the complete "\tmp\" segment in cases like \\?\C:\tmp\..\, C:\tmp\..
break;
}
}