aboutsummaryrefslogtreecommitdiffstats
path: root/camel/camel-mime-utils.c
diff options
context:
space:
mode:
authorJeffrey Stedfast <fejj@ximian.com>2001-07-14 02:53:08 +0800
committerJeffrey Stedfast <fejj@src.gnome.org>2001-07-14 02:53:08 +0800
commitaabc9c14ea0e9dc152e1aee605eeaace2ba4d4f6 (patch)
tree86fc004ac681b0edd182d073fb8cce941835ece9 /camel/camel-mime-utils.c
parent3209f94b02a3d153df60f83d9595d32348fa7ae6 (diff)
downloadgsoc2013-evolution-aabc9c14ea0e9dc152e1aee605eeaace2ba4d4f6.tar
gsoc2013-evolution-aabc9c14ea0e9dc152e1aee605eeaace2ba4d4f6.tar.gz
gsoc2013-evolution-aabc9c14ea0e9dc152e1aee605eeaace2ba4d4f6.tar.bz2
gsoc2013-evolution-aabc9c14ea0e9dc152e1aee605eeaace2ba4d4f6.tar.lz
gsoc2013-evolution-aabc9c14ea0e9dc152e1aee605eeaace2ba4d4f6.tar.xz
gsoc2013-evolution-aabc9c14ea0e9dc152e1aee605eeaace2ba4d4f6.tar.zst
gsoc2013-evolution-aabc9c14ea0e9dc152e1aee605eeaace2ba4d4f6.zip
Added a hack to convert charsets in the format iso8859-1 to iso-8859-1
2001-07-13 Jeffrey Stedfast <fejj@ximian.com> * camel-mime-utils.c (rfc2047_decode_word): Added a hack to convert charsets in the format iso8859-1 to iso-8859-1 because it seems to be more iconv friendly. It has been reported that on some systems, iconv doesn't know about iso8859-1 while it *does* know about iso-8859-1. See bug #4530. svn path=/trunk/; revision=11094
Diffstat (limited to 'camel/camel-mime-utils.c')
-rw-r--r--camel/camel-mime-utils.c44
1 files changed, 27 insertions, 17 deletions
diff --git a/camel/camel-mime-utils.c b/camel/camel-mime-utils.c
index f051c0d596..357c183f02 100644
--- a/camel/camel-mime-utils.c
+++ b/camel/camel-mime-utils.c
@@ -934,8 +934,9 @@ rfc2047_decode_word(const char *in, int len)
inlen = quoted_decode(inptr+2, tmplen, decword);
break;
case 'B': {
- int state=0;
- unsigned int save=0;
+ int state = 0;
+ unsigned int save = 0;
+
inlen = base64_decode_step((char *)inptr+2, tmplen, decword, &state, &save);
/* if state != 0 then error? */
break;
@@ -945,29 +946,38 @@ rfc2047_decode_word(const char *in, int len)
return NULL;
}
d(printf("The encoded length = %d\n", inlen));
- if (inlen>0) {
+ if (inlen > 0) {
/* yuck, all this snot is to setup iconv! */
- tmplen = inptr-in-3;
- encname = alloca(tmplen+1);
- encname[tmplen]=0;
- memcpy(encname, in+2, tmplen);
-
+ tmplen = inptr - in - 3;
+ encname = alloca (tmplen + 2);
+
+ /* Hack to convert charsets like ISO8859-1 to iconv-friendly ISO-8859-1 */
+ if (!g_strncasecmp (in + 2, "iso", 3) && *(in + 5) != '-') {
+ memcpy (encname, in + 2, 3);
+ encname[3] = '-';
+ memcpy (encname + 4, in + 5, tmplen - 3);
+ tmplen++;
+ } else {
+ memcpy (encname, in + 2, tmplen);
+ }
+ encname[tmplen] = '\0';
+
inbuf = decword;
-
- outlen = inlen*6+16;
- outbase = alloca(outlen);
+
+ outlen = inlen * 6 + 16;
+ outbase = alloca (outlen);
outbuf = outbase;
-
+
/* TODO: Should this cache iconv converters? */
- ic = iconv_open("UTF-8", encname);
+ ic = iconv_open ("UTF-8", encname);
if (ic != (iconv_t)-1) {
- ret = iconv(ic, &inbuf, &inlen, &outbuf, &outlen);
+ ret = iconv (ic, &inbuf, &inlen, &outbuf, &outlen);
if (ret>=0) {
- iconv(ic, NULL, 0, &outbuf, &outlen);
+ iconv (ic, NULL, 0, &outbuf, &outlen);
*outbuf = 0;
- decoded = g_strdup(outbase);
+ decoded = g_strdup (outbase);
}
- iconv_close(ic);
+ iconv_close (ic);
} else {
w(g_warning("Cannot decode charset, header display may be corrupt: %s: %s",
encname, strerror(errno)));