[banshee] Gio: Fix encoding of URIs in Directory class



commit 92fdfa224fd2aac937535e63abd9475b0e79d377
Author: James Otting <xepher xepher net>
Date:   Tue Nov 8 18:24:04 2011 +0000

    Gio: Fix encoding of URIs in Directory class
    
    The Gio IO backend was buggy, since we started to import filenames with
    some special characters like ',' and '&' escaped.
    
    So this would lead to URIs like this:
    
    file:///path/You've%20Come%20a%20Long%20Way,%20Baby/Right%20Here%2C%20Right%20Now.mp3
    
    Which is inconsistent because:
    - Commas are encoded in the file name while the normal IO banshee
    backend never did this.
    - Commas are encoded in the file name but not in the directory name.
    
    In fact, SafeUri's default behaviour when asked for the AbsoluteUri
    property is encoding some characters, but not so many as
    System.Uri.EscapeDataString() method appears to do.
    
    So with this fix in place, the URI will be now:
    
    file:///path/You've%20Come%20a%20Long%20Way,%20Baby/Right%20Here,%20Right%20Now.mp3
    
    This failure to encode URIs consistently in the database was causing
    user-facing issues like bgo#631970 and bgo#661100, which will be
    completely fixed after the next commit, that fixes the existing URIs in
    the database.
    
    Signed-off-by: Bertrand Lorentz <bertrand lorentz gmail com>

 .../Banshee.Gio/Banshee.IO.Gio/Directory.cs        |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
---
diff --git a/src/Backends/Banshee.Gio/Banshee.IO.Gio/Directory.cs b/src/Backends/Banshee.Gio/Banshee.IO.Gio/Directory.cs
index 1da1a72..76563f7 100644
--- a/src/Backends/Banshee.Gio/Banshee.IO.Gio/Directory.cs
+++ b/src/Backends/Banshee.Gio/Banshee.IO.Gio/Directory.cs
@@ -118,7 +118,7 @@ namespace Banshee.IO.Gio
             var enumerator = dir.EnumerateChildren ("standard::type,standard::name", followSymlinks ? FileQueryInfoFlags.None : FileQueryInfoFlags.NofollowSymlinks, null);
             foreach (FileInfo file in enumerator) {
                 if ((file.FileType & FileType.Regular) != 0) {
-                    var ret = dir.Uri.AbsoluteUri + "/" + Uri.EscapeDataString (file.Name);
+                    var ret = SafeUri.FilenameToUri (System.IO.Path.Combine (dir.Path, file.Name));
                     file.Dispose ();
                     yield return ret;
                 } else {
@@ -141,7 +141,7 @@ namespace Banshee.IO.Gio
             var enumerator = dir.EnumerateChildren ("standard::type,standard::name", followSymlinks ? FileQueryInfoFlags.None : FileQueryInfoFlags.NofollowSymlinks, null);
             foreach (FileInfo file in enumerator) {
                 if ((file.FileType & FileType.Directory) != 0) {
-                    var ret = dir.Uri.AbsoluteUri + "/" + Uri.EscapeDataString (file.Name);
+                    var ret = SafeUri.FilenameToUri (System.IO.Path.Combine (dir.Path, file.Name));
                     file.Dispose ();
                     yield return ret;
                 } else {



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]