http://bugs.gnome.org/show_bug.cgi?id=169678 Ok, I thought about it some more. Decided that fixing up the URI's before serialization would be most sensible. Dropped a function into UriFu, fixed the XML serialization routines to use it, job done. Not. Ran into further problems with the Lucene glue's Document <--> Uri handling. Ran into further problems with our binary serialization (for sending results to client) So while its not as clean as I had hoped it would be, this is the best solution I've come up with. Index: BeagleClient/Hit.cs =================================================================== RCS file: /cvs/gnome/beagle/BeagleClient/Hit.cs,v retrieving revision 1.15 diff -u -B -p -r1.15 Hit.cs --- BeagleClient/Hit.cs 23 Feb 2005 05:01:29 -0000 1.15 +++ BeagleClient/Hit.cs 9 Mar 2005 16:42:20 -0000 @@ -87,7 +87,7 @@ namespace Beagle { { writer.Write (BU.StringFu.DateTimeToString (Timestamp)); writer.Write (id); - writer.Write (uri.ToString ()); + writer.Write (BU.UriFu.UriToSerializableString (uri)); writer.Write (type); writer.Write (mimeType == null ? "" : mimeType); writer.Write (source); Index: BeagleClient/Indexable.cs =================================================================== RCS file: /cvs/gnome/beagle/BeagleClient/Indexable.cs,v retrieving revision 1.21 diff -u -B -p -r1.21 Indexable.cs --- BeagleClient/Indexable.cs 23 Feb 2005 05:01:29 -0000 1.21 +++ BeagleClient/Indexable.cs 9 Mar 2005 16:42:20 -0000 @@ -110,7 +110,7 @@ namespace Beagle { [XmlAttribute ("Uri")] public string UriString { - get { return uri.ToString (); } + get { return UriFu.UriToSerializableString (uri); } set { uri = UriFu.UriStringToUri (value); } } @@ -122,7 +122,7 @@ namespace Beagle { [XmlAttribute ("ContentUri")] public string ContentUriString { - get { return ContentUri.ToString (); } + get { return UriFu.UriToSerializableString (ContentUri); } set { contentUri = UriFu.UriStringToUri (value); } } @@ -134,7 +134,7 @@ namespace Beagle { [XmlAttribute ("HotContentUri")] public string HotContentUriString { - get { return HotContentUri != null ? HotContentUri.ToString () : ""; } + get { return HotContentUri != null ? UriFu.UriToSerializableString (HotContentUri) : ""; } set { hotContentUri = (value != "") ? new Uri (value) : null; } } Index: Util/UriFu.cs =================================================================== RCS file: /cvs/gnome/beagle/Util/UriFu.cs,v retrieving revision 1.5 diff -u -B -p -r1.5 UriFu.cs --- Util/UriFu.cs 23 Feb 2005 07:26:46 -0000 1.5 +++ Util/UriFu.cs 9 Mar 2005 16:42:20 -0000 @@ -56,6 +56,21 @@ namespace Beagle.Util { return new Uri (path, true); } + static public String UriToSerializableString (Uri uri) + { + // The ToString() of a file:// URI is not always representative of + // what it was constructed from. For example, it will return a + // # (which was inputted as %23) as %23, whereas the more standard + // behaviour for other escaped-characters is to return them as + // their actual character. (e.g. %40 gets returned as @) + // On the other hand, the LocalPath of a file:// URI does seem to + // return the literal # so we use that instead. + if (uri.IsFile) + return Uri.UriSchemeFile + Uri.SchemeDelimiter + uri.LocalPath; + else + return uri.ToString (); + } + ////////////////////////////////// public class Comparer : IComparer Index: beagled/LuceneDriver.cs =================================================================== RCS file: /cvs/gnome/beagle/beagled/LuceneDriver.cs,v retrieving revision 1.64 diff -u -B -p -r1.64 LuceneDriver.cs --- beagled/LuceneDriver.cs 27 Feb 2005 22:53:30 -0000 1.64 +++ beagled/LuceneDriver.cs 9 Mar 2005 16:42:20 -0000 @@ -594,7 +593,7 @@ namespace Beagle.Daemon { // First we add the Indexable's 'canonical' properties // to the Document. - f = Field.Keyword ("Uri", indexable.Uri.ToString ()); + f = Field.Keyword ("Uri", UriFu.UriToSerializableString (indexable.Uri)); doc.Add (f); f = Field.Keyword ("Type", indexable.Type);