[evolution-patches] 42710, non-utf8 getting to the display layer
- From: Not Zed <notzed ximian com>
- To: evolution-patches ximian com
- Subject: [evolution-patches] 42710, non-utf8 getting to the display layer
- Date: 16 May 2003 09:32:46 +0930
Since the internal api's are supposed to be utf8, this patch checks for
8 bit data in rfc822 'word's, like addresses, and so forth.
The bug 42710 has some more details
Z
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution/camel/ChangeLog,v
retrieving revision 1.1813
diff -u -3 -r1.1813 ChangeLog
--- ChangeLog 15 May 2003 01:00:56 -0000 1.1813
+++ ChangeLog 15 May 2003 09:49:46 -0000
@@ -1,3 +1,11 @@
+2003-05-15 Not Zed <NotZed Ximian com>
+
+ * camel-mime-utils.c (header_decode_word): Simplistic quick-fix
+ for #42170. Add a charset argument. If the data is 8 bit, try to
+ decode into the passed in charset (i.e. the message header?), at
+ worst, fall back to latin1, similarly to header_decode_text.
+ Fixed all callers to pass in a charset if available, or NULL.
+
2003-05-14 Not Zed <NotZed Ximian com>
** See bug #42540
Index: camel-mime-utils.c
===================================================================
RCS file: /cvs/gnome/evolution/camel/camel-mime-utils.c,v
retrieving revision 1.182
diff -u -3 -r1.182 camel-mime-utils.c
--- camel-mime-utils.c 2 May 2003 17:37:11 -0000 1.182
+++ camel-mime-utils.c 15 May 2003 09:49:49 -0000
@@ -1777,18 +1777,36 @@
}
static char *
-header_decode_word(const char **in)
+header_decode_word(const char **in, const char *charset)
{
- const char *inptr = *in;
+ char *out;
- header_decode_lwsp(&inptr);
- if (*inptr == '"') {
- *in = inptr;
- return header_decode_quoted_string(in);
- } else {
- *in = inptr;
- return header_decode_atom(in);
+ header_decode_lwsp(in);
+ if (**in == '"')
+ out = header_decode_quoted_string(in);
+ else
+ out = header_decode_atom(in);
+
+ /* FIXME: temporary workaround for non-ascii-data problem, see bug #42710 */
+ if (out) {
+ char *p;
+
+ for (p=out;*p;p++) {
+ if ((*p) & 0x80) {
+ GString *newstr = g_string_new("");
+
+ if (charset == NULL || !append_8bit(newstr, out, strlen(out), charset))
+ append_latin1(newstr, out, strlen(out));
+
+ g_free(out);
+ out = newstr->str;
+ g_string_free(newstr, FALSE);
+ break;
+ }
+ }
}
+
+ return out;
}
static char *
@@ -2282,7 +2300,7 @@
header_decode_lwsp(&inptr);
/* addr-spec */
- word = header_decode_word(&inptr);
+ word = header_decode_word(&inptr, NULL);
if (word) {
addr = g_string_append(addr, word);
header_decode_lwsp(&inptr);
@@ -2290,7 +2308,7 @@
while (*inptr == '.' && word) {
inptr++;
addr = g_string_append_c(addr, '.');
- word = header_decode_word(&inptr);
+ word = header_decode_word(&inptr, NULL);
if (word) {
addr = g_string_append(addr, word);
header_decode_lwsp(&inptr);
@@ -2351,7 +2369,7 @@
addr = g_string_new("");
/* for each address */
- pre = header_decode_word(&inptr);
+ pre = header_decode_word(&inptr, charset);
header_decode_lwsp(&inptr);
if (!(*inptr == '.' || *inptr == '@' || *inptr==',' || *inptr=='\0')) {
/* ',' and '\0' required incase it is a simple address, no @ domain part (buggy writer) */
@@ -2365,7 +2383,7 @@
last = pre;
g_free(text);
- pre = header_decode_word(&inptr);
+ pre = header_decode_word(&inptr, charset);
if (pre) {
size_t l = strlen (last);
size_t p = strlen (pre);
@@ -2383,7 +2401,7 @@
while (!pre && *inptr && *inptr != '<') {
w(g_warning("Working around stupid mailer bug #5: unescaped characters in names"));
name = g_string_append_c(name, *inptr++);
- pre = header_decode_word(&inptr);
+ pre = header_decode_word(&inptr, charset);
}
}
g_free(last);
@@ -2410,7 +2428,7 @@
w(g_warning("broken route-address, missing ':': %s", *in));
}
}
- pre = header_decode_word(&inptr);
+ pre = header_decode_word(&inptr, charset);
header_decode_lwsp(&inptr);
} else {
w(g_warning("broken address? %s", *in));
@@ -2427,7 +2445,7 @@
while (*inptr == '.' && pre) {
inptr++;
g_free(pre);
- pre = header_decode_word(&inptr);
+ pre = header_decode_word(&inptr, charset);
addr = g_string_append_c(addr, '.');
if (pre)
addr = g_string_append(addr, pre);
@@ -2550,7 +2568,7 @@
/* pre-scan, trying to work out format, discard results */
header_decode_lwsp(&inptr);
- while ( (pre = header_decode_word(&inptr)) ) {
+ while ( (pre = header_decode_word(&inptr, charset)) ) {
group = g_string_append(group, pre);
group = g_string_append(group, " ");
g_free(pre);
@@ -2665,7 +2683,7 @@
}
/* Eudora has been known to use <.@> as a content-id */
- if (!(buf = header_decode_word (&inptr)) && !strchr (".@", *inptr))
+ if (!(buf = header_decode_word (&inptr, NULL)) && !strchr (".@", *inptr))
return NULL;
addr = g_string_new ("");
@@ -2680,10 +2698,10 @@
if (!at) {
if (*inptr == '.') {
g_string_append_c (addr, *inptr++);
- buf = header_decode_word (&inptr);
+ buf = header_decode_word (&inptr, NULL);
} else if (*inptr == '@') {
g_string_append_c (addr, *inptr++);
- buf = header_decode_word (&inptr);
+ buf = header_decode_word (&inptr, NULL);
at = TRUE;
}
} else if (strchr (".[]", *inptr)) {
@@ -2756,7 +2774,7 @@
break;
}
} else {
- word = header_decode_word (&inptr);
+ word = header_decode_word (&inptr, NULL);
if (word)
g_free (word);
else if (*inptr != '\0')
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]