[claws-mail-cvs-commit] procmime.c

Colin Leroy <[email protected]> Tue, 15 Sep 2009 19:13:30 +0000
Newsgroups gmane.mail.sylpheed.claws.cvs
Message-ID <[email protected]>
Update of /srv/cvs/claws-mail/claws/src
In directory ran:/tmp/cvs-serv31897/src

Modified Files:
      Tag: gtk2
	procmime.c 
Log Message:
2009-09-15 [colin]	3.7.2cvs33

	* src/procmime.c
		Complete 3.7.1cvs42: only output directly to
		final file if we get NULL byes at the start.
		Still fixes saving UTF16 files, but also
		fixes displaying Base64 parts with decoding
		errors (parts without errors get displayed)

Index: procmime.c
===================================================================
RCS file: /srv/cvs/claws-mail/claws/src/procmime.c,v
retrieving revision 1.49.2.130
retrieving revision 1.49.2.131
diff -u -d -r1.49.2.130 -r1.49.2.131
--- procmime.c	8 Apr 2009 16:10:13 -0000	1.49.2.130
+++ procmime.c	15 Sep 2009 19:13:28 -0000	1.49.2.131
@@ -351,6 +351,7 @@
 		gboolean uncanonicalize = FALSE;
 		FILE *tmpfp = outfp;
 		gboolean null_bytes = FALSE;
+		gboolean starting = TRUE;
 
 		if (mimeinfo->type == MIMETYPE_TEXT ||
 		    mimeinfo->type == MIMETYPE_MESSAGE) {
@@ -367,10 +368,11 @@
 		decoder = base64_decoder_new();
 		while ((ftell(infp) < readend) && (fgets(buf, sizeof(buf), infp) != NULL)) {
 			len = base64_decoder_decode(decoder, buf, outbuf);
-			if (uncanonicalize == TRUE && strlen(outbuf) < len) {
+			if (uncanonicalize == TRUE && strlen(outbuf) < len && starting) {
 				uncanonicalize = FALSE;
 				null_bytes = TRUE;
 			}
+			starting = FALSE;
 			if (len < 0 && !got_error) {
 				g_warning("Bad BASE64 content.\n");
 				if (fwrite(_("[Error decoding BASE64]\n"),