From 80b93e39ac63a1adb76610e0f84c5273f675e603 Mon Sep 17 00:00:00 2001 From: Milan Crha Date: Wed, 20 Feb 2013 11:32:46 +0100 Subject: EAttachment: Decode part's file name before using it --- e-util/e-attachment.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/e-util/e-attachment.c b/e-util/e-attachment.c index 22ad0be653..a460890246 100644 --- a/e-util/e-attachment.c +++ b/e-util/e-attachment.c @@ -1785,7 +1785,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; @@ -1836,11 +1836,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; -- cgit v1.2.3