[Mono-bugs] [Bug 76643][Nor] Changed - System.Uri.ToString is broken

bugzilla-daemon at bugzilla.ximian.com bugzilla-daemon at bugzilla.ximian.com
Fri Nov 11 10:30:51 EST 2005

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 atsushi at ximian.com.


--- shadow/76643	2005-11-10 18:14:35.000000000 -0500
+++ shadow/76643.tmp.10571	2005-11-11 10:30:51.000000000 -0500
@@ -29,6 +29,39 @@
 			Console.WriteLine (uri.ToString ());
 mono outputs "file:///foo%bar" (meaning "/fooºr"). .NET correctly
 outputs "file:///foo%25bar"
+------- Additional Comments From atsushi at ximian.com  2005-11-11 10:30 -------
+This seems not a simple bug (it should be still fixed).
+When a string passed to Uri.ctor() contains a file path part, it is
+regarded as escaped (unless it is explicitly specified as "dontEscape"
+from its optional parameter). Thus, if there is a file whose name is
+foo%25bar, then it is unescaped as "foo%bar" (it will never exist on
+Windows BTW).
+new Uri ("file:///tmp/a%20a").LocalPath ==> \\tmp\a a
+new Uri ("file:///tmp/foo%25bar").LocalPath ==> \\tmp\foo%bar
+BTW, under MS.NET, in file URLs "///" are always treated as equivalent
+to "//", which represents a UNC. Thus, on Windows it is treated as a
+new Uri ("file:///foo%25bar").LocalPath ==> \\foo%25bar
+new Uri ("file:///foo%25bar").Host ==> foo%25bar
+On the other hand, we should handle it as a file path. Thus, it should
+be escaped as "/foo%bar", which matches our existing behavior.
+Uri.ToString() unescapes path strings (some tests are in
+class/System/Test/System/UriTest2.cs, actually in test-uri-list.txt).
+Under .NET 2.0, those properties become
+new Uri ("file:///foo%25bar").LocalPath ==> \\foo%bar
+new Uri ("file:///foo%25bar").Host ==> foo%25bar
+I'll revisit here after I fixed a collation bug I found with related
+to this bug.

More information about the mono-bugs mailing list