From 58f9c991887293ca8a9ca375c63e15b2e9664798 Mon Sep 17 00:00:00 2001 From: Anirudh Agnihotry Date: Thu, 30 Nov 2017 11:54:26 -0800 Subject: Removed Check Invalid Path Chars (dotnet/coreclr#15191) Removed Check Invalid Chars from Coreclr Signed-off-by: dotnet-bot --- .../shared/System/IO/Path.Unix.cs | 3 --- .../shared/System/IO/Path.Windows.cs | 4 ---- src/System.Private.CoreLib/shared/System/IO/Path.cs | 20 -------------------- .../shared/System/IO/PathInternal.cs | 16 ---------------- 4 files changed, 43 deletions(-) diff --git a/src/System.Private.CoreLib/shared/System/IO/Path.Unix.cs b/src/System.Private.CoreLib/shared/System/IO/Path.Unix.cs index 4ed5069b3..61a8314ac 100644 --- a/src/System.Private.CoreLib/shared/System/IO/Path.Unix.cs +++ b/src/System.Private.CoreLib/shared/System/IO/Path.Unix.cs @@ -25,8 +25,6 @@ namespace System.IO if (path.Length == 0) throw new ArgumentException(SR.Arg_PathEmpty, nameof(path)); - PathInternal.CheckInvalidPathChars(path); - // Expand with current directory if necessary if (!IsPathRooted(path)) { @@ -176,7 +174,6 @@ namespace System.IO if (path == null) return false; - PathInternal.CheckInvalidPathChars(path); return path.Length > 0 && path[0] == PathInternal.DirectorySeparatorChar; } 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 373234782..5d92d3b49 100644 --- a/src/System.Private.CoreLib/shared/System/IO/Path.Windows.cs +++ b/src/System.Private.CoreLib/shared/System/IO/Path.Windows.cs @@ -119,8 +119,6 @@ namespace System.IO { if (path != null) { - PathInternal.CheckInvalidPathChars(path); - int length = path.Length; if ((length >= 1 && PathInternal.IsDirectorySeparator(path[0])) || (length >= 2 && PathInternal.IsValidDriveChar(path[0]) && path[1] == PathInternal.VolumeSeparatorChar)) @@ -144,8 +142,6 @@ namespace System.IO if (PathInternal.IsEffectivelyEmpty(path)) throw new ArgumentException(SR.Arg_PathEmpty, nameof(path)); - PathInternal.CheckInvalidPathChars(path); - // Need to return the normalized directory separator path = PathInternal.NormalizeDirectorySeparators(path); diff --git a/src/System.Private.CoreLib/shared/System/IO/Path.cs b/src/System.Private.CoreLib/shared/System/IO/Path.cs index c9b9ed0cd..9f3f48600 100644 --- a/src/System.Private.CoreLib/shared/System/IO/Path.cs +++ b/src/System.Private.CoreLib/shared/System/IO/Path.cs @@ -41,8 +41,6 @@ namespace System.IO { if (path != null) { - PathInternal.CheckInvalidPathChars(path); - string s = path; for (int i = path.Length - 1; i >= 0; i--) { @@ -81,7 +79,6 @@ namespace System.IO if (PathInternal.IsEffectivelyEmpty(path)) throw new ArgumentException(SR.Arg_PathEmpty, nameof(path)); - PathInternal.CheckInvalidPathChars(path); path = PathInternal.NormalizeDirectorySeparators(path); int root = PathInternal.GetRootLength(path); @@ -104,7 +101,6 @@ namespace System.IO if (path == null) return null; - PathInternal.CheckInvalidPathChars(path); int length = path.Length; for (int i = length - 1; i >= 0; i--) { @@ -194,8 +190,6 @@ namespace System.IO { if (path != null) { - PathInternal.CheckInvalidPathChars(path); - for (int i = path.Length - 1; i >= 0; i--) { char ch = path[i]; @@ -214,9 +208,6 @@ namespace System.IO if (path1 == null || path2 == null) throw new ArgumentNullException((path1 == null) ? nameof(path1) : nameof(path2)); - PathInternal.CheckInvalidPathChars(path1); - PathInternal.CheckInvalidPathChars(path2); - return CombineNoChecks(path1, path2); } @@ -225,10 +216,6 @@ namespace System.IO if (path1 == null || path2 == null || path3 == null) throw new ArgumentNullException((path1 == null) ? nameof(path1) : (path2 == null) ? nameof(path2) : nameof(path3)); - PathInternal.CheckInvalidPathChars(path1); - PathInternal.CheckInvalidPathChars(path2); - PathInternal.CheckInvalidPathChars(path3); - return CombineNoChecks(path1, path2, path3); } @@ -237,11 +224,6 @@ namespace System.IO if (path1 == null || path2 == null || path3 == null || path4 == null) throw new ArgumentNullException((path1 == null) ? nameof(path1) : (path2 == null) ? nameof(path2) : (path3 == null) ? nameof(path3) : nameof(path4)); - PathInternal.CheckInvalidPathChars(path1); - PathInternal.CheckInvalidPathChars(path2); - PathInternal.CheckInvalidPathChars(path3); - PathInternal.CheckInvalidPathChars(path4); - return CombineNoChecks(path1, path2, path3, path4); } @@ -270,8 +252,6 @@ namespace System.IO continue; } - PathInternal.CheckInvalidPathChars(paths[i]); - if (IsPathRooted(paths[i])) { firstComponent = i; diff --git a/src/System.Private.CoreLib/shared/System/IO/PathInternal.cs b/src/System.Private.CoreLib/shared/System/IO/PathInternal.cs index 9362636f8..bfd69e925 100644 --- a/src/System.Private.CoreLib/shared/System/IO/PathInternal.cs +++ b/src/System.Private.CoreLib/shared/System/IO/PathInternal.cs @@ -10,21 +10,6 @@ namespace System.IO /// Contains internal path helpers that are shared between many projects. internal static partial class PathInternal { - /// - /// Checks for invalid path characters in the given path. - /// - /// Thrown if the path is null. - /// Thrown if the path has invalid characters. - /// The path to check for invalid characters. - internal static void CheckInvalidPathChars(string path) - { - if (path == null) - throw new ArgumentNullException(nameof(path)); - - if (HasIllegalCharacters(path)) - throw new ArgumentException(SR.Argument_InvalidPathChars, nameof(path)); - } - /// /// Returns the start index of the filename /// in the given path, or 0 if no directory @@ -40,7 +25,6 @@ namespace System.IO internal static int FindFileNameIndex(string path) { Debug.Assert(path != null); - CheckInvalidPathChars(path); for (int i = path.Length - 1; i >= 0; i--) { -- cgit v1.2.3