[evolution-patches] fix for bug #44344



Don't ever encode non-text streams as quoted-printable.

(technically you are allowed to do this, but to avoid the gotchas with
it, it's easier to just force base64)

-- 
Jeffrey Stedfast
Evolution Hacker - Ximian, Inc.
fejj ximian com  - www.ximian.com
? 44344.patch
? broken-pop3-server-workaround.patch
? camel-charset-map.patch
? camel-fixes.patch
? charset-map.c
? ct.patch
? imap.patch
? postfix.patch
? srep.sh
? subject-encoding.patch
? providers/mapi
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution/camel/ChangeLog,v
retrieving revision 1.1824
diff -u -r1.1824 ChangeLog
--- ChangeLog	9 Jun 2003 17:31:12 -0000	1.1824
+++ ChangeLog	10 Jun 2003 04:46:37 -0000
@@ -0,0 +1,9 @@
+2003-06-09  Jeffrey Stedfast  <fejj ximian com>
+
+	* camel-mime-message.c (find_best_encoding): Pass in the new
+	istext argument to camel_mime_filter_bestenc_get_best_encoding().
+
+	* camel-mime-filter-bestenc.c
+	(camel_mime_filter_bestenc_get_best_encoding): If we have any
+	nul-bytes or if the content is non-text and contains any 8bit
+	octets, we need to use base64. Fixes bug #44344.
Index: camel-mime-filter-bestenc.c
===================================================================
RCS file: /cvs/gnome/evolution/camel/camel-mime-filter-bestenc.c,v
retrieving revision 1.6
diff -u -r1.6 camel-mime-filter-bestenc.c
--- camel-mime-filter-bestenc.c	11 Jul 2002 22:30:49 -0000	1.6
+++ camel-mime-filter-bestenc.c	10 Jun 2003 04:46:37 -0000
@@ -23,6 +23,7 @@
 #include <config.h>
 #endif
 
+#include <stdio.h>
 #include <string.h>
 
 #include "camel-mime-filter-bestenc.h"
@@ -210,8 +211,9 @@
 
 /**
  * camel_mime_filter_bestenc_get_best_encoding:
- * @f: 
+ * @f: bestenc filter object
  * @required: maximum level of output encoding allowed.
+ * @istext: content stream is text
  * 
  * Return the best encoding, given specific constraints, that can be used to
  * encode a stream of bytes.
@@ -219,10 +221,10 @@
  * Return value: 
  **/
 CamelMimePartEncodingType
-camel_mime_filter_bestenc_get_best_encoding(CamelMimeFilterBestenc *f, CamelBestencEncoding required)
+camel_mime_filter_bestenc_get_best_encoding(CamelMimeFilterBestenc *f, CamelBestencEncoding required, int istext)
 {
 	CamelMimePartEncodingType bestenc;
-
+	
 #if 0
 	printf("count0 = %d, count8 = %d, total = %d\n", f->count0, f->count8, f->total);
 	printf("maxline = %d, crlfnoorder = %s\n", f->maxline, f->crlfnoorder?"TRUE":"FALSE");
@@ -238,7 +240,7 @@
 	/* if we need to encode, see how we do it */
 	if (required == CAMEL_BESTENC_BINARY)
 		bestenc = CAMEL_MIME_PART_ENCODING_BINARY;
-	else if (f->count8 + f->count0 >= (f->total*17/100))
+	else if (f->count0 > 0 || f->count8 >= (istext ? (f->total*17/100) : 1))
 		bestenc = CAMEL_MIME_PART_ENCODING_BASE64;
 	else
 		bestenc = CAMEL_MIME_PART_ENCODING_QUOTEDPRINTABLE;
@@ -268,7 +270,7 @@
 
 /**
  * camel_mime_filter_bestenc_get_best_charset:
- * @f: 
+ * @f: bestenc filter object
  * 
  * Gets the best charset that can be used to contain this content.
  * 
Index: camel-mime-filter-bestenc.h
===================================================================
RCS file: /cvs/gnome/evolution/camel/camel-mime-filter-bestenc.h,v
retrieving revision 1.7
diff -u -r1.7 camel-mime-filter-bestenc.h
--- camel-mime-filter-bestenc.h	7 May 2002 07:31:20 -0000	1.7
+++ camel-mime-filter-bestenc.h	10 Jun 2003 04:46:37 -0000
@@ -70,7 +70,7 @@
 	int startofline;	/* are we at the start of a new line? */
 
 	int fromcount;
-	char fromsave[6];	/* save a few characters if we found an \nF near the end of the buffer */
+	char fromsave[6];	/* save a few characters if we found an \n near the end of the buffer */
 	int hadfrom;		/* did we encounter a "\nFrom " in the data? */
 
 	unsigned int countline;	/* current count of characters on a given line */
@@ -87,7 +87,7 @@
 CamelMimeFilterBestenc      *camel_mime_filter_bestenc_new	(unsigned int flags);
 
 
-CamelMimePartEncodingType	camel_mime_filter_bestenc_get_best_encoding(CamelMimeFilterBestenc *f, CamelBestencEncoding required);
+CamelMimePartEncodingType	camel_mime_filter_bestenc_get_best_encoding(CamelMimeFilterBestenc *f, CamelBestencEncoding required, int istext);
 const char *		camel_mime_filter_bestenc_get_best_charset(CamelMimeFilterBestenc *f);
 void 			camel_mime_filter_bestenc_set_flags(CamelMimeFilterBestenc *f, unsigned int flags);
 
Index: camel-mime-message.c
===================================================================
RCS file: /cvs/gnome/evolution/camel/camel-mime-message.c,v
retrieving revision 1.113
diff -u -r1.113 camel-mime-message.c
--- camel-mime-message.c	16 May 2003 18:47:49 -0000	1.113
+++ camel-mime-message.c	10 Jun 2003 04:46:38 -0000
@@ -776,7 +776,7 @@
 		}
 	}
 	
-	encoding = camel_mime_filter_bestenc_get_best_encoding (bestenc, enctype);
+	encoding = camel_mime_filter_bestenc_get_best_encoding (bestenc, enctype, istext);
 	
 	camel_object_unref ((CamelObject *)filter);
 	camel_object_unref ((CamelObject *)bestenc);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]