Re: [evolution-patches] fix for bug #44344
- From: Jeffrey Stedfast <fejj ximian com>
- To: evolution-patches ximian com
- Subject: Re: [evolution-patches] fix for bug #44344
- Date: 10 Jun 2003 01:24:35 -0400
better fix... instead of requiring an istext arg to get_best_encoding(),
instead define a bit CAMEL_BESTENC_TEXT that we pass in at creation
time.
1. this way the code that calls get_best_encoding() doesn't have to know
anything about the content-type
2. also means no API changes.
Jeff
On Tue, 2003-06-10 at 01:06, Jeffrey Stedfast wrote:
> 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 05:20:46 -0000
@@ -0,0 +1,9 @@
+2003-06-09 Jeffrey Stedfast <fejj ximian com>
+
+ * camel-mime-message.c (find_best_encoding): Add
+ CAMEL_BESTENC_TEXT to the bit flags.
+
+ * 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 05:20:47 -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.
@@ -222,7 +224,10 @@
camel_mime_filter_bestenc_get_best_encoding(CamelMimeFilterBestenc *f, CamelBestencEncoding required)
{
CamelMimePartEncodingType bestenc;
-
+ int istext;
+
+ istext = (f->flags & CAMEL_BESTENC_TEXT) ? 1 : 0;
+
#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 +243,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 +273,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 05:20:47 -0000
@@ -45,6 +45,8 @@
CAMEL_BESTENC_LF_IS_CRLF = 1<<8,
/* do we not allow "From " to appear at the start of a line in any part? */
CAMEL_BESTENC_NO_FROM = 1<<9,
+ /* stream is known to be a text stream */
+ CAMEL_BESTENC_TEXT = 1<<10,
};
typedef enum _CamelBestencRequired CamelBestencRequired;
@@ -70,7 +72,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 */
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 05:20:47 -0000
@@ -701,7 +701,7 @@
istext = header_content_type_is (part->content_type, "text", "*");
if (istext) {
- flags = CAMEL_BESTENC_GET_CHARSET | CAMEL_BESTENC_GET_ENCODING;
+ flags = CAMEL_BESTENC_GET_CHARSET | CAMEL_BESTENC_GET_ENCODING | CAMEL_BESTENC_TEXT;
} else {
flags = CAMEL_BESTENC_GET_ENCODING;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]