Browse Source

2009-03-16 Atsushi Enomoto <[email protected]>

	* DTDRreader.cs : read up all DTD stream so that we don't have to
	  see bugs like #469317 many times.


svn path=/trunk/mcs/; revision=129465
Atsushi Eno 17 years ago
parent
commit
fea31fd77d

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

@@ -1,3 +1,8 @@
+2009-03-16  Atsushi Enomoto  <[email protected]>
+
+	* DTDRreader.cs : read up all DTD stream so that we don't have to
+	  see bugs like #469317 many times.
+
 2009-03-16  Atsushi Enomoto  <[email protected]>
 
 	* XmlReaderBinarySupport.cs : ReadContentsAsBase64() could skip

+ 10 - 1
mcs/class/System.XML/System.Xml/DTDReader.cs

@@ -1632,9 +1632,18 @@ namespace System.Xml
 			}
 			parserInputStack.Push (currentInput);
 			Stream s = null;
+			MemoryStream ms = new MemoryStream ();
 			try {
 				s = DTD.Resolver.GetEntity (absUri, null, typeof (Stream)) as Stream;
-				currentInput = new XmlParserInput (new XmlStreamReader (s), absPath);
+				int size;
+				byte [] buf = new byte [4096];
+				do {
+					size = s.Read (buf, 0, buf.Length);
+					ms.Write (buf, 0, size);
+				} while (size > 0);
+				s.Close ();
+				ms.Position = 0;
+				currentInput = new XmlParserInput (new XmlStreamReader (ms), absPath);
 			} catch (Exception ex) { // FIXME: (wishlist) Bad exception catch ;-(
 				if (s != null)
 					s.Close ();