2005-05-31 Atsushi Enomoto <atsushi@ximian.com>
authorAtsushi Eno <atsushieno@gmail.com>
Tue, 31 May 2005 11:41:54 +0000 (11:41 -0000)
committerAtsushi Eno <atsushieno@gmail.com>
Tue, 31 May 2005 11:41:54 +0000 (11:41 -0000)
* DTDValidatingReader.cs : Last BaseURI exposed this hidden bug via
  sys.security tests.

* XmlValidatingReaderTests.cs : added ResolveEntityAndBaseURI() which
  is imported from sys.security.

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

mcs/class/System.XML/System.Xml/ChangeLog
mcs/class/System.XML/System.Xml/DTDValidatingReader.cs
mcs/class/System.XML/Test/System.Xml/ChangeLog
mcs/class/System.XML/Test/System.Xml/XmlValidatingReaderTests.cs

index c4805ea1d9eef60e70e236135a0a44b63aaf954b..5cb5d7a22b498aa0da57e4539333d45cdb991103 100644 (file)
@@ -1,3 +1,8 @@
+2005-05-31  Atsushi Enomoto <atsushi@ximian.com>
+
+       * DTDValidatingReader.cs : Last BaseURI exposed this hidden bug via
+         sys.security tests.
+
 2005-05-30  Atsushi Enomoto <atsushi@ximian.com>
 
        * DTDObjectModel.cs : in DTDEntityBase.Resolve() don't overwrite
index 285dd616af31a120a41b614f04e4e2b963c99b86..167ecdfeca8b971b161b52ac0bcfeb04da7d77cd 100644 (file)
@@ -950,7 +950,7 @@ namespace Mono.Xml
 
                        // MS.NET 1.x ignores undeclared entity reference here..
                        if (entity != null && entity.SystemId != null) {
-                               Uri baseUri = entity.BaseURI == null ? null : new Uri (entity.BaseURI);
+                               Uri baseUri = entity.BaseURI == String.Empty ? null : new Uri (entity.BaseURI);
                                Stream stream = resolver.GetEntity (resolver.ResolveUri (baseUri, entity.SystemId), null, typeof (Stream)) as Stream;
                                nextEntityReader = new XmlTextReader (stream, xmlReaderNodeType, ParserContext);
                        } else {
index 6cbe24cf02ef7fe3f1b56062aba12df3e2164881..e1109202a96decbddc27a90c27a9c10c1ae2ae83 100644 (file)
@@ -1,3 +1,8 @@
+2005-05-31  Atsushi Enomoto <atsushi@ximian.com>
+
+       * XmlValidatingReaderTests.cs : added ResolveEntityAndBaseURI() which
+         is imported from sys.security.
+
 2005-05-25  Andrew Skiba  <andrews@mainsoft.com>
 
        * W3C : directory added
index 9caa9f7d7d7db1841f305962321828f4a90c21ba..438922495a163e2bfa64c548f460429cc215e016 100644 (file)
@@ -7,6 +7,7 @@
 // (C)2003 Atsushi Enomoto\r
 //\r
 using System;\r
+using System.IO;\r
 using System.Xml;\r
 using System.Xml.Schema;\r
 using NUnit.Framework;\r
@@ -814,5 +815,42 @@ namespace MonoTests.System.Xml
                        r.Read ();\r
                        AssertEquals (refOut, r.ReadOuterXml ());\r
                }\r
+\r
+               [Test]\r
+               // imported testcase from sys.security which had regression.\r
+               public void ResolveEntityAndBaseURI ()\r
+               {\r
+                       try {\r
+                               using (TextWriter w = File.CreateText ("world.txt")) {\r
+                                       w.WriteLine ("world");\r
+                               }\r
+\r
+                               string xml =  "<!DOCTYPE doc [\n" +\r
+                                       "<!ATTLIST doc attrExtEnt ENTITY #IMPLIED>\n" +\r
+                                       "<!ENTITY ent1 \"Hello\">\n" +\r
+                                       "<!ENTITY ent2 SYSTEM \"world.txt\">\n" +\r
+                                       "<!ENTITY entExt SYSTEM \"earth.gif\" NDATA gif>\n" +\r
+                                       "<!NOTATION gif SYSTEM \"viewgif.exe\">\n" +\r
+                                       "]>\n" +\r
+                                       "<doc attrExtEnt=\"entExt\">\n" +\r
+                                       "   &ent1;, &ent2;!\n" +\r
+                                       "</doc>\n" +\r
+                                       "\n" +\r
+                                       "<!-- Let world.txt contain \"world\" (excluding the quotes) -->\n";\r
+\r
+                               XmlValidatingReader xvr =\r
+                                       new XmlValidatingReader (\r
+                                       xml, XmlNodeType.Document, null);\r
+                               xvr.ValidationType = ValidationType.None;\r
+                               xvr.EntityHandling =\r
+                                       EntityHandling.ExpandCharEntities;\r
+                               XmlDocument doc = new XmlDocument ();\r
+                               doc.Load (xvr);\r
+\r
+                       } finally {\r
+                               if (File.Exists ("world.txt"))\r
+                                       File.Delete ("world.txt");\r
+                       }\r
+               }\r
        }\r
 }\r