Merge pull request #1299 from esdrubal/uriuserinfo
authorRodrigo Kumpera <kumpera@gmail.com>
Tue, 23 Sep 2014 18:00:13 +0000 (14:00 -0400)
committerRodrigo Kumpera <kumpera@gmail.com>
Tue, 23 Sep 2014 18:00:13 +0000 (14:00 -0400)
UriParseComponents no longer decodes '@' in UserInfo.

1  2 
mcs/class/System/System/UriParseComponents.cs
mcs/class/System/Test/System/UriTest.cs

index 347b859ccd87c4025be06f9da996c716d5149524,5e94d3bdf539e67969bdcc768a3c4464debf0a03..39c26a8588f48b9286b8a8f0a2459d1ba2e5ba8a
@@@ -206,7 -206,7 +206,7 @@@ namespace System 
                        state.elements.scheme = Uri.UriSchemeFile;
                        state.elements.delimiter = "://";
                        state.elements.isUnixFilePath = true;
 -                      state.elements.isAbsoluteUri = (state.kind == UriKind.Relative)? false : true;
 +                      state.elements.isAbsoluteUri = state.kind == UriKind.Absolute;
  
                        if (part.Length >= 2 && part [0] == '/' && part [1] == '/') {
                                part = part.TrimStart (new char [] {'/'});
                                if (ch == '%'){
                                        if (!Uri.IsHexEncoding (part, index))
                                                return false;
+                                       var oldIndex = index;
                                        ch = Uri.HexUnescape (part, ref index);
+                                       index--;
+                                       if (ch == '@') {
+                                               sb.Append (part.Substring (oldIndex, index - oldIndex + 1));
+                                               continue;
+                                       }
                                }
  
                                if (Char.IsLetterOrDigit (ch) || IsUnreserved (ch) || IsSubDelim (ch) || ch == ':'){
index b1332125db82b9792478ae00dfa191dd8d1d8841,4cf95d4456b94909b89ec9a9edbab97fe21311ac..be0c0370b137c18ff8e97c03ed65a96413d47aca
@@@ -1940,13 -1940,6 +1940,13 @@@ namespace MonoTests.Syste
                        Assert.AreEqual ("id=1%262&sort=asc", escaped, "UriEscaped");
                }
  
 +              [Test]
 +              public void RelativeOrAbsoluteUnixPath ()
 +              {
 +                      var uri = new Uri ("/abc", UriKind.RelativeOrAbsolute);
 +                      Assert.IsFalse (uri.IsAbsoluteUri);
 +              }
 +
                [Test]
                // Bug #12631
                public void LocalPathWithBaseUrl ()
                        var uri = new Uri ("/relative/path", UriKind.Relative);
                        uri.GetComponents (UriComponents.SerializationInfoString  | UriComponents.Host, UriFormat.UriEscaped);
                }
+               [Test]
+               public void UserInfo_EscapedLetter ()
+               {
+                       var uri = new Uri ("https://first%61second@host");
+                       Assert.AreEqual ("firstasecond", uri.UserInfo);
+               }
+               [Test]
+               public void UserInfo_EscapedAt ()
+               {
+                       var userinfo =  "first%40second";
+                       var uri = new Uri ("https://" + userinfo + "@host");
+                       Assert.AreEqual (userinfo, uri.UserInfo);
+               }
        }
  
        // Tests non default IriParsing