Hi, The attached patch fixes the attached test.cs.
Uri.IsWellFormedUriString calls the .ctor which throws an exception. The .ctor throwing the exception is expected behavior, IsWellFormedUriString throwing is not expected. I would also like to apply this to the 2.4 branch. -bill 2009-01-21 Bill Holmes <billholme...@gmail.com> * Uri.cs (IsWellFormedUriString): Changing IsWellFormedUriString to not throw an exception but return false instead. Contributed under MIT/X11 license.
using System; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { string link = "adat"; if (Uri.IsWellFormedUriString(link, UriKind.Absolute)) // <- Exception is thrown. { Console.WriteLine("Good link"); } else { Console.WriteLine("Bad link"); } } } }
Index: mcs/class/System/System/ChangeLog =================================================================== --- mcs/class/System/System/ChangeLog (revision 124048) +++ mcs/class/System/System/ChangeLog (working copy) @@ -1,3 +1,10 @@ +2009-01-21 Bill Holmes <billholme...@gmail.com> + + * Uri.cs (IsWellFormedUriString): Changing IsWellFormedUriString + to not throw an exception but return false instead. + + Contributed under MIT/X11 license. + 2009-15-01 Leeszek Ciesielski <skol...@gmail.com> * Uri.cs: Use registered UriParser when a custom schema is passed Index: mcs/class/System/System/Uri.cs =================================================================== --- mcs/class/System/System/Uri.cs (revision 124048) +++ mcs/class/System/System/Uri.cs (working copy) @@ -1992,8 +1992,13 @@ { if (uriString == null) return false; - Uri uri = new Uri (uriString, uriKind); - return uri.IsWellFormedOriginalString (); + try { + Uri uri = new Uri (uriString, uriKind); + return uri.IsWellFormedOriginalString (); + } + catch (UriFormatException) { + return false; + } } public static bool TryCreate (string uriString, UriKind uriKind, out Uri result)
_______________________________________________ Mono-devel-list mailing list Mono-devel-list@lists.ximian.com http://lists.ximian.com/mailman/listinfo/mono-devel-list