[evolution/gnome-3-6] EAttachment: Decode part's file name before using it



commit 9064d9e60105f51bdf63ff1b2aeba51efa003998
Author: Milan Crha <mcrha redhat com>
Date:   Wed Feb 20 11:35:01 2013 +0100

    EAttachment: Decode part's file name before using it

 widgets/misc/e-attachment.c |   14 ++++++++++++--
 1 files changed, 12 insertions(+), 2 deletions(-)
---
diff --git a/widgets/misc/e-attachment.c b/widgets/misc/e-attachment.c
index 32f79da..8a4ff29 100644
--- a/widgets/misc/e-attachment.c
+++ b/widgets/misc/e-attachment.c
@@ -1786,7 +1786,7 @@ attachment_load_from_mime_part_thread (GSimpleAsyncResult *simple,
        CamelMimePart *mime_part;
        const gchar *attribute;
        const gchar *string;
-       gchar *allocated;
+       gchar *allocated, *decoded_string = NULL;
        CamelStream *null;
        CamelDataWrapper *dw;
 
@@ -1837,11 +1837,21 @@ attachment_load_from_mime_part_thread (GSimpleAsyncResult *simple,
 
        /* Strip any path components from the filename. */
        string = camel_mime_part_get_filename (mime_part);
-       if (string == NULL)
+       if (string == NULL) {
                /* Translators: Default attachment filename. */
                string = _("attachment.dat");
+       } else {
+               decoded_string = camel_header_decode_string (string, "UTF-8");
+               if (decoded_string && *decoded_string && !g_str_equal (decoded_string, string)) {
+                       string = decoded_string;
+               } else {
+                       g_free (decoded_string);
+                       decoded_string = NULL;
+               }
+       }
        allocated = g_path_get_basename (string);
        g_file_info_set_display_name (file_info, allocated);
+       g_free (decoded_string);
        g_free (allocated);
 
        attribute = G_FILE_ATTRIBUTE_STANDARD_DESCRIPTION;


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