From fe4d62284f581b4d0fba0fcb71003fded7e4b322 Mon Sep 17 00:00:00 2001 From: AnakinRaW Date: Mon, 29 Jan 2024 10:28:02 +0100 Subject: [PATCH 1/3] check root for drive relative paths case insensitive. --- .../System.Private.CoreLib/src/System/IO/Path.Windows.cs | 2 +- .../System/IO/PathTests_Windows.cs | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/libraries/System.Private.CoreLib/src/System/IO/Path.Windows.cs b/src/libraries/System.Private.CoreLib/src/System/IO/Path.Windows.cs index e5ee3e8fec49f0..6a1e5ac4127dfb 100644 --- a/src/libraries/System.Private.CoreLib/src/System/IO/Path.Windows.cs +++ b/src/libraries/System.Private.CoreLib/src/System/IO/Path.Windows.cs @@ -89,7 +89,7 @@ public static string GetFullPath(string path, string basePath) // Drive relative paths Debug.Assert(length == 2 || !PathInternal.IsDirectorySeparator(path[2])); - if (GetVolumeName(path.AsSpan()).EqualsOrdinal(GetVolumeName(basePath.AsSpan()))) + if (GetVolumeName(path.AsSpan()).EqualsOrdinalIgnoreCase(GetVolumeName(basePath.AsSpan()))) { // Matching root // "C:Foo" and "C:\Bar" => "C:\Bar\Foo" diff --git a/src/libraries/System.Runtime/tests/System.Runtime.Extensions.Tests/System/IO/PathTests_Windows.cs b/src/libraries/System.Runtime/tests/System.Runtime.Extensions.Tests/System/IO/PathTests_Windows.cs index f1b27f9fef81f6..89b502d9e59929 100644 --- a/src/libraries/System.Runtime/tests/System.Runtime.Extensions.Tests/System/IO/PathTests_Windows.cs +++ b/src/libraries/System.Runtime/tests/System.Runtime.Extensions.Tests/System/IO/PathTests_Windows.cs @@ -563,6 +563,9 @@ public void GetFullPath_CommonDevice_Windows(string path, string basePath, strin { @"C:tmp", @"C:\git\runtime", @"C:\git\runtime\tmp" }, { @"C:", @"C:\git\runtime", @"C:\git\runtime" }, { @"C", @"C:\git\runtime", @"C:\git\runtime\C" }, + // https://github.com/dotnet/runtime/issues/97615 + { @"c:", @"C:\git\runtime", @"C:\git\runtime" }, + { @"C:tmp", @"c:\git\runtime", @"c:\git\runtime\tmp" }, { @"Z:tmp\foo\..", @"C:\git\runtime", @"Z:\tmp" }, { @"Z:tmp\foo\.", @"C:\git\runtime", @"Z:\tmp\foo" }, From 4dd5b29f225e10c3a913bddd6a0638990be1ea42 Mon Sep 17 00:00:00 2001 From: AnakinRaW Date: Sat, 16 Mar 2024 09:56:27 +0100 Subject: [PATCH 2/3] Remove link --- .../System/IO/PathTests_Windows.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/libraries/System.Runtime/tests/System.Runtime.Extensions.Tests/System/IO/PathTests_Windows.cs b/src/libraries/System.Runtime/tests/System.Runtime.Extensions.Tests/System/IO/PathTests_Windows.cs index 89b502d9e59929..46d7bf01c4ecae 100644 --- a/src/libraries/System.Runtime/tests/System.Runtime.Extensions.Tests/System/IO/PathTests_Windows.cs +++ b/src/libraries/System.Runtime/tests/System.Runtime.Extensions.Tests/System/IO/PathTests_Windows.cs @@ -563,7 +563,6 @@ public void GetFullPath_CommonDevice_Windows(string path, string basePath, strin { @"C:tmp", @"C:\git\runtime", @"C:\git\runtime\tmp" }, { @"C:", @"C:\git\runtime", @"C:\git\runtime" }, { @"C", @"C:\git\runtime", @"C:\git\runtime\C" }, - // https://github.com/dotnet/runtime/issues/97615 { @"c:", @"C:\git\runtime", @"C:\git\runtime" }, { @"C:tmp", @"c:\git\runtime", @"c:\git\runtime\tmp" }, From 0acd5ce91f75e71b484a644baa59a443e9d19144 Mon Sep 17 00:00:00 2001 From: AnakinRaW Date: Sat, 16 Mar 2024 19:24:23 +0100 Subject: [PATCH 3/3] apply feedback --- .../System.Private.CoreLib/src/System/IO/Path.Windows.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libraries/System.Private.CoreLib/src/System/IO/Path.Windows.cs b/src/libraries/System.Private.CoreLib/src/System/IO/Path.Windows.cs index 6a1e5ac4127dfb..81f2e063a847e1 100644 --- a/src/libraries/System.Private.CoreLib/src/System/IO/Path.Windows.cs +++ b/src/libraries/System.Private.CoreLib/src/System/IO/Path.Windows.cs @@ -349,8 +349,8 @@ internal static int GetUncRootLength(ReadOnlySpan path) if (!isDevice && path.Slice(0, 2).EqualsOrdinal(@"\\".AsSpan())) return 2; else if (isDevice && path.Length >= 8 - && (path.Slice(0, 8).EqualsOrdinal(PathInternal.UncExtendedPathPrefix.AsSpan()) - || path.Slice(5, 4).EqualsOrdinal(@"UNC\".AsSpan()))) + && (path.Slice(0, 8).EqualsOrdinalIgnoreCase(PathInternal.UncExtendedPathPrefix.AsSpan()) + || path.Slice(5, 4).EqualsOrdinalIgnoreCase(@"UNC\".AsSpan()))) return 8; return -1;