Hi Andrew,

How about this patch? To save iterations, I made the same check in ResolveExternalEntityReplacementText, please tell me, if it's unnecessary.

This patch looks fine. Let's check it in svn.

I'll apply the patch attached after your commit.

Index: DTDReader.cs
===================================================================
--- DTDReader.cs        (revision 46238)
+++ DTDReader.cs        (working copy)
@@ -641,8 +641,9 @@
                private void ResolveExternalEntityReplacementText 
(DTDEntityBase decl)
                {
                        if (decl.LiteralEntityValue.StartsWith ("<?xml")) {
+                               // FIXME: not always it should be read in 
Element context - AS

What does this mean? I guess you have in mind that there are cases that
entities could be used inside attributes, but attribute content check
is less prohibiting and '<' characters are checked anyways.

(BTW we won't understand what "-AS" means there ;-)

Besides the comment itself.

In fact I also don't like that part of code. Actually, though
replacing entities with a simple string is good for performance
as compared to such code that loads entity possibly from external
files every time, it causes incorrect BaseURI resolution (that
results in incorrect not-wf error for XHTML 1.1 DTD; bug #51495).

So, basically rewriting that entity expansion part is the best
solution. But I haven't tried that since it will not be done as a
quick hack and it will first result in several breakage in
standalone tests.

Thanks,
Atsushi Eno
Index: Test/System.Xml/XmlTextReaderTests.cs
===================================================================
--- Test/System.Xml/XmlTextReaderTests.cs       (revision 46370)
+++ Test/System.Xml/XmlTextReaderTests.cs       (working copy)
@@ -1100,5 +1100,20 @@
                        AssertEquals ("#1", 0xf090, (int) r.Value [0]);
                        AssertEquals ("#1", 0x8080, (int) r.Value [1]);
                }
+
+               [Test]
+               [ExpectedException (typeof (XmlException))]
+               public void EntityDeclarationNotWF ()
+               {
+                       string xml = @"<!DOCTYPE doc [
+                               <!ELEMENT doc (#PCDATA)>
+                               <!ENTITY e ''>
+                               <!ENTITY e '<foo&>'>
+                               ]>
+                               <doc>&e;</doc> ";
+                       XmlTextReader xtr = new XmlTextReader (xml,
+                               XmlNodeType.Document, null);
+                       xtr.Read ();
+               }
        }
 }
_______________________________________________
Mono-devel-list mailing list
Mono-devel-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list

Reply via email to