Explorar o código

2006-12-12 Atsushi Enomoto <[email protected]>

	* XmlNode.cs : InnerText was returning comment text when there was
	  only a Comment node. Fixed bug #80233.

	* XmlNodeTests.cs : added test for bug #80233.


svn path=/trunk/mcs/; revision=69392
Atsushi Eno %!s(int64=19) %!d(string=hai) anos
pai
achega
efcfec2517

+ 5 - 0
mcs/class/System.XML/System.Xml/ChangeLog

@@ -1,3 +1,8 @@
+2006-12-12  Atsushi Enomoto <[email protected]>
+
+	* XmlNode.cs : InnerText was returning comment text when there was
+	  only a Comment node. Fixed bug #80233.
+
 2006-12-12  Atsushi Enomoto <[email protected]>
 
 	* XmlReader.cs : Create() with string url was not returning validating

+ 3 - 1
mcs/class/System.XML/System.Xml/XmlNode.cs

@@ -140,7 +140,9 @@ namespace System.Xml
 				if (FirstChild == null)
 					return String.Empty;
 				if (FirstChild == LastChild)
-					return FirstChild.InnerText;
+					return FirstChild.NodeType != XmlNodeType.Comment ?
+						FirstChild.InnerText :
+						String.Empty;
 
 				StringBuilder builder = null;
 				AppendChildValues (ref builder);

+ 4 - 0
mcs/class/System.XML/Test/System.Xml/ChangeLog

@@ -1,3 +1,7 @@
+2006-12-12  Atsushi Enomoto <[email protected]>
+
+	* XmlNodeTests.cs : added test for bug #80233.
+
 2006-12-12  Atsushi Enomoto <[email protected]>
 
 	* XmlValidatingReaderTests.cs : #if NET_2_0 was missing.

+ 8 - 0
mcs/class/System.XML/Test/System.Xml/XmlNodeTests.cs

@@ -485,5 +485,13 @@ namespace MonoTests.System.Xml
 			Assert ("#1", n.IsReadOnly);
 			Assert ("#2", !n.CloneNode (true).IsReadOnly);
 		}
+
+		[Test] // bug #80233
+		public void InnerTextComment ()
+		{
+			XmlDocument doc = new XmlDocument ();
+			doc.LoadXml ("<a><!--xx--></a>");
+			AssertEquals (String.Empty, doc.InnerText);
+		}
 	}
 }