New function - even though its broken, we'll assume mailers send latin1

2000-08-31  Not Zed  <NotZed@HelixCode.com>

        * camel-mime-utils.c (append_latin1): New function - even though
        its broken, we'll assume mailers send latin1 headers instead of
        us-ascii.  We just have to encode high chars into utf-8.
        (header_decode_text): Call append_latin1 for appending unencoded
        text segments.

svn path=/trunk/; revision=5128
This commit is contained in:
Not Zed
2000-08-31 01:46:44 +00:00
committed by Michael Zucci
parent d4a67b5d3b
commit dbe98bddd3
2 changed files with 32 additions and 2 deletions

View File

@ -1,3 +1,11 @@
2000-08-31 Not Zed <NotZed@HelixCode.com>
* camel-mime-utils.c (append_latin1): New function - even though
its broken, we'll assume mailers send latin1 headers instead of
us-ascii. We just have to encode high chars into utf-8.
(header_decode_text): Call append_latin1 for appending unencoded
text segments.
2000-08-30 Jeffrey Stedfast <fejj@helixcode.com>
* providers/imap/camel-imap-store.c (camel_imap_fetch_command):

View File

@ -914,6 +914,28 @@ g_string_append_len(GString *st, const char *s, int l)
return g_string_append(st, tmp);
}
/* ok, a lot of mailers are BROKEN, and send iso-latin1 encoded
headers, when they should just be sticking to US-ASCII
according to the rfc's. Anyway, since the conversion to utf-8
is trivial, just do it here without iconv */
static GString *
append_latin1(GString *out, const char *in, int len)
{
unsigned int c;
while (len) {
c = (unsigned int)*in++;
len--;
if (c & 0x80) {
out = g_string_append_c(out, 0xc0 | (c>>6)); /* 110000xx */
out = g_string_append_c(out, 0x80 | (c&0x3f)); /* 10xxxxxx */
} else {
out = g_string_append_c(out, c);
}
}
return out;
}
/* decodes a simple text, rfc822 */
static char *
header_decode_text(const char *in, int inlen)
@ -934,11 +956,11 @@ header_decode_text(const char *in, int inlen)
out = g_string_append_len(out, decword, strlen(decword));
g_free (decword);
} else {
out = g_string_append_len(out, inptr, encend-inptr+2);
out = append_latin1(out, inptr, encend-inptr+2);
}
inptr = encend+2;
}
out = g_string_append_len(out, inptr, inend-inptr);
out = append_latin1(out, inptr, inend-inptr);
encstart = out->str;
g_string_free(out, FALSE);