[evolution-patches] patch for fix fix non rfc2047 compliant i18n mailer
- From: cantona <cantona softhome net>
- To: evolution-patches lists ximian com
- Cc: notzed ximian com
- Subject: [evolution-patches] patch for fix fix non rfc2047 compliant i18n mailer
- Date: Sun, 30 May 2004 06:13:18 +0800
Hi all,
This is the patch for fix non rfc2047 compliant i18n header.
I have tested it with no problem and work properly with valid header.
If someone have time, please see it if something I can improve . (I am a
newbie coder)
Thanks,
Cantona
Index: camel/ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution/camel/ChangeLog,v
retrieving revision 1.2152
diff -u -r1.2152 ChangeLog
--- a/camel/ChangeLog 27 May 2004 17:56:51 -0000 1.2152
+++ b/camel/ChangeLog 29 May 2004 22:04:56 -0000
@@ -1,3 +1,10 @@
+2004-05-30 Cantona Su <paradisetux hotmail com>
+
+ * camel-mime-utils.c (camel_fix_non_rfc): Added camel_fix_non_rfc()
+ for fix non rfc2047 compliant i18n mailer. #58555
+ (camel_header_decode_string): call camel_fix_non_rfc() before return
+ the string to header_decode_text().
+
2004-05-27 Jeffrey Stedfast <fejj novell com>
Fixes bug #59191.
Index: camel/camel-mime-utils.c
===================================================================
RCS file: /cvs/gnome/evolution/camel/camel-mime-utils.c,v
retrieving revision 1.208
diff -u -r1.208 camel-mime-utils.c
--- a/camel/camel-mime-utils.c 24 May 2004 08:02:10 -0000 1.208
+++ b/camel/camel-mime-utils.c 29 May 2004 22:04:58 -0000
@@ -70,6 +70,7 @@
#define w(x)
#define d(x)
+#define dd(x)
#define d2(x)
#define CAMEL_UUENCODE_CHAR(c) ((c) ? (c) + ' ' : '`')
@@ -967,19 +968,19 @@
gboolean retried = FALSE;
iconv_t ic;
- d(printf("rfc2047: decoding '%.*s'\n", len, in));
+ dd(printf("rfc2047: decoding '%.*s'\n", len, in));
/* quick check to see if this could possibly be a real encoded word */
if (len < 8 || !(in[0] == '=' && in[1] == '?' && in[len-1] == '=' && in[len-2] == '?')) {
- d(printf("invalid\n"));
+ dd(printf("invalid\n"));
return NULL;
}
/* skip past the charset to the encoding type */
inptr = memchr (inptr, '?', inend-inptr);
if (inptr != NULL && inptr < inend + 2 && inptr[2] == '?') {
- d(printf("found ?, encoding is '%c'\n", inptr[0]));
inptr++;
+ dd(printf("found ?, encoding is '%c'\n", inptr[0]));
tmplen = inend-inptr-2;
decword = g_alloca (tmplen); /* this will always be more-than-enough room */
switch(toupper(inptr[0])) {
@@ -1174,7 +1175,51 @@
{
if (in == NULL)
return NULL;
- return header_decode_text (in, strlen (in), default_charset);
+ const char *enc;
+ enc = camel_fix_non_rfc(in);
+ return header_decode_text (enc, strlen (enc), default_charset);
+}
+
+/* fix for non rfc2047 compliant i18n mailers */
+const char *
+camel_fix_non_rfc(const char *in) {
+ GString *out;
+ const char *str, *start, *temp;
+ int len, i;
+
+ str = in;
+ out = g_string_new ("");
+
+ do {
+ start = strstr(str, "=?");
+ temp = strstr(toupper(str), "?B?");
+
+ if (start == str && (start = strstr(str+2, "=?")) && temp) {
+ len = start - str + 3;
+ } else {
+ len = start - str;
+ }
+
+ dd(printf("encode word %.*s\n\n", len, str));
+ g_string_append_len(out, str, len);
+ g_string_append_c(out, ' ');
+
+ temp = out->str;
+ i = strrchr(temp, '=') - temp + 1;
+
+ if(i > 0 && temp[i-2] == '?' && !camel_mime_is_lwsp(temp[i]))
+ g_string_insert(out, i, ' ');
+
+ if(start >= str)
+ str += len;
+
+ temp = NULL;
+ } while (start != NULL);
+
+ dd(printf("encode string %s\n\n", str));
+ str = out->str;
+ g_string_free(out, FALSE);
+ return (const char *)str;
}
/* how long a sequence of pre-encoded words should be less than, to attempt to
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]