From fee3cf83f6833e34755c7c8492ef1a4088d91ae5 Mon Sep 17 00:00:00 2001 From: Jeffrey Stedfast Date: Wed, 17 Apr 2002 21:20:19 +0000 Subject: Handle broken multipart/signed parts such as where the signature part is 2002-04-17 Jeffrey Stedfast * mail-format.c (handle_multipart_signed): Handle broken multipart/signed parts such as where the signature part is not the last part (as it should be). Fixes bug #23583. * folder-browser.c (message_list_drag_data_get): Free the temp GByteArrays. (setup_popup_icons): Connect to the destroy signal on the pixmap objects using gtk_object_unref as the callback - this way when the popup menu gets destroyed, the pixmaps clean themselves up. (on_right_click): Same idea for the label_menu. svn path=/trunk/; revision=16494 --- mail/mail-format.c | 35 +++++++++++++++++++++++++++++------ 1 file changed, 29 insertions(+), 6 deletions(-) (limited to 'mail/mail-format.c') diff --git a/mail/mail-format.c b/mail/mail-format.c index 79bc90c9fb..eb5723da17 100644 --- a/mail/mail-format.c +++ b/mail/mail-format.c @@ -1763,22 +1763,34 @@ handle_multipart_signed (CamelMimePart *part, const char *mime_type, g_return_val_if_fail (CAMEL_IS_MULTIPART (wrapper), FALSE); - /* Display all the subparts (there should be only 1) - * except the signature (last part). + /* Display all the subparts (there should be only 1) up to, but not including, + * the signature. (this should be the last part but we all know that most + * mailers are broken, so attempt to handle broken multipart/signed messages). + * See bug #23583 for details. */ mp = CAMEL_MULTIPART (wrapper); nparts = camel_multipart_get_number (mp); - for (i = 0; i < nparts - 1; i++) { - if (i != 0 && output) - write_hr (html, stream); + for (i = 0; i < nparts; i++) { + CamelContentType *content_type; subpart = camel_multipart_get_part (mp, i); + content_type = camel_mime_part_get_content_type (subpart); + + if (header_content_type_is (content_type, "application", "pgp-signature")) + break; + + if (i != 0 && output) + write_hr (html, stream); output = format_mime_part (subpart, md, html, stream); } - subpart = camel_multipart_get_part (mp, i); + if (i >= nparts) { + /* no signature part? wtf? */ + return TRUE; + } + mail_part_set_default_displayed_inline (subpart, md, FALSE); if (!mail_part_is_displayed_inline (subpart, md) && !md->printing) { @@ -1852,6 +1864,17 @@ handle_multipart_signed (CamelMimePart *part, const char *mime_type, camel_cipher_validity_free (valid); } + /* continuation of handling broken multipart/signed + * parts... write out any extra parts that were added after + * the signature part. */ + for (i++; i < nparts; i++) { + subpart = camel_multipart_get_part (mp, i); + + write_hr (html, stream); + + output = format_mime_part (subpart, md, html, stream); + } + return TRUE; } -- cgit v1.2.3