aboutsummaryrefslogtreecommitdiffstats
path: root/mail
diff options
context:
space:
mode:
Diffstat (limited to 'mail')
-rw-r--r--mail/ChangeLog11
-rw-r--r--mail/em-format.c45
-rw-r--r--mail/em-inline-filter.c61
3 files changed, 80 insertions, 37 deletions
diff --git a/mail/ChangeLog b/mail/ChangeLog
index 98eaa70ac2..d11af3dc5e 100644
--- a/mail/ChangeLog
+++ b/mail/ChangeLog
@@ -1,3 +1,14 @@
+2006-04-20 Jeffrey Stedfast <fejj@novell.com>
+
+ Fix for bug #339052
+
+ * em-inline-filter.c (emif_add_part): Preserve all Content-Type
+ params so that they may be restored later.
+
+ * em-format.c (emf_inlinepgp_signed): Restore the original part's
+ Content-Type params otherwise we lose valuable information such as
+ charset or format=flowed or various other things.
+
2006-04-18 Jeffrey Stedfast <fejj@novell.com>
* mail.error.xml: Removed error id "camel-exception" as it was a
diff --git a/mail/em-format.c b/mail/em-format.c
index 7467896dac..b89d1e0423 100644
--- a/mail/em-format.c
+++ b/mail/em-format.c
@@ -1501,15 +1501,17 @@ emf_message_deliverystatus(EMFormat *emf, CamelStream *stream, CamelMimePart *pa
static void
emf_inlinepgp_signed(EMFormat *emf, CamelStream *stream, CamelMimePart *ipart, EMFormatHandler *info)
{
+ CamelStreamFilter *filtered_stream;
+ CamelMimeFilterPgp *pgp_filter;
+ CamelContentType *content_type;
CamelCipherContext *cipher;
CamelCipherValidity *valid;
- CamelException *ex;
- CamelMimePart *opart=NULL;
- CamelStreamFilter *filtered_stream;
- CamelStream *ostream;
CamelDataWrapper *dw;
- CamelMimeFilterPgp *pgp_filter;
-
+ CamelMimePart *opart;
+ CamelStream *ostream;
+ CamelException *ex;
+ char *type;
+
ex = camel_exception_new();
cipher = camel_gpg_context_new(emf->session);
/* Verify the signature of the message */
@@ -1528,7 +1530,7 @@ emf_inlinepgp_signed(EMFormat *emf, CamelStream *stream, CamelMimePart *ipart, E
/* Setup output stream */
ostream = camel_stream_mem_new();
filtered_stream = camel_stream_filter_new_with_stream(ostream);
-
+
/* Add PGP header / footer filter */
pgp_filter = (CamelMimeFilterPgp *)camel_mime_filter_pgp_new();
camel_stream_filter_add(filtered_stream, (CamelMimeFilter *)pgp_filter);
@@ -1540,17 +1542,30 @@ emf_inlinepgp_signed(EMFormat *emf, CamelStream *stream, CamelMimePart *ipart, E
camel_stream_flush((CamelStream *)filtered_stream);
camel_object_unref(filtered_stream);
- /* Extract new part and display it as text/plain */
- dw = camel_data_wrapper_new();
- camel_data_wrapper_construct_from_stream(dw, ostream);
- camel_data_wrapper_set_mime_type(dw, "text/plain");
- opart = camel_mime_part_new();
- camel_medium_set_content_object((CamelMedium *)opart, dw);
- camel_mime_part_set_content_type(opart, "text/plain");
+ /* Create a new text/plain MIME part containing the signed content preserving the original part's Content-Type params */
+ content_type = camel_mime_part_get_content_type (ipart);
+ type = camel_content_type_format (content_type);
+ content_type = camel_content_type_decode (type);
+ g_free (type);
+
+ g_free (content_type->type);
+ content_type->type = g_strdup ("text");
+ g_free (content_type->subtype);
+ content_type->subtype = g_strdup ("plain");
+ type = camel_content_type_format (content_type);
+ camel_content_type_unref (content_type);
+
+ dw = camel_data_wrapper_new ();
+ camel_data_wrapper_construct_from_stream (dw, ostream);
+ camel_data_wrapper_set_mime_type (dw, type);
+
+ opart = camel_mime_part_new ();
+ camel_medium_set_content_object ((CamelMedium *) opart, dw);
+ camel_data_wrapper_set_mime_type_field ((CamelDataWrapper *) opart, dw->mime_type);
/* Pass it off to the real formatter */
em_format_format_secure(emf, stream, opart, valid);
-
+
/* Clean Up */
camel_object_unref(dw);
camel_object_unref(opart);
diff --git a/mail/em-inline-filter.c b/mail/em-inline-filter.c
index 9842742341..9549b6b1bd 100644
--- a/mail/em-inline-filter.c
+++ b/mail/em-inline-filter.c
@@ -106,31 +106,34 @@ enum {
};
static const struct {
- const char *name;
- CamelTransferEncoding type;
+ const char *type;
+ const char *subtype;
+ CamelTransferEncoding encoding;
int plain:1;
} emif_types[] = {
- { "text/plain", CAMEL_TRANSFER_ENCODING_DEFAULT, 1, },
- { "application/octet-stream", CAMEL_TRANSFER_ENCODING_UUENCODE, },
- { "application/mac-binhex40", CAMEL_TRANSFER_ENCODING_7BIT, },
- { "application/postscript", CAMEL_TRANSFER_ENCODING_7BIT, },
- { "application/x-inlinepgp-signed", CAMEL_TRANSFER_ENCODING_DEFAULT, },
- { "application/x-inlinepgp-encrypted", CAMEL_TRANSFER_ENCODING_DEFAULT, },
+ { "text", "plain", CAMEL_TRANSFER_ENCODING_DEFAULT, 1, },
+ { "application", "octet-stream", CAMEL_TRANSFER_ENCODING_UUENCODE, 0, },
+ { "application", "mac-binhex40", CAMEL_TRANSFER_ENCODING_7BIT, 0, },
+ { "application", "postscript", CAMEL_TRANSFER_ENCODING_7BIT, 0, },
+ { "application", "x-inlinepgp-signed", CAMEL_TRANSFER_ENCODING_DEFAULT, 0, },
+ { "application", "x-inlinepgp-encrypted", CAMEL_TRANSFER_ENCODING_DEFAULT, 0, },
};
static void
emif_add_part(EMInlineFilter *emif, const char *data, int len)
{
- CamelTransferEncoding type;
- CamelStream *mem;
+ CamelTransferEncoding encoding;
+ CamelContentType *content_type;
CamelDataWrapper *dw;
- CamelMimePart *part;
const char *mimetype;
-
+ CamelMimePart *part;
+ CamelStream *mem;
+ char *type;
+
if (emif->state == EMIF_PLAIN || emif->state == EMIF_PGPSIGNED || emif->state == EMIF_PGPENCRYPTED)
- type = emif->base_encoding;
+ encoding = emif->base_encoding;
else
- type = emif_types[emif->state].type;
+ encoding = emif_types[emif->state].encoding;
g_byte_array_append(emif->data, data, len);
/* check the part will actually have content */
@@ -139,19 +142,33 @@ emif_add_part(EMInlineFilter *emif, const char *data, int len)
}
mem = camel_stream_mem_new_with_byte_array(emif->data);
emif->data = g_byte_array_new();
-
+
dw = camel_data_wrapper_new();
camel_data_wrapper_construct_from_stream(dw, mem);
camel_object_unref(mem);
- if (emif_types[emif->state].plain && emif->base_type)
- camel_data_wrapper_set_mime_type_field(dw, emif->base_type);
- else
- camel_data_wrapper_set_mime_type(dw, emif_types[emif->state].name);
- dw->encoding = type;
-
+
+ if (emif_types[emif->state].plain && emif->base_type) {
+ camel_content_type_ref (emif->base_type);
+ content_type = emif->base_type;
+ } else {
+ /* we want to preserve all params */
+ type = camel_content_type_format (emif->base_type);
+ content_type = camel_content_type_decode (type);
+ g_free (type);
+
+ g_free (content_type->type);
+ g_free (content_type->subtype);
+ content_type->type = g_strdup (emif_types[emif->state].type);
+ content_type->subtype = g_strdup (emif_types[emif->state].subtype);
+ }
+
+ camel_data_wrapper_set_mime_type_field (dw, content_type);
+ camel_content_type_unref (content_type);
+ dw->encoding = encoding;
+
part = camel_mime_part_new();
camel_medium_set_content_object((CamelMedium *)part, dw);
- camel_mime_part_set_encoding(part, type);
+ camel_mime_part_set_encoding(part, encoding);
camel_object_unref(dw);
if (emif->filename)