pkg://evolution-2.0.4-6.src.rpm:15418022/evolution-2.0.4-fix-for-CAN-2005-0806.patch
info downloads
--- evolution-2.0.4/mail/ChangeLog.fix-for-CAN-2005-0806 2005-02-14 11:09:06.000000000 -0500
+++ evolution-2.0.4/mail/ChangeLog 2005-04-20 17:45:24.000000000 -0400
@@ -0,0 +1,8 @@
+2005-02-24 Not Zed <NotZed@Ximian.com>
+
+ ** See bug #72609
+
+ * em-inline-filter.c (emif_scan): try to convert the filename
+ based on the incoming charset or the locale charset. This will
+ make sure it is always valid.
+
--- evolution-2.0.4/mail/em-inline-filter.c.fix-for-CAN-2005-0806 2004-05-19 03:02:12.000000000 -0400
+++ evolution-2.0.4/mail/em-inline-filter.c 2005-04-20 17:45:24.000000000 -0400
@@ -196,6 +196,7 @@
if (strncmp(start, "begin ", 6) == 0
&& start[6] >= '0' && start[6] <= '7') {
int i = 7;
+ char *name;
while (start[i] >='0' && start[i] <='7')
i++;
@@ -206,7 +207,10 @@
break;
emif_add_part(emif, data_start, start-data_start);
- emif->filename = g_strndup(start+i, inptr-start-i-1);
+
+ name = g_strndup(start+i, inptr-start-i-1);
+ emif->filename = camel_header_decode_string(name, emif->base_type?camel_content_type_param(emif->base_type, "charset"):NULL);
+ g_free(name);
data_start = start;
emif->state = EMIF_UUENC;
} else if (strncmp(start, "(This file must be converted with BinHex 4.0)", 45) == 0) {
--- evolution-2.0.4/camel/ChangeLog.fix-for-CAN-2005-0806 2005-02-14 11:09:04.000000000 -0500
+++ evolution-2.0.4/camel/ChangeLog 2005-04-20 17:45:24.000000000 -0400
@@ -0,0 +1,12 @@
+2005-02-28 Not Zed <NotZed@Ximian.com>
+
+ ** See bug #72609
+
+ * camel-mime-utils.c (header_encode_param): just call
+ camel_charset_best once to get the best charset, and handle a NULL
+ charset name case properly.
+
+ * camel-charset-map.c (camel_charset_step): use the camel utf8
+ functions for robustness (&fix possible buffer-read-overflow).
+ Perform some short-circuit optimisation when we can.
+
--- evolution-2.0.4/camel/camel-mime-utils.c.fix-for-CAN-2005-0806 2005-02-14 11:09:04.000000000 -0500
+++ evolution-2.0.4/camel/camel-mime-utils.c 2005-04-20 17:47:07.000000000 -0400
@@ -2998,7 +2998,6 @@
const unsigned char *inptr = in;
unsigned char *outbuf = NULL;
const char *charset;
- int encoding;
GString *out;
guint32 c;
@@ -3006,36 +3005,17 @@
g_return_val_if_fail (in != NULL, NULL);
- /* do a quick us-ascii check (the common case?) */
- while (*inptr) {
- if (*inptr > 127)
- break;
- inptr++;
- }
-
- if (*inptr == '\0')
- return g_strdup (in);
-
- inptr = in;
- encoding = 0;
- while ( encoding !=2 && (c = camel_utf8_getc(&inptr)) ) {
- if (c > 127 && c < 256)
- encoding = MAX (encoding, 1);
- else if (c >= 256)
- encoding = MAX (encoding, 2);
- }
-
- if (encoding == 2)
- charset = camel_charset_best(in, strlen(in));
- else
- charset = "iso-8859-1";
-
- if (strcasecmp(charset, "UTF-8") != 0
- && (outbuf = header_convert(charset, "UTF-8", in, strlen(in)))) {
- inptr = outbuf;
- } else {
- charset = "UTF-8";
- inptr = in;
+ /* if we have really broken utf8 passed in, we just treat it as binary data */
+
+ charset = camel_charset_best(in, strlen(in));
+ if (charset == NULL)
+ return g_strdup(in);
+
+ if (g_ascii_strcasecmp(charset, "UTF-8") != 0) {
+ if ((outbuf = header_convert(charset, "UTF-8", in, strlen(in))))
+ inptr = outbuf;
+ else
+ return g_strdup(in);
}
/* FIXME: set the 'language' as well, assuming we can get that info...? */
--- evolution-2.0.4/camel/camel-charset-map.c.fix-for-CAN-2005-0806 2004-12-06 02:46:50.000000000 -0500
+++ evolution-2.0.4/camel/camel-charset-map.c 2005-04-20 17:45:24.000000000 -0400
@@ -200,11 +200,6 @@
#else
-#include "camel-charset-map.h"
-#include "camel-charset-map-private.h"
-
-#include <gal/util/e-iconv.h>
-
#include <glib.h>
#include <locale.h>
#include <ctype.h>
@@ -213,6 +208,12 @@
#include <langinfo.h>
#endif
+#include "camel-charset-map.h"
+#include "camel-charset-map-private.h"
+#include "camel-utf8.h"
+
+#include <gal/util/e-iconv.h>
+
void
camel_charset_init (CamelCharset *c)
{
@@ -221,42 +222,34 @@
}
void
-camel_charset_step (CamelCharset *c, const char *in, int len)
+camel_charset_step (CamelCharset *cc, const char *in, int len)
{
register unsigned int mask;
register int level;
- const char *inptr = in, *inend = in+len;
+ const unsigned char *inptr = in, *inend = in+len;
+ register guint32 c;
- mask = c->mask;
- level = c->level;
+ mask = cc->mask;
+ level = cc->level;
/* check what charset a given string will fit in */
- while (inptr < inend) {
- gunichar c;
- const char *newinptr;
- newinptr = g_utf8_next_char(inptr);
- c = g_utf8_get_char(inptr);
- if (newinptr == NULL || !g_unichar_validate (c)) {
- inptr++;
- continue;
- }
-
- inptr = newinptr;
- if (c<=0xffff) {
+ while ( (c = camel_utf8_getc_limit(&inptr, inend)) != 0xffff) {
+ if (c < 0xffff) {
mask &= charset_mask(c);
if (c>=128 && c<256)
level = MAX(level, 1);
else if (c>=256)
- level = MAX(level, 2);
+ level = 2;
} else {
mask = 0;
- level = MAX(level, 2);
+ level = 2;
+ break;
}
}
- c->mask = mask;
- c->level = level;
+ cc->mask = mask;
+ cc->level = level;
}
/* gets the best charset from the mask of chars in it */