--- mail-format.c.orig	Sun Feb 17 22:24:37 2002
+++ mail-format.c	Sun Feb 17 22:22:57 2002
@@ -1374,18 +1374,29 @@
 	char *msg_start, *msg_end, *sig_start, *sig_end;
 	CamelContentType *type;
 	char *type_str;
+	char *decode_buffer;
+	char *dest_ptr, *src_start, *src_end;
 	
 	/* We know start points to "-----BEGIN PGP SIGNED MESSAGE-----\n" */
 	msg_start = start + sizeof ("-----BEGIN PGP SIGNED MESSAGE-----\n") - 1;
-	/* Skip 'One or more "Hash" Armor Headers' followed by
-	 * 'Exactly one empty line'.
-	 */
-	msg_start = strstr (msg_start, "\n\n");
-	if (!msg_start)
-		return start;
-	msg_start += 2;
+	
+	if (*msg_start != '\n') {
+		/* Skip 'One or more "Hash" Armor Headers' followed by
+		 * 'Exactly one empty line'.
+		 */
+		msg_start = strstr (msg_start, "\n\n");
+		if (!msg_start)
+			return start;
+		msg_start += 2;
+	}
+	else {
+		/* Skip the 'Exactly one empty line'
+		 */
+		++msg_start;
+	}
+	
 	msg_end = strstr (msg_start, "\n-----BEGIN PGP SIGNATURE-----\n");
-	if (!msg_end)
+	if (!msg_end || msg_end == msg_start)
 		return start;
 	
 	sig_start = msg_end;
@@ -1394,6 +1405,27 @@
 		return start;
 	sig_end += sizeof ("\n-----END PGP SIGNATURE-----\n") - 1;
 	
+	/* decode the dash escaped message body (rfc2440) */
+	decode_buffer = g_malloc (msg_end - msg_start);
+	dest_ptr = decode_buffer;
+	src_start = msg_start;
+	
+	if (src_start[0] == '-' && src_start[1] == ' ')
+		src_start += 2;
+	while ((src_end = strstr (src_start, "\n- "))
+	       && src_end < msg_end)
+	{
+		src_end++;
+		g_memmove (dest_ptr, src_start, src_end - src_start);
+		dest_ptr += src_end - src_start;
+		src_start = src_end + 2;	/* skip the dash and the space */
+	}
+	if (src_start < msg_end) {
+		g_memmove (dest_ptr, src_start, msg_end - src_start);
+		dest_ptr += msg_end - src_start;
+	}
+	
+	/* create new mime part for decoded message */
 	multipart = camel_multipart_new ();
 	camel_data_wrapper_set_mime_type (CAMEL_DATA_WRAPPER (multipart),
 					  "multipart/signed; micalg=pgp-sha1;"
@@ -1401,11 +1433,12 @@
 	
 	type = camel_mime_part_get_content_type (mime_part);
 	type_str = header_content_type_format (type);
-	part = fake_mime_part_from_data (msg_start, msg_end - msg_start,
+	part = fake_mime_part_from_data (decode_buffer, dest_ptr - decode_buffer,
 					 type_str, offset, md);
 	g_free (type_str);
 	camel_multipart_add_part (multipart, part);
 	camel_object_unref (CAMEL_OBJECT (part));
+	g_free (decode_buffer);
 	
 	part = fake_mime_part_from_data (sig_start, sig_end - sig_start,
 					 "application/pgp-signature",
