diff options
author | hiro <hiro@ee746299-78ed-0310-b773-934348b2243d> | 2005-03-04 11:41:49 +0000 |
---|---|---|
committer | hiro <hiro@ee746299-78ed-0310-b773-934348b2243d> | 2005-03-04 11:41:49 +0000 |
commit | 00147be89513db41cdefb984b9d8e5e02e3f8ce6 (patch) | |
tree | 1066745852a3bc4db092442c5892994d798cb715 /src/codeconv.c | |
parent | c713812fef1340829e2142e177f0a60f2e9471b8 (diff) |
improved header MIME decoding.
git-svn-id: svn://sylpheed.sraoss.jp/sylpheed/trunk@147 ee746299-78ed-0310-b773-934348b2243d
Diffstat (limited to 'src/codeconv.c')
-rw-r--r-- | src/codeconv.c | 29 |
1 files changed, 9 insertions, 20 deletions
diff --git a/src/codeconv.c b/src/codeconv.c index 0d494919..8371486d 100644 --- a/src/codeconv.c +++ b/src/codeconv.c @@ -1543,31 +1543,25 @@ const gchar *conv_get_current_locale(void) gchar *conv_unmime_header(const gchar *str, const gchar *default_encoding) { - gchar *buf; - gint buflen; gchar *utf8_buf; + gint buflen; - if (is_ascii_str(str)) { - buflen = strlen(str) * 6 + 1; - Xalloca(buf, buflen, return NULL); - unmime_header(buf, str); - return g_strdup(buf); - } + if (is_ascii_str(str)) + return unmime_header(str); if (default_encoding) { utf8_buf = conv_codeset_strdup (str, default_encoding, CS_INTERNAL); if (utf8_buf) { - buflen = strlen(utf8_buf) * 6 + 1; - Xalloca(buf, buflen, - { g_free(utf8_buf); return NULL; }); - unmime_header(buf, utf8_buf); + gchar *decoded_str; + + decoded_str = unmime_header(utf8_buf); g_free(utf8_buf); - return g_strdup(buf); + return decoded_str; } } - buflen = strlen(str) * 6 + 1; + buflen = MIN(strlen(str) * 6 + 1, BUFFSIZE); Xalloca(utf8_buf, buflen, return NULL); if (conv_get_locale_charset() == C_EUC_JP) @@ -1575,12 +1569,7 @@ gchar *conv_unmime_header(const gchar *str, const gchar *default_encoding) else conv_localetodisp(utf8_buf, buflen, str); - buflen = strlen(utf8_buf) * 6 + 1; - Xalloca(buf, buflen, return NULL); - - unmime_header(buf, utf8_buf); - - return g_strdup(buf); + return unmime_header(utf8_buf); } #define MAX_LINELEN 76 |