rhythmbox r5902 - in trunk: . plugins/generic-player sources



Author: jmatthew
Date: Wed Sep 10 13:33:48 2008
New Revision: 5902
URL: http://svn.gnome.org/viewvc/rhythmbox?rev=5902&view=rev

Log:
2008-09-10  Jonathan Matthew  <jonathan d14n org>

	* plugins/generic-player/rb-generic-player-source.c:
	(sanitize_path):
	* sources/rb-library-source.c: (sanitize_path), (impl_paste):
	Our sanitize_path function(s) are used for building URIs, not paths,
	so we need to use g_uri_escape_string rather than
	g_filename_from_utf8; also make library destination URIs safe for the
	target filesystem.  Fixes #550117.


Modified:
   trunk/ChangeLog
   trunk/plugins/generic-player/rb-generic-player-source.c
   trunk/sources/rb-library-source.c

Modified: trunk/plugins/generic-player/rb-generic-player-source.c
==============================================================================
--- trunk/plugins/generic-player/rb-generic-player-source.c	(original)
+++ trunk/plugins/generic-player/rb-generic-player-source.c	Wed Sep 10 13:33:48 2008
@@ -1107,7 +1107,6 @@
 	return (priv->read_only == FALSE);
 }
 
-/* probably should move this somewhere common */
 static char *
 sanitize_path (const char *str)
 {
@@ -1119,20 +1118,10 @@
 		str++;
 
 	s = g_strdup (str);
-	/* Replace path seperators with a hyphen */
 	g_strdelimit (s, "/", '-');
-
-	/* Replace separators with a hyphen */
-	g_strdelimit (s, "\\:|", '-');
-	/* Replace all other weird characters to whitespace */
-	g_strdelimit (s, "*?&!\'\"$()`>{}", ' ');
-	/* Replace all whitespace with underscores */
-	/* TODO: I'd like this to compress whitespace aswell */
-	g_strdelimit (s, "\t ", '_');
-
-	res = g_filename_from_utf8 (s, -1, NULL, NULL, NULL);
+	res = g_uri_escape_string (s, G_URI_RESERVED_CHARS_ALLOWED_IN_PATH_ELEMENT, TRUE);
 	g_free (s);
-	return res ? res : g_strdup (str);
+	return res;
 }
 
 static GList *

Modified: trunk/sources/rb-library-source.c
==============================================================================
--- trunk/sources/rb-library-source.c	(original)
+++ trunk/sources/rb-library-source.c	Wed Sep 10 13:33:48 2008
@@ -766,9 +766,10 @@
 /**
  * Perform magic on a path to make it safe.
  *
- * This will always replace '/' with ' ', and optionally make the file name
- * shell-friendly. This involves removing [?*\ ] and replacing with '_'.  Also
- * any leading periods are removed so that the files don't end up being hidden.
+ * This will always replace '/' with '-', and optionally make the file name
+ * shell-friendly. This involves removing replacing shell metacharacters and all
+ * whitespace with '_'. Also any leading periods are removed so that the files
+ * don't end up being hidden.
  */
 static char *
 sanitize_path (const char *str)
@@ -792,9 +793,10 @@
 		/* TODO: I'd like this to compress whitespace aswell */
 		g_strdelimit (s, "\t ", '_');
 	}
-	res = g_filename_from_utf8(s, -1, NULL, NULL, NULL);
-	g_free(s);
-	return res ? res : g_strdup(str);
+
+	res = g_uri_escape_string (s, G_URI_RESERVED_CHARS_ALLOWED_IN_PATH_ELEMENT, TRUE);
+	g_free (s);
+	return res;
 }
 
 static char *
@@ -812,8 +814,7 @@
 }
 
 /*
- * Parse a filename pattern and replace markers with values from a TrackDetails
- * structure.
+ * Parse a filename pattern and replace markers with values from a RhythmDBEntry
  *
  * Valid markers so far are:
  * %at -- album title
@@ -1233,6 +1234,7 @@
 		RhythmDBEntryType entry_type;
 		RBSource *source_source;
 		char *dest;
+		char *sane_dest;
 
 		rb_debug ("pasting entry %s", rhythmdb_entry_get_string (entry, RHYTHMDB_PROP_LOCATION));
 
@@ -1252,8 +1254,11 @@
 			continue;
 		}
 
+		sane_dest = rb_sanitize_uri_for_filesystem (dest);
+		g_free (dest);
+
 		rb_removable_media_manager_queue_transfer (rm_mgr, entry,
-							  dest, NULL,
+							  sane_dest, NULL,
 							  (RBTransferCompleteCallback)completed_cb, source);
 	}
 	g_boxed_free (RHYTHMDB_TYPE_ENTRY_TYPE, source_entry_type);



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