Bugs in Package.LoadRelationships and PackageUriHelper.ResolvePartUri

10 views
Skip to first unread message

Yves

unread,
Mar 12, 2009, 4:12:59 PM3/12/09
to Mono Olive - developing.NET 3.0, 3.5 and later versions
Hello,

I have no experience with bug reporting for Mono and I couldn't find a
suitable section on bugzilla, so I'm going to add it here. If someone
can add it to the correct place on the bugtracker (or tell me where to
do it) that would be nice.

BUG 1: Package.LoadRelationships
=====
Sample program with bug (tested on MacOSX with the latest version of
olive from subversion).

========= Start of program =========

using System;
using System.IO;
using System.IO.Packaging;

namespace MonoOpenXmlExperiment
{
class Program
{
static void Main(string[] args)
{
if (args.Length != 1)
{
Console.WriteLine("Usage: MonoOpenXmlExperiment <docx file>");
Environment.Exit(1);
}
Package package = Package.Open(args[0], FileMode.Open,
FileAccess.Read);
PackageRelationshipCollection coll = package.GetRelationships();
foreach (PackageRelationship rel in coll)
{
Console.WriteLine("RelationshipType: {0}\nTargetUri: {1}\n",
rel.RelationshipType, rel.TargetUri);
}
package.Close();
}
}
}

========= End of program =========

The error is caused by a nullreference exception in
System.IO.Packaging.LoadRelationships(). The error is caused in the
line:

PackagePart part = GetPart(r.TargetUri);

and is caused by the fact that the Uri is not the correct one. It
misses a leading "/".

Possible fix:
Change the above codeline into:

Uri partUri = new Uri("/" + r.TargetUri, UriKind.Relative);
PackagePart part = GetPart(partUri);


Bug 2: PackageUriHelper.ResolvePartUri
====
Different behaviour in .Net 3.5 from Mono - olive

In .Net 3.5 the following code works:

Uri target = new Uri("docProps/app.xml", UriKind.Relative);
Uri src = new Uri("/", UriKind.Relative);
Uri result = PackUriHelper.ResolvePartUri(src, target);

In Olive a System.UriFormatException is thrown because the target uri
does not start with a "/".

Note that behaviour of Mono is correct while the one of .Net is not.


Yves
Reply all
Reply to author
Forward
0 new messages