Bug 793109 - Name of attached mail with dash in Subject truncated

This commit is contained in:
Milan Crha
2018-02-09 12:32:41 +01:00
parent a55165db99
commit 8678dddaf1
3 changed files with 28 additions and 11 deletions

View File

@ -870,6 +870,7 @@ e_attachment_store_run_save_dialog (EAttachmentStore *store,
EAttachment *attachment;
GFileInfo *file_info;
const gchar *name = NULL;
gchar *allocated;
#ifdef HAVE_AUTOAR
gchar *mime_type;
@ -885,7 +886,12 @@ e_attachment_store_run_save_dialog (EAttachmentStore *store,
/* Translators: Default attachment filename. */
name = _("attachment.dat");
gtk_file_chooser_set_current_name (file_chooser, name);
allocated = g_strdup (name);
e_filename_make_safe (allocated);
gtk_file_chooser_set_current_name (file_chooser, allocated);
g_free (allocated);
#ifdef HAVE_AUTOAR
mime_type = e_attachment_dup_mime_type (attachment);

View File

@ -2239,6 +2239,7 @@ attachment_load_from_mime_part_thread (GSimpleAsyncResult *simple,
}
}
g_free (allocated);
allocated = NULL;
/* Strip any path components from the filename. */
string = camel_mime_part_get_filename (mime_part);
@ -2277,9 +2278,13 @@ attachment_load_from_mime_part_thread (GSimpleAsyncResult *simple,
g_free (decoded_string);
decoded_string = NULL;
}
if (string && *string) {
allocated = g_path_get_basename (string);
string = allocated;
}
}
allocated = g_path_get_basename (string);
g_file_info_set_display_name (file_info, allocated);
g_file_info_set_display_name (file_info, string);
g_free (decoded_string);
g_free (allocated);
@ -2951,7 +2956,7 @@ attachment_save_new_candidate (SaveContext *save_context)
GFileInfo *file_info;
EAttachment *attachment;
const gchar *display_name = NULL;
gchar *basename;
gchar *basename, *allocated;
attachment = save_context->attachment;
file_info = e_attachment_ref_file_info (attachment);
@ -2962,12 +2967,16 @@ attachment_save_new_candidate (SaveContext *save_context)
/* Translators: Default attachment filename. */
display_name = _("attachment.dat");
basename = get_new_name_with_count (display_name, save_context->count);
allocated = g_strdup (display_name);
e_filename_make_safe (allocated);
basename = get_new_name_with_count (allocated, save_context->count);
save_context->count++;
candidate = g_file_get_child (save_context->directory, basename);
g_free (allocated);
g_free (basename);
g_clear_object (&file_info);

View File

@ -559,20 +559,22 @@ e_mail_part_describe (CamelMimePart *part,
filename = camel_mime_part_get_filename (part);
description = camel_mime_part_get_description (part);
if (!filename || !*filename) {
if (filename && *filename) {
gchar *basename = g_path_get_basename (filename);
g_string_append_printf (stext, " (%s)", basename);
g_free (basename);
} else {
CamelDataWrapper *content;
filename = NULL;
content = camel_medium_get_content (CAMEL_MEDIUM (part));
if (CAMEL_IS_MIME_MESSAGE (content))
filename = camel_mime_message_get_subject (
CAMEL_MIME_MESSAGE (content));
}
if (filename != NULL && *filename != '\0') {
gchar *basename = g_path_get_basename (filename);
g_string_append_printf (stext, " (%s)", basename);
g_free (basename);
if (filename && *filename)
g_string_append_printf (stext, " (%s)", filename);
}
if (description != NULL && *description != '\0' &&