Index: src/plugins/pgpinline/pgpinline.c
===================================================================
RCS file: /cvsroot/sylpheed-claws/sylpheed-claws/src/plugins/pgpinline/Attic/pgpinline.c,v
retrieving revision 1.1.2.8
diff -u -r1.1.2.8 pgpinline.c
--- src/plugins/pgpinline/pgpinline.c	21 Oct 2005 17:31:15 -0000	1.1.2.8
+++ src/plugins/pgpinline/pgpinline.c	13 Jan 2006 06:25:50 -0000
@@ -200,6 +200,112 @@
 	return TRUE;
 }
 
+/* Removes the ASCII armoring from an inline signed message.
+ * (REPLACES the mimeinfo node that's passed in!) */
+static MimeInfo* pgpinline_unascii_armor(MimeInfo *mimeinfo)
+{
+	MimeInfo *parseinfo, *unarmored;
+	FILE *srcfp = NULL, *dstfp;
+	gchar* fname;
+	const gchar *sig_indicator = "-----BEGIN PGP";
+	static gint id = 0;
+	short sawsig = 0;
+	gchar buf[BUFFSIZE];
+
+	fname = g_strdup_printf("%s%cunarmored.%08x",
+		get_mime_tmp_dir(), G_DIR_SEPARATOR, ++id);
+
+	if (mimeinfo->content == MIMECONTENT_FILE)
+	{
+		if ((srcfp = g_fopen(mimeinfo->data.filename, "r")) == NULL)
+		{
+			FILE_OP_ERROR(fname, "fopen");
+			g_free(fname);
+			return NULL;
+		}
+	}
+	else
+		srcfp = str_open_as_stream(mimeinfo->data.mem);
+		
+	if ((dstfp = g_fopen(fname, "wb")) == NULL) {
+		FILE_OP_ERROR(fname, "fopen");
+		g_free(fname);
+		return NULL;
+	}
+
+	/* Separate the headers */
+	fputs("\n", dstfp);
+
+	/* Now strip the headers, check for armor header first */
+	if (fgets(buf, BUFFSIZE, srcfp) != NULL)
+	{
+		if (strncmp(sig_indicator, buf, 14) == 0) /* length of sig_indicator */
+		{
+			char *ptr;
+			while ((ptr = fgets(buf, BUFFSIZE, srcfp)) != NULL)
+			{
+				/* Newline separates headers and body */
+				if (buf[0] == '\n')
+					break;
+			}
+
+			if (ptr == NULL) /* end of message? */
+				return NULL;
+		}
+	}
+
+	/* Now parse the rest of the message, with dash-escaping, until we hit
+	 * the sig header. */
+	while (fgets(buf, BUFFSIZE, srcfp) != NULL)
+	{
+		if (strcmp(buf, "-----BEGIN PGP SIGNATURE-----\n") == 0)
+		{
+			sawsig = 1;
+			break;
+		}
+
+		if (buf[0] == '-' && buf[1] == ' ')
+			fputs(buf + 2, dstfp);
+		else
+			fputs(buf, dstfp);
+	}
+	
+	fclose(dstfp);
+	fclose(srcfp);
+
+	if (!sawsig) /* then what was it...? */
+	{
+		unlink(fname);
+		return NULL;
+	}
+
+	/* Now create a new message, a la pgpinline_decrypt */
+	parseinfo = procmime_scan_file(fname);
+	g_free(fname); /* will be reaped by sylpheed */
+
+	if (parseinfo == NULL)
+		return NULL;
+	
+	unarmored = g_node_first_child(parseinfo->node) != NULL ?
+		g_node_first_child(parseinfo->node)->data : NULL;
+
+	if (unarmored == NULL)
+		return NULL;
+
+	g_node_unlink(unarmored->node);
+
+	/* Copy privacy data */
+	unarmored->privacy = (PrivacyData *)pgpinline_new_privacydata();
+	memcpy(unarmored->privacy, mimeinfo->privacy, sizeof(PrivacyDataPGP));
+	procmime_mimeinfo_free_all(parseinfo);
+
+	/* Now replace the mimeinfo node! */
+	g_node_prepend(mimeinfo->node->parent, unarmored->node);
+	g_node_unlink(mimeinfo->node);
+	
+	return unarmored;
+}
+
 static gint pgpinline_check_signature(MimeInfo *mimeinfo)
 {
 	PrivacyDataPGP *data = NULL;
@@ -256,6 +362,8 @@
 	gpgme_data_release(cipher);
 	
 	g_free(textdata);
+
+	pgpinline_unascii_armor(mimeinfo);
 	
 	return 0;
 }
