System.IO.Path.IsPathRooted does not check if valid drive letter on Windows (#10323)
authorViktor Hofer <viktor.hofer@outlook.com>
Tue, 21 Mar 2017 19:36:25 +0000 (20:36 +0100)
committerDan Moseley <danmose@microsoft.com>
Tue, 21 Mar 2017 19:36:25 +0000 (12:36 -0700)
src/mscorlib/shared/System/IO/Path.Windows.cs

index 0f8e3b3..d6f0c62 100644 (file)
@@ -114,7 +114,7 @@ namespace System.IO
         }
 
         // Tests if the given path contains a root. A path is considered rooted
-        // if it starts with a backslash ("\") or a drive letter and a colon (":").
+        // if it starts with a backslash ("\") or a valid drive letter and a colon (":").
         public static bool IsPathRooted(string path)
         {
             if (path != null)
@@ -123,7 +123,7 @@ namespace System.IO
 
                 int length = path.Length;
                 if ((length >= 1 && PathInternal.IsDirectorySeparator(path[0])) ||
-                    (length >= 2 && path[1] == PathInternal.VolumeSeparatorChar))
+                    (length >= 2 && PathInternal.IsValidDriveChar(path[0]) && path[1] == PathInternal.VolumeSeparatorChar))
                     return true;
             }
             return false;