2010-04-28 Atsushi Enomoto <atsushi@ximian.com>
authorAtsushi Eno <atsushieno@gmail.com>
Wed, 28 Apr 2010 01:22:00 +0000 (01:22 -0000)
committerAtsushi Eno <atsushieno@gmail.com>
Wed, 28 Apr 2010 01:22:00 +0000 (01:22 -0000)
* XmlDocument.cs : it seems .net does allow Load() with such an xml
  reader positioned in the middle of the document. Fixed bug #598953.

* XmlDocumentTests.cs : add test for bug #598953.

svn path=/trunk/mcs/; revision=156278

mcs/class/System.XML/System.Xml/ChangeLog
mcs/class/System.XML/System.Xml/XmlDocument.cs
mcs/class/System.XML/Test/System.Xml/ChangeLog
mcs/class/System.XML/Test/System.Xml/XmlDocumentTests.cs

index 04d45073ed08980ef8be0031d48e2e1c6cb0727a..a28f921c02bd97ec32ef2d2088a4bf31834d13a4 100644 (file)
@@ -1,3 +1,8 @@
+2010-04-28  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * XmlDocument.cs : it seems .net does allow Load() with such an xml
+         reader positioned in the middle of the document. Fixed bug #598953.
+
 2010-04-21  Atsushi Enomoto  <atsushi@ximian.com>
 
        * XmlTextReader.cs, DTDReader.cs : 0xFFFF was treated as if it were
index 9469b3259da6df964b35a19c2c1f17a237bf9ec4..ea543440a232caf92c90be03c1062f7585742f64 100644 (file)
@@ -734,7 +734,7 @@ namespace System.Xml
                                                break;
                                        if (preserveWhitespace || n.NodeType != XmlNodeType.Whitespace)
                                                AppendChild (n, false);
-                               } while (true);
+                               } while (xmlReader.NodeType != XmlNodeType.EndElement);
 #if NET_2_0
                                if (xmlReader.Settings != null)
                                        schemas = xmlReader.Settings.Schemas;
index 6582a26e1e85d59e718539960fb32169387e91c3..d9290cb3f92b0ae37173584e1653cdb9630c0f31 100644 (file)
@@ -1,3 +1,7 @@
+2010-04-28  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * XmlDocumentTests.cs : add test for bug #598953.
+
 2010-03-26  Atsushi Enomoto  <atsushi@ximian.com>
 
        * XmlReaderCommonTests.cs : added test for ReadElementContentAs() for
index 65b0b104ecf3f55f8eea65647eeb749704120faa..6b30f0889c8bfdbdbf623ed07773893dc0a30b71 100644 (file)
@@ -1198,5 +1198,24 @@ namespace MonoTests.System.Xml
                        Assert.IsNotNull (doc.DocumentElement.GetAttributeNode ("hijacked"));
                        Assert.IsNull (doc.DocumentElement.GetAttributeNode ("a"));
                }
+
+               [Test]
+               public void LoadFromMiddleOfDocument ()
+               {
+                       // bug #598953
+                       string xml = @"<?xml version='1.0' encoding='utf-8' ?>
+<Racal>
+  <Ports>
+    <ConsolePort value='9998' />
+  </Ports>
+</Racal>";
+                       var r = new XmlTextReader (new StringReader (xml));
+                       r.WhitespaceHandling = WhitespaceHandling.All;
+                       r.MoveToContent ();
+                       r.Read ();
+                       var doc = new XmlDocument ();
+                       doc.Load (r);
+                       Assert.AreEqual (XmlNodeType.EndElement, r.NodeType, "#1");
+               }
        }
 }