[banshee] [Banshee.IO] Fix Uri to path conversion



commit eaecba9936189b810ec6360563a83ed0a9db3f6c
Author: Gabriel Burt <gabriel burt gmail com>
Date:   Fri Mar 19 14:02:22 2010 -0700

    [Banshee.IO] Fix Uri to path conversion
    
    We were just chopping off the file:// part, but we need to convert to a
    SafeUri object, and use its LocalPath property, to account for uri
    encoding.  Change the unit tests such that they'll fail if uri encoding
    isn't accounted for like this.  Fixes bgo#613292

 src/Core/Banshee.Core/Banshee.IO/Provider.cs |    2 +-
 src/Core/Banshee.Core/Banshee.IO/Tests.cs    |    3 ++-
 2 files changed, 3 insertions(+), 2 deletions(-)
---
diff --git a/src/Core/Banshee.Core/Banshee.IO/Provider.cs b/src/Core/Banshee.Core/Banshee.IO/Provider.cs
index 82191fd..16dac3c 100644
--- a/src/Core/Banshee.Core/Banshee.IO/Provider.cs
+++ b/src/Core/Banshee.Core/Banshee.IO/Provider.cs
@@ -112,7 +112,7 @@ namespace Banshee.IO
         internal static string GetPath (string uri)
         {
             if (LocalOnly && !String.IsNullOrEmpty (uri) && uri[0] != '/' && uri.StartsWith ("file://")) {
-                return uri.Substring (7, uri.Length - 7);
+                return new SafeUri (uri).LocalPath;
             }
 
             return uri;
diff --git a/src/Core/Banshee.Core/Banshee.IO/Tests.cs b/src/Core/Banshee.Core/Banshee.IO/Tests.cs
index abe183b..9e61779 100644
--- a/src/Core/Banshee.Core/Banshee.IO/Tests.cs
+++ b/src/Core/Banshee.Core/Banshee.IO/Tests.cs
@@ -46,7 +46,8 @@ namespace Banshee.IO
     [TestFixture]
     public class Tests : TestBase
     {
-        private string tmp_dir = System.IO.Path.Combine (System.Environment.CurrentDirectory, "tmp-io-test-dir");
+        // Purposefully putting a space in this directory name, helps test uri encoding issues
+        private string tmp_dir = System.IO.Path.Combine (System.Environment.CurrentDirectory, "tmp-io test-dir");
         private SafeUri foo, baz, zoo;
         private string woo, yoo;
 



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