Browse Source

Merge pull request #1195 from akoeplinger/fix-uri-with-digits

[System] Fix parsing of URI schemes with digits
Marek Safar 11 years ago
parent
commit
e64af2edbf

+ 1 - 1
mcs/class/System/System/UriParseComponents.cs

@@ -228,7 +228,7 @@ namespace System {
 			int index;
 			for (index = 1; index < part.Length; index++ ) {
 				char ch = part [index];
-				if (ch != '.' && ch != '-' && ch != '+' && !IsAlpha (ch))
+				if (ch != '.' && ch != '-' && ch != '+' && !IsAlpha (ch) && !Char.IsDigit (ch))
 					break;
 				
 				sb.Append (ch);

+ 7 - 0
mcs/class/System/Test/System/UriTest.cs

@@ -1434,6 +1434,13 @@ namespace MonoTests.System
 			new Uri ("hey");
 		}
 
+		[Test]
+		public void SchemeWithDigits ()
+		{
+			Uri uri = new Uri ("net.p2p://foobar");
+			Assert.AreEqual ("net.p2p", uri.Scheme);
+		}
+
 		// on .NET 2.0 a port number is limited to UInt16.MaxValue
 		[ExpectedException (typeof (UriFormatException))]
 		[Test]