diff options
author | Milan Crha <mcrha@redhat.com> | 2010-10-13 22:29:15 +0800 |
---|---|---|
committer | Milan Crha <mcrha@redhat.com> | 2010-10-13 22:29:15 +0800 |
commit | 231ed4fe9851aaf1517eea105c116826accdf175 (patch) | |
tree | e94766e6c91d193e25571e11ef0f50c9f8a8d833 | |
parent | 011e1064c52a1bad20a7d9806ee026c863b46613 (diff) | |
download | gsoc2013-evolution-231ed4fe9851aaf1517eea105c116826accdf175.tar gsoc2013-evolution-231ed4fe9851aaf1517eea105c116826accdf175.tar.gz gsoc2013-evolution-231ed4fe9851aaf1517eea105c116826accdf175.tar.bz2 gsoc2013-evolution-231ed4fe9851aaf1517eea105c116826accdf175.tar.lz gsoc2013-evolution-231ed4fe9851aaf1517eea105c116826accdf175.tar.xz gsoc2013-evolution-231ed4fe9851aaf1517eea105c116826accdf175.tar.zst gsoc2013-evolution-231ed4fe9851aaf1517eea105c116826accdf175.zip |
Bug #630375 - Character encoding of GPG encrypted message not honored
-rw-r--r-- | em-format/em-format.c | 19 | ||||
-rw-r--r-- | mail/em-format-html.c | 10 | ||||
-rw-r--r-- | mail/em-inline-filter.c | 6 |
3 files changed, 33 insertions, 2 deletions
diff --git a/em-format/em-format.c b/em-format/em-format.c index baa1803276..a5cda111d6 100644 --- a/em-format/em-format.c +++ b/em-format/em-format.c @@ -1465,6 +1465,22 @@ add_validity_found (EMFormat *emf, /* ********************************************************************** */ +static void +preserve_charset_in_content_type (CamelMimePart *ipart, CamelMimePart *opart) +{ + CamelContentType *ict; + + g_return_if_fail (ipart != NULL); + g_return_if_fail (opart != NULL); + + ict = camel_data_wrapper_get_mime_type_field (camel_medium_get_content (CAMEL_MEDIUM (ipart))); + if (!ict || !camel_content_type_param (ict, "charset") || !*camel_content_type_param (ict, "charset")) + return; + + camel_content_type_set_param (camel_data_wrapper_get_mime_type_field (camel_medium_get_content (CAMEL_MEDIUM (opart))), + "charset", camel_content_type_param (ict, "charset")); +} + #ifdef ENABLE_SMIME static void emf_application_xpkcs7mime (EMFormat *emf, @@ -1496,6 +1512,7 @@ emf_application_xpkcs7mime (EMFormat *emf, opart = camel_mime_part_new(); valid = camel_cipher_decrypt(context, part, opart, &local_error); + preserve_charset_in_content_type (part, opart); if (valid == NULL) { em_format_format_error ( emf, stream, "%s", @@ -1682,6 +1699,7 @@ emf_multipart_encrypted (EMFormat *emf, context = camel_gpg_context_new(emf->session); opart = camel_mime_part_new(); valid = camel_cipher_decrypt(context, part, opart, &local_error); + preserve_charset_in_content_type (part, opart); if (valid == NULL) { em_format_format_error ( emf, stream, local_error->message ? @@ -2153,6 +2171,7 @@ emf_inlinepgp_encrypted (EMFormat *emf, camel_data_wrapper_set_mime_type (dw, snoop); } + preserve_charset_in_content_type (ipart, opart); g_free (mime_type); add_validity_found (emf, valid); diff --git a/mail/em-format-html.c b/mail/em-format-html.c index 8962de2c36..6cc43da58c 100644 --- a/mail/em-format-html.c +++ b/mail/em-format-html.c @@ -1702,6 +1702,7 @@ efh_text_plain (EMFormatHTML *efh, EMInlineFilter *inline_filter; CamelStream *null; CamelContentType *ct; + gboolean charset_added = FALSE; /* if we had to snoop the part type to get here, then * use that as the base type, yuck */ @@ -1711,6 +1712,11 @@ efh_text_plain (EMFormatHTML *efh, camel_content_type_ref(ct); } + if (dw->mime_type && ct != dw->mime_type && camel_content_type_param (dw->mime_type, "charset")) { + camel_content_type_set_param (ct, "charset", camel_content_type_param (dw->mime_type, "charset")); + charset_added = TRUE; + } + null = camel_stream_null_new(); filtered_stream = camel_stream_filter_new (null); g_object_unref (null); @@ -1728,6 +1734,10 @@ efh_text_plain (EMFormatHTML *efh, efhc = efh_insert_cache(efh, ((EMFormat *)efh)->part_id->str); efhc->textmp = mp; + if (charset_added) { + camel_content_type_set_param (ct, "charset", NULL); + } + g_object_unref (inline_filter); camel_content_type_unref(ct); } diff --git a/mail/em-inline-filter.c b/mail/em-inline-filter.c index 703b3fc7a4..ea0859530c 100644 --- a/mail/em-inline-filter.c +++ b/mail/em-inline-filter.c @@ -100,8 +100,10 @@ inline_filter_add_part(EMInlineFilter *emif, const gchar *data, gint len) g_object_unref (mem); if (emif_types[emif->state].plain && emif->base_type) { - camel_content_type_ref (emif->base_type); - content_type = emif->base_type; + /* create a copy */ + type = camel_content_type_format (emif->base_type); + content_type = camel_content_type_decode (type); + g_free (type); } else { /* we want to preserve all params */ type = camel_content_type_format (emif->base_type); |