banshee r5066 - in branches/banshee/stable: . src/Core/Banshee.Core/Banshee.Base src/Libraries/Hyena/Hyena src/Libraries/Migo/Migo.DownloadCore src/Libraries/Migo/Migo.Syndication



Author: gburt
Date: Wed Feb 25 19:13:36 2009
New Revision: 5066
URL: http://svn.gnome.org/viewvc/banshee?rev=5066&view=rev

Log:
2009-02-10  Gabriel Burt  <gabriel burt gmail com>

	Patch from John Millikin fixing issue with downloading some podcasts.

	* Core/Banshee.Core/Banshee.Base/FileNamePattern.cs:
	* Libraries/Hyena/Hyena/StringUtil.cs: Move Escape method to Hyena so
	reusable in Migo, and mark the Regex it uses as Compiled.

	* Libraries/Migo/Migo.DownloadCore/DownloadManager.cs:
	* Libraries/Migo/Migo.Syndication/Feed.cs: Use Hyena's new EscapeFilename
	method to fix bug with downloading podcasts with special characters in
	their title (BGO #567293).



Modified:
   branches/banshee/stable/   (props changed)
   branches/banshee/stable/ChangeLog
   branches/banshee/stable/src/Core/Banshee.Core/Banshee.Base/FileNamePattern.cs
   branches/banshee/stable/src/Libraries/Hyena/Hyena/StringUtil.cs
   branches/banshee/stable/src/Libraries/Migo/Migo.DownloadCore/DownloadManager.cs
   branches/banshee/stable/src/Libraries/Migo/Migo.Syndication/Feed.cs

Modified: branches/banshee/stable/src/Core/Banshee.Core/Banshee.Base/FileNamePattern.cs
==============================================================================
--- branches/banshee/stable/src/Core/Banshee.Core/Banshee.Base/FileNamePattern.cs	(original)
+++ branches/banshee/stable/src/Core/Banshee.Core/Banshee.Base/FileNamePattern.cs	Wed Feb 25 19:13:36 2009
@@ -42,9 +42,6 @@
         public delegate string ExpandTokenHandler (ITrackInfo track, object replace);
         public delegate string FilterHandler (string path);
         
-        private static string invalid_path_characters = "\"\\:'~`! #$%^&*_-+|?/><[]";
-        private static Regex invalid_path_regex;
-        
         public static FilterHandler Filter;
         
         public struct Conversion
@@ -263,17 +260,7 @@
 
         public static string Escape (string input)
         {
-            if (invalid_path_regex == null) {
-                string regex_str = "[";
-                for (int i = 0; i < invalid_path_characters.Length; i++) {
-                    regex_str += "\\" + invalid_path_characters[i];
-                }
-                regex_str += "]+";
-                
-                invalid_path_regex = new Regex (regex_str);
-            }
-            
-            return invalid_path_regex.Replace (input, String.Empty);
+            return Hyena.StringUtil.EscapeFilename (input);
         }
     }
 }

Modified: branches/banshee/stable/src/Libraries/Hyena/Hyena/StringUtil.cs
==============================================================================
--- branches/banshee/stable/src/Libraries/Hyena/Hyena/StringUtil.cs	(original)
+++ branches/banshee/stable/src/Libraries/Hyena/Hyena/StringUtil.cs	Wed Feb 25 19:13:36 2009
@@ -159,5 +159,23 @@
             else
                 return (int)num + 1;
         }
+        
+        private static string invalid_path_characters = "\"\\:'~`! #$%^&*_-+|?/><[]";
+        private static Regex invalid_path_regex;
+        
+        public static string EscapeFilename (string input)
+        {
+            if (invalid_path_regex == null) {
+                string regex_str = "[";
+                for (int i = 0; i < invalid_path_characters.Length; i++) {
+                    regex_str += "\\" + invalid_path_characters[i];
+                }
+                regex_str += "]+";
+                
+                invalid_path_regex = new Regex (regex_str, RegexOptions.Compiled);
+            }
+            
+            return invalid_path_regex.Replace (input, String.Empty);
+        }
     }
 }

Modified: branches/banshee/stable/src/Libraries/Migo/Migo.DownloadCore/DownloadManager.cs
==============================================================================
--- branches/banshee/stable/src/Libraries/Migo/Migo.DownloadCore/DownloadManager.cs	(original)
+++ branches/banshee/stable/src/Libraries/Migo/Migo.DownloadCore/DownloadManager.cs	Wed Feb 25 19:13:36 2009
@@ -126,7 +126,7 @@
             }
             
             string[] segments = uri.Segments;        
-            string fileName = segments[segments.Length-1].Trim ('/');
+            string fileName = System.Web.HttpUtility.UrlDecode (segments[segments.Length-1].Trim ('/'));
             
             MD5 hasher = MD5.Create ();
             
@@ -139,7 +139,7 @@
                                          .ToLower ();
             
             string remoteUri = url;
-            string localPath = tmpDir + urlHash + Path.DirectorySeparatorChar + System.Web.HttpUtility.UrlDecode (fileName);
+            string localPath = tmpDir + urlHash + Path.DirectorySeparatorChar + Hyena.StringUtil.EscapeFilename (fileName);
 
             HttpFileDownloadTask task = null;
             string [] parts = fileName.Split ('.');

Modified: branches/banshee/stable/src/Libraries/Migo/Migo.Syndication/Feed.cs
==============================================================================
--- branches/banshee/stable/src/Libraries/Migo/Migo.Syndication/Feed.cs	(original)
+++ branches/banshee/stable/src/Libraries/Migo/Migo.Syndication/Feed.cs	Wed Feb 25 19:13:36 2009
@@ -218,7 +218,10 @@
         
         //[DatabaseColumn]
         public string LocalEnclosurePath {
-            get { return Path.Combine (FeedsManager.Instance.PodcastStorageDirectory, Title); }
+            get {
+                string escaped = Hyena.StringUtil.EscapeFilename (Title);
+                return Path.Combine (FeedsManager.Instance.PodcastStorageDirectory, escaped);
+            }
             //set { local_enclosure_path = value; }
         }
 



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