TryParseComponent returns when the scheme has a registered parser.
authorMarcos Henrich <marcos.henrich@xamarin.com>
Tue, 29 Jul 2014 06:17:21 +0000 (07:17 +0100)
committerMarcos Henrich <marcos.henrich@xamarin.com>
Tue, 29 Jul 2014 06:17:21 +0000 (07:17 +0100)
mcs/class/System/System/UriParseComponents.cs

index 7051d391331aee84929fa7e6db48ee889a2c62f4..47716481489c1fc1f9d7a0ac28f3936badd47a10 100644 (file)
@@ -82,22 +82,29 @@ namespace System {
                        }
 
                        bool ok = ParseFilePath (state) &&
-                               ParseScheme (state) &&
+                               ParseScheme (state);
+
+                       var scheme = state.elements.scheme;
+                       UriParser parser = null;
+                       if (!string.IsNullOrEmpty (scheme)) {
+                               parser = UriParser.GetParser (scheme);
+                               if (parser != null && !(parser is DefaultUriParser))
+                                       return true;
+                       }
+
+                       ok = ok &&
                                ParseAuthority (state) &&
                                ParsePath (state) &&
                                ParseQuery (state) &&
                                ParseFragment (state);
 
-                       var scheme = state.elements.scheme;
                        if (string.IsNullOrEmpty (state.elements.host) &&
                                (scheme == Uri.UriSchemeHttp || scheme == Uri.UriSchemeGopher || scheme == Uri.UriSchemeNntp ||
                                scheme == Uri.UriSchemeHttps || scheme == Uri.UriSchemeFtp))
                                state.error = "Invalid URI: The Authority/Host could not be parsed.";
 
-                       var parser = UriParser.GetParser (scheme);
                        if (!string.IsNullOrEmpty (state.elements.host) &&
-                               Uri.CheckHostName (state.elements.host) == UriHostNameType.Unknown &&
-                               parser is DefaultUriParser)
+                               Uri.CheckHostName (state.elements.host) == UriHostNameType.Unknown)
                                state.error = "Invalid URI: The hostname could not be parsed.";
 
                        if (!string.IsNullOrEmpty (state.error)) {