[Mono-bugs] [Bug 55570][Nor] New - XmlTextReader.ReadOuterXml craches where it shouldn't

bugzilla-daemon@bugzilla.ximian.com bugzilla-daemon@bugzilla.ximian.com
Sun, 14 Mar 2004 13:40:40 -0500 (EST)


Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.

Changed by jeanmarc.andre@cpe.fr.

http://bugzilla.ximian.com/show_bug.cgi?id=55570

--- shadow/55570	2004-03-14 13:40:40.000000000 -0500
+++ shadow/55570.tmp.12559	2004-03-14 13:40:40.000000000 -0500
@@ -0,0 +1,95 @@
+Bug#: 55570
+Product: Mono: Class Libraries
+Version: unspecified
+OS: All
+OS Details: 
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Normal
+Component: Sys.XML
+AssignedTo: mono-bugs@ximian.com                            
+ReportedBy: jeanmarc.andre@cpe.fr               
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: XmlTextReader.ReadOuterXml craches where it shouldn't
+
+Please fill in this template when reporting a bug, unless you know what you
+are doing.
+Description of Problem:
+
+The Mono XmlTextReader.ReadOuterXml() send an exception where the MS one
+doesn't.
+
+
+Steps to reproduce the problem:
+Build and run the following...
+
+using System;
+using System.Xml;
+
+namespace ReadOuterXml
+{
+	class ReadOuterXml
+	{
+		/// <summary>
+		/// Point d'entrée principal de l'application.
+		/// </summary>
+		[STAThread]
+		static void Main(string[] args)
+		{
+			
+			XmlTextReader reader = new XmlTextReader("books.xml");
+			reader.WhitespaceHandling = WhitespaceHandling.None;
+
+			//Move the reader to the first book element.
+			reader.MoveToContent();
+			Console.WriteLine("after MoveToContent() reader.Name: " + reader.Name);
+			reader.Read();
+			reader.Read();
+			Console.WriteLine("after Read() :reader.Name: " + reader.Name);
+
+			string xmlElement;
+
+			while((xmlElement = reader.ReadOuterXml()) != String.Empty)
+				Console.WriteLine(xmlElement);
+		}
+	}
+}
+
+
+
+Actual Results:
+<title>The Autobiography of Benjamin Franklin</title>
+<author><first-name>Benjamin</first-name><last-name>Franklin</last-name></author>
+<price>8.99</price>
+
+Unhandled Exception: System.InvalidOperationException: There was no XML
+start tag open.
+in <0x0004c> System.Xml.XmlTextWriter:WriteEndElementInternal (bool)
+in <0x00013> System.Xml.XmlTextWriter:WriteFullEndElement ()
+in <0x003d1> System.Xml.XmlWriter:WriteNode (System.Xml.XmlReader,bool)
+in <0x0008c> System.Xml.XmlReader:ReadOuterXmlInternal ()
+in <0x00011> System.Xml.XmlReader:ReadOuterXml ()
+in <0x0010a> ReadOuterXml.ReadOuterXml:Main (string[])
+
+
+Expected Results:
+<title>The Autobiography of Benjamin Franklin</title>
+<author><first-name>Benjamin</first-name><last-name>Franklin</last-name></author>
+<price>8.99</price>
+
+
+How often does this happen? 
+Always
+
+Additional Information:
+
+I'll join the source and the xml files.
+I think the bug could be fixed adding something like the following to
+XmlReader.cs line 348:
+
+if (ReadState != ReadState.Interactive || NodeType == XmlNodeType.EndElement)
+	return String.Empty;