[Mono-bugs] [Bug 78781][Nor] New - System.Uri throws UriFormatException on single digit port numbers

bugzilla-daemon at bugzilla.ximian.com bugzilla-daemon at bugzilla.ximian.com
Thu Jul 6 17:44:00 EDT 2006


Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.

Changed by boykin at pobox.com.

http://bugzilla.ximian.com/show_bug.cgi?id=78781

--- shadow/78781	2006-07-06 17:44:00.000000000 -0400
+++ shadow/78781.tmp.28306	2006-07-06 17:44:00.000000000 -0400
@@ -0,0 +1,63 @@
+Bug#: 78781
+Product: Mono: Class Libraries
+Version: 1.1
+OS: 
+OS Details: 
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Normal
+Component: System
+AssignedTo: mono-bugs at ximian.com                            
+ReportedBy: boykin at pobox.com               
+QAContact: mono-bugs at ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: System.Uri throws UriFormatException on single digit port numbers
+
+System.Uri throws the following exception:
+System.UriFormatException: Invalid URI: The hostname could not be parsed
+
+anytime the port number is between 0 and 9 inclusive.
+
+
+To reproduce, run this program:
+=====
+public class UriTest {
+
+  public static void Main(string[] args) {
+          
+    for(int i = 0; i < System.UInt16.MaxValue; i++) {
+      string uri = "myscheme://127.0.0.1:" + i.ToString();
+      try {
+        System.Uri u = new System.Uri(uri);
+      }
+      catch(System.Exception x) {
+        System.Console.WriteLine("Port: {0}, uri: {1}\n{2}",i,uri,x);   
+      }
+    }
+  }
+
+}
+===
+
+On mono 1.1.13.6 I get the following output:
+
+=====
+Port: 0, uri: myscheme://127.0.0.1:0
+System.UriFormatException: Invalid URI: The hostname could not be parsed.
+in <0x00f1b> System.Uri:Parse (System.String uriString)
+in <0x00014> System.Uri:ParseUri ()
+in <0x0000a> System.Uri:Parse ()
+in <0x00051> System.Uri:.ctor (System.String uriString, Boolean dontEscape)
+in <0x0000f> System.Uri:.ctor (System.String uriString)
+in (wrapper remoting-invoke-with-check) System.Uri:.ctor (string)
+in <0x00067> UriTest:Main (System.String[] args)
+=====
+
+For each port 0 to 9.
+
+I would expect that the port number would not effect whether the hostname
+could be parsed, and I would expect in no case would the above code result
+in an Exception.


More information about the mono-bugs mailing list