[Mono-bugs] [Bug 74704][Wis] New - XmlTextReader: handling of xml:base causes exception
bugzilla-daemon@bugzilla.ximian.com
bugzilla-daemon@bugzilla.ximian.com
Sat, 23 Apr 2005 15:56:44 -0400 (EDT)
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 heath@pointedstick.net.
http://bugzilla.ximian.com/show_bug.cgi?id=74704
--- shadow/74704 2005-04-23 15:56:44.000000000 -0400
+++ shadow/74704.tmp.11705 2005-04-23 15:56:44.000000000 -0400
@@ -0,0 +1,81 @@
+Bug#: 74704
+Product: Mono: Class Libraries
+Version: 1.0
+OS:
+OS Details: Fedora Core 3 x86
+Status: NEW
+Resolution:
+Severity:
+Priority: Wishlist
+Component: Sys.XML
+AssignedTo: mono-bugs@ximian.com
+ReportedBy: heath@pointedstick.net
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL:
+Cc:
+Summary: XmlTextReader: handling of xml:base causes exception
+
+Please fill in this template when reporting a bug, unless you know what you
+are doing.
+Description of Problem:
+In the ReadStartTag() method, XmlTextReader tries to use the BaseURI
+variable to construct a URI without checking if it's empty. This can cause
+a UriFormatException.
+
+Apparently, this was noticed and changed in Mono 1.1, because XmlTextReader
+in Mono 1.1 checks for this condition.
+
+Code from Mono 1.0.6 (XmlTextReader.cs, line 1333):
+
+string baseUri = GetAttribute ("xml:base");
+if (baseUri != null) {
+ parsercontext.BaseURI =
+ resolver.ResolveUri (new Uri(BaseURI), value).ToString();
+else
+ parsercontext.BaseURI = baseUri;
+
+The problem comes in using the Uri constructor when BaseURI == String.Empty.
+
+The equivalent code in Mono 1.1.6 (XmlTextReader.cs, line 1323):
+
+case "base":
+ if (this.resolver != null) {
+ Uri buri = BaseURI != String.Empty ?
+ new Uri (BaseURI) : null;
+ Uri uri = resolver.ResolveUri (buri, value);
+ parsercontext.BaseURI =
+ uri != null ?
+ uri.ToString () :
+ String.Empty;
+ }
+ else
+ parsercontext.BaseURI = value;
+
+
+
+Steps to reproduce the problem:
+1. Read an XML file containing xml:base attributes (in my case, an
+ Atom feed) with an XmlTextReader.
+2. Watch XmlTextReader.ReadStartTag() throw UriFormatException.
+
+
+Actual Results:
+UriFormatException.
+
+Expected Results:
+No UriFormatException, same as Mono 1.1.
+
+How often does this happen?
+Always, in my experience, but from the look of the code it's possible that
+it wouldn't happen under other circumstances.
+
+Additional Information:
+I discovered this by writing a patch for Imendio Blam! that adds Atom feed
+support using Atom.NET (atomnet.sourceforge.net). The constructor for the
+AtomReader class is throwing this exception, but only on Mono 1.0.X. The
+AtomReader constructor creates an XPathDocument from a stream, which
+creates an XmlTextReader, which reads through the feed and throws the
+UriFormatException. Again, this does not happen on Mono 1.1.
+
+I have a short patch that fixes the problem, attached shortly.