[System] Test Uri constructor with escaped user info chars.
authorMarcos Henrich <marcos.henrich@xamarin.com>
Fri, 5 Dec 2014 16:11:32 +0000 (16:11 +0000)
committerMarcos Henrich <marcos.henrich@xamarin.com>
Fri, 5 Dec 2014 16:11:32 +0000 (16:11 +0000)
mcs/class/System/Test/System/UriTest.cs

index fa76c2a67d414aa1b5a280128d1e648cbe7885fc..e9a92244f63c27b1eb745d3c792d8fdb6cbae586 100644 (file)
@@ -1983,6 +1983,19 @@ namespace MonoTests.System
                        var uri = new Uri ("https://" + userinfo + "@host");
                        Assert.AreEqual (userinfo, uri.UserInfo);
                }
+
+               [Test]
+               public void UserInfo_EscapedChars ()
+               {
+                       for (var ch = (char) 1; ch < 128; ch++) {
+                               var userinfo = Uri.EscapeDataString (ch.ToString ());
+                               try {
+                                       new Uri (string.Format("http://{0}@localhost:80/", userinfo));
+                               } catch (Exception e) {
+                                       Assert.Fail (string.Format("Unexpected {0} while building URI with username {1}", e.GetType ().Name, userinfo));
+                               }
+                       }
+               }
        }
 
        // Tests non default IriParsing