[Mono-devel-list] Bug: XmlParserContext BaseURI is null

Atsushi Eno atsushi at ximian.com
Wed Dec 22 13:24:57 EST 2004


Hi,

Thanks for the report. Now I have a couple of fixes, but since
currently svn server is down (and not likely to be fixed soon),
I just attached a fix.

Will check them in svn when it got working again.

Atsushi Eno

Joshua Tauberer wrote:
> Atsushi,
> 
> After updating to the latest and greatest development RPMs of Mono I 
> found a bug in XmlParserContext.  BaseURI is returned as null sometimes, 
> which it should never be.  (If there's no URI, it should be the empty 
> string.)
> 
> This test produces the problem:
> 
> using System;
> using System.IO;
> using System.Xml;
> 
> public class Test {
>   public static void Main(string[] args) {
>     string baseuri = new XmlTextReader(
>       new StringReader("<xml/>")).BaseURI;
>     Console.WriteLine(baseuri == null ? "It's null."
>       : "It's not null.");
>   }
> }
> 
> I don't know where a fix would be appropriate.  There seem to be a few 
> issues.  1) XmlParserContext can be initialized with a null BaseURI 
> through its many constructors.  2)  When the XmlTextReader doesn't know 
> about a URI, it doesn't set parserContext.BaseURI, leaving it at null.
> 
> (Also, when XmlTextReader encounters an xml:base attribute (I didn't 
> even know those existed until now), and if an XmlResolver is set, the 
> reader does this:
>   parserContext.BaseURI = resolver.ResolveUri (new Uri (BaseURI), 
> value).ToString ();
> ResolveUri is allowed to return null, so this could throw a 
> NullReferenceException.)
> 
> Initializing the parser context with "" instead of null fixes the test 
> case.
> 
> Thanks for looking at this, as always.
> 

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: parsercontext-fixes.diff
Url: http://lists.ximian.com/pipermail/mono-devel-list/attachments/20041223/5759f31d/attachment.pl 


More information about the Mono-devel-list mailing list