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 02:07:45 -0400
ok, last try...then I'm going to bed.
Jeff
On Tue, 2003-06-10 at 01:24, Jeffrey Stedfast wrote:
> 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:56:35 -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:56:35 -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,11 @@
camel_mime_filter_bestenc_get_best_encoding(CamelMimeFilterBestenc *f, CamelBestencEncoding required)
{
CamelMimePartEncodingType bestenc;
-
+ int istext;
+
+ istext = (required & CAMEL_BESTENC_TEXT) ? 1 : 0;
+ required = required & ~CAMEL_BESTENC_TEXT;
+
#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 +244,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;
@@ -257,6 +263,7 @@
return bestenc;
case CAMEL_BESTENC_8BIT:
case CAMEL_BESTENC_BINARY:
+ default:
if (f->count0 == 0)
return CAMEL_MIME_PART_ENCODING_8BIT;
else
@@ -268,7 +275,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:56:35 -0000
@@ -52,6 +52,9 @@
CAMEL_BESTENC_7BIT,
CAMEL_BESTENC_8BIT,
CAMEL_BESTENC_BINARY,
+
+ /* is the content stream to be treated as text? */
+ CAMEL_BESTENC_TEXT = 1<<8,
};
typedef enum _CamelBestencEncoding CamelBestencEncoding;
@@ -70,7 +73,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:56:36 -0000
@@ -702,6 +702,7 @@
istext = header_content_type_is (part->content_type, "text", "*");
if (istext) {
flags = CAMEL_BESTENC_GET_CHARSET | CAMEL_BESTENC_GET_ENCODING;
+ enctype |= CAMEL_BESTENC_TEXT;
} else {
flags = CAMEL_BESTENC_GET_ENCODING;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]