Handle broken multipart/signed parts such as where the signature part is

2002-04-17  Jeffrey Stedfast  <fejj@ximian.com>

	* 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
This commit is contained in:
Jeffrey Stedfast
2002-04-17 21:20:19 +00:00
committed by Jeffrey Stedfast
parent d89c3d0a9c
commit fee3cf83f6
3 changed files with 57 additions and 16 deletions

View File

@ -1,3 +1,16 @@
2002-04-17 Jeffrey Stedfast <fejj@ximian.com>
* 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.
2002-04-17 Jeffrey Stedfast <fejj@ximian.com>
* mail-local.c (mail_local_folder_construct): Just use g_basename.

View File

@ -381,7 +381,7 @@ message_list_drag_data_get (ETree *tree, int row, ETreePath path, int col,
gtk_selection_data_set (selection_data, selection_data->target, 8,
bytes->data, bytes->len);
g_byte_array_free (bytes, FALSE);
g_byte_array_free (bytes, TRUE);
}
break;
case DND_TARGET_TYPE_X_EVOLUTION_MESSAGE:
@ -409,7 +409,7 @@ message_list_drag_data_get (ETree *tree, int row, ETreePath path, int col,
gtk_selection_data_set (selection_data, selection_data->target, 8,
array->data, array->len);
g_byte_array_free (array, FALSE);
g_byte_array_free (array, TRUE);
}
break;
default:
@ -1731,6 +1731,8 @@ setup_popup_icons (void)
filename = g_strdup_printf ("%s/%s", EVOLUTION_IMAGES, context_pixmaps[i]);
context_menu[i].pixmap = gnome_pixmap_new_from_file (filename);
gtk_signal_connect (GTK_OBJECT (context_menu[i].pixmap), "destroy",
gtk_object_unref, NULL);
g_free (filename);
}
}
@ -1768,9 +1770,9 @@ on_right_click (ETree *tree, gint row, ETreePath path, gint col, GdkEvent *event
enable_mask |= CAN_RESEND;
hide_mask |= CAN_RESEND;
}
enable_mask |= SELECTION_SET;
/* get a list of uids */
uids = g_ptr_array_new ();
message_list_foreach (fb->message_list, enumerate_msg, uids);
@ -1792,23 +1794,23 @@ on_right_click (ETree *tree, gint row, ETreePath path, gint col, GdkEvent *event
info = camel_folder_get_message_info (fb->folder, uids->pdata[i]);
if (info == NULL)
continue;
if (i == 0 && uids->len == 1) {
const char *mname, *p;
char c, *o;
/* used by filter/vfolder from X callbacks */
fdata = g_malloc0(sizeof(*fdata));
fdata->uid = g_strdup(uids->pdata[i]);
fdata->uri = g_strdup(fb->uri);
fdata->folder = fb->folder;
camel_object_ref((CamelObject *)fdata->folder);
enable_mask &= ~SELECTION_SET;
mname = camel_message_info_mlist(info);
if (mname && mname[0]) {
fdata->mlist = g_strdup(mname);
/* Escape the mailing list name before showing it */
mlist = alloca (strlen (mname)+2);
p = mname;
@ -1962,11 +1964,14 @@ on_right_click (ETree *tree, gint row, ETreePath path, gint col, GdkEvent *event
label_menu[i + 2].name = e_utf8_to_locale_string (mail_config_get_label_name (i));
label_menu[i + 2].pixmap = gtk_pixmap_new (pixmap, NULL);
label_menu[i + 2].closure = closure;
gtk_signal_connect (GTK_OBJECT (label_menu[i].pixmap), "destroy",
gtk_object_unref, NULL);
}
setup_popup_icons ();
for (i=0;i<sizeof(filter_menu)/sizeof(filter_menu[0]);i++)
for (i = 0; i < sizeof (filter_menu) / sizeof (filter_menu[0]); i++)
filter_menu[i].closure = fdata;
menu = e_popup_menu_create (context_menu, enable_mask, hide_mask, fb);
@ -1998,7 +2003,7 @@ on_right_click (ETree *tree, gint row, ETreePath path, gint col, GdkEvent *event
for (i = 0; i < 5; i++) {
g_free (label_menu[i + 2].name);
}
return TRUE;
}

View File

@ -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;
}