[mono/mono] eda41be3: Support deserializing relative Uris. Fixes #15169.

"Jonathan Pryor ([email protected])" <[email protected]>
Newsgroups gmane.comp.gnome.mono.patches
Message-ID <000001417edd336a-7e702dc0-a91c-49d1-8b3d-3f2a29d6c03b-000000@email.amazonses.com>
   Branch: refs/heads/master
     Home: https://github.com/mono/mono
  Compare: https://github.com/mono/mono/compare/a769cce0b77f...eda41be35500

   Commit: eda41be355007cc088c47124d1ddf1e7e459b89d
   Author: Jonathan Pryor <[email protected]> (jonpryor)
     Date: 2013-10-03 15:06:21 GMT
      URL: https://github.com/mono/mono/commit/eda41be355007cc088c47124d1ddf1e7e459b89d

Support deserializing relative Uris. Fixes #15169.

Fixes: https://bugzilla.xamarin.com/show_bug.cgi?id=15169

Changed paths:
  M mcs/class/System.ServiceModel.Web/System.Runtime.Serialization.Json/JsonSerializationReader.cs
  M mcs/class/System.ServiceModel.Web/Test/System.Runtime.Serialization.Json/DataContractJsonSerializerTest.cs

Modified: mcs/class/System.ServiceModel.Web/System.Runtime.Serialization.Json/JsonSerializationReader.cs
===================================================================
@@ -162,7 +162,7 @@ public object ReadObject (Type type)
 						return null;
 					}
 					else
-						return new Uri (reader.ReadElementContentAsString ());
+						return new Uri (reader.ReadElementContentAsString (), UriKind.RelativeOrAbsolute);
 				} else if (type == typeof (XmlQualifiedName)) {
 					s = reader.ReadElementContentAsString ();
 					int idx = s.IndexOf (':');

Modified: mcs/class/System.ServiceModel.Web/Test/System.Runtime.Serialization.Json/DataContractJsonSerializerTest.cs
===================================================================
@@ -1467,6 +1467,25 @@ public void Bug13485 ()
 			result = entity.GetValue;
 			Assert.AreEqual ("ValueA", result, "#1");
 		}
+
+		[DataContract(Name = "UriTest")]
+		public class UriTest
+		{
+			[DataMember(Name = "members")]
+			public Uri MembersRelativeLink { get; set; }
+		}
+
+		[Test]
+		public void Bug15169 ()
+		{
+			const string json = "{\"members\":\"foo/bar/members\"}";
+			var serializer = new DataContractJsonSerializer (typeof (UriTest));
+			UriTest entity;
+			using (var stream = new MemoryStream (Encoding.UTF8.GetBytes (json)))
+				entity = (UriTest) serializer.ReadObject (stream);
+
+			Assert.AreEqual ("foo/bar/members", entity.MembersRelativeLink.ToString ());
+		}
 	}
 	
 	public class CharTest


_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.