[evolution-patches] [Mailer] Fix for #326571



Hi,

Bug 326571 â?? Evolution converts *space* in filename to *underscore* when
saving attachments.
http://bugzilla.gnome.org/show_bug.cgi?id=326571

To allow more valid characters to occur in filenames, clone a copy
e_filename_make_safe() from e-d-s for saving attachments.

Sending patch for review.

Thanks,
-Simon
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution/mail/ChangeLog,v
retrieving revision 1.3818
diff -u -p -r1.3818 ChangeLog
--- ChangeLog	6 Mar 2006 10:44:25 -0000	1.3818
+++ ChangeLog	8 Mar 2006 11:39:17 -0000
@@ -1,3 +1,11 @@
+2006-03-08  Simon Zheng  <simon zheng sun com>
+
+	Fixes bug #326571
+	* em-utils.c (em_filename_make_safe), (emu_get_save_filesel),
+	(emu_save_parts_response):
+	Add em_filename_make_safe(), and use it to allow filenames 
+	contain more valid characters when saving attachment.
+
 2006-03-06  Simon Zheng  <simon zheng sun com>
 
 	Fixes bug #332140
Index: em-utils.c
===================================================================
RCS file: /cvs/gnome/evolution/mail/em-utils.c,v
retrieving revision 1.78
diff -u -p -r1.78 em-utils.c
--- em-utils.c	6 Mar 2006 10:44:25 -0000	1.78
+++ em-utils.c	8 Mar 2006 11:39:17 -0000
@@ -322,6 +322,40 @@ em_utils_edit_filters (GtkWidget *parent
 	gtk_widget_show (GTK_WIDGET (filter_editor));
 }
 
+/* 
+ * Picked this from e-d-s/libedataserver/e-data. 
+ * But it allows more characters to occur in filenames, especially when saving attachment.
+ */
+void
+em_filename_make_safe (gchar *string)
+{
+	gchar *p, *ts;
+	gunichar c;
+#ifdef G_OS_WIN32
+	const char *unsafe_chars = "/\":*?<>|\\";
+#else
+	const char *unsafe_chars = "/";
+#endif	
+	
+	g_return_if_fail (string != NULL);
+	p = string;
+
+	while(p && *p) {
+		c = g_utf8_get_char (p);
+		ts = p;
+		p = g_utf8_next_char (p);
+		/* I wonder what this code is supposed to actually
+		 * achieve, and whether it does that as currently
+		 * written?
+		 */
+		if (!g_unichar_isprint(c) || ( c < 0xff && strchr (unsafe_chars, c&0xff ))) {
+			while (ts<p) 	
+				*ts++ = '_';
+		}
+	}
+}
+
+
 /* Saving messages... */
 
 static GtkWidget *
@@ -358,7 +392,7 @@ emu_get_save_filesel (GtkWidget *parent,
 
 	if (name && name[0]) {
 		realname = g_strdup (name);
-		e_filename_make_safe (realname);
+		em_filename_make_safe (realname);
 	} else {
 		realname = NULL;
 	}
@@ -502,7 +536,7 @@ emu_save_parts_response (GtkWidget *file
                                 }
                         } else {
 				safe_name = g_strdup(file_name);
-				e_filename_make_safe(safe_name);
+				em_filename_make_safe(safe_name);
 				file_name = safe_name;
 			}
 			


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