diff options
author | Simon Zheng <simon.zheng@sun.com> | 2006-03-21 11:02:59 +0800 |
---|---|---|
committer | Simon Zheng <simonz@src.gnome.org> | 2006-03-21 11:02:59 +0800 |
commit | 379633a5ad7a5aec294c424ef500312beb1cc30a (patch) | |
tree | 3d1cc892324f57fc8fdaef7addaf90f3ae0f1380 | |
parent | 01b256150b4041dc49e539743754163c2704240d (diff) | |
download | gsoc2013-evolution-379633a5ad7a5aec294c424ef500312beb1cc30a.tar gsoc2013-evolution-379633a5ad7a5aec294c424ef500312beb1cc30a.tar.gz gsoc2013-evolution-379633a5ad7a5aec294c424ef500312beb1cc30a.tar.bz2 gsoc2013-evolution-379633a5ad7a5aec294c424ef500312beb1cc30a.tar.lz gsoc2013-evolution-379633a5ad7a5aec294c424ef500312beb1cc30a.tar.xz gsoc2013-evolution-379633a5ad7a5aec294c424ef500312beb1cc30a.tar.zst gsoc2013-evolution-379633a5ad7a5aec294c424ef500312beb1cc30a.zip |
Fixed bug #326571 Add em_filename_make_safe(), and use it to allow
2006-03-21 Simon Zheng <simon.zheng@sun.com>
Fixed 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 attachments.
svn path=/trunk/; revision=31726
-rw-r--r-- | mail/ChangeLog | 8 | ||||
-rw-r--r-- | mail/em-utils.c | 38 |
2 files changed, 44 insertions, 2 deletions
diff --git a/mail/ChangeLog b/mail/ChangeLog index 76c65d7ec6..b68d4e74ff 100644 --- a/mail/ChangeLog +++ b/mail/ChangeLog @@ -1,3 +1,11 @@ +2006-03-21 Simon Zheng <simon.zheng@sun.com> + + Fixed 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 attachments. + 2006-03-20 Srinivasa Ragavan <sragavan@novell.com> * em-folder-view.c: (emfv_setup_view_instance): Added code to set the diff --git a/mail/em-utils.c b/mail/em-utils.c index 13f66166ef..458fd2c02c 100644 --- a/mail/em-utils.c +++ b/mail/em-utils.c @@ -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, const char *title, const char *name, Gt 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 *filesel, int response, GSList *parts) } } else { safe_name = g_strdup(file_name); - e_filename_make_safe(safe_name); + em_filename_make_safe(safe_name); file_name = safe_name; } |