aboutsummaryrefslogtreecommitdiffstats
path: root/camel/camel-folder-summary.c
diff options
context:
space:
mode:
author4 <NotZed@Ximian.com>2001-09-25 03:31:07 +0800
committerMichael Zucci <zucchi@src.gnome.org>2001-09-25 03:31:07 +0800
commit450e955e76ca9174658c0bb94e99e4174df2fe48 (patch)
tree6d708cc2b707fc24618cdcf6fdd9ed2539a2189e /camel/camel-folder-summary.c
parent8ac999f87feb11e3e33f0a5ab33d92f15e57c613 (diff)
downloadgsoc2013-evolution-450e955e76ca9174658c0bb94e99e4174df2fe48.tar.gz
gsoc2013-evolution-450e955e76ca9174658c0bb94e99e4174df2fe48.tar.zst
gsoc2013-evolution-450e955e76ca9174658c0bb94e99e4174df2fe48.zip
If the type is encoded, get the fallback charset from the message
2001-09-24 <NotZed@Ximian.com> * camel-filter-search.c (check_header): If the type is encoded, get the fallback charset from the message content-type. * camel-mime-part-utils.c (check_html_charset): Dont check for charset==null before calling charset_to_iconv. (simple_data_wrapper_construct_from_parser): " * camel-mime-message.c (process_header): Try use content-type charset param as the fallback charset. * camel-charset-map.c (camel_charset_to_iconv): Handle name == NULL, return NULL. * camel-folder-summary.c (camel_folder_summary_format_address): (camel_folder_summary_format_string): Made private again, removed #warning about it. Renamed to s/camel_folder//. (summary_format_string): Take default charset param. (camel_message_info_new_from_header, message_info_new): Decode content-type field to get the charset parameter to use as the default charset for decoding strings. * camel-search-private.c (camel_search_header_match): Pass NULL as the charset, the locale charset is always tried. (camel_search_header_match): Supply a default_charset parameter to be used with TYPE_ENCODED params. * camel-mime-utils.c (header_param): get rid of the g_strcasecmp crap. (header_set_param): Same here. (header_decode_param_list): And here. (header_decode_text): Totally rewritten. 30% of its size. If the word is not rfc2047 encoded, always try default_charset if supplied, if that fails, try locale charset if it exists, if that fails then assume latin1/7 bit ascii. (append_8bit): Changed to return FALSE if we can't convert for whatever reason, and dont append anything. * camel-mime-part.h (struct _CamelMimePart): Move content_type and headers out of the 'private' section. * camel-mime-part.c (get_headers): Dont do any conversion on the header. (process_header): Get the content-type charset as the fallback charset for decode_string. (construct_from_parser): IF we have a content-type header, process it before doing anything else, so we have access to a fallback charset for invalid headers. svn path=/trunk/; revision=13096
Diffstat (limited to 'camel/camel-folder-summary.c')
-rw-r--r--camel/camel-folder-summary.c56
1 files changed, 39 insertions, 17 deletions
diff --git a/camel/camel-folder-summary.c b/camel/camel-folder-summary.c
index f5f2131fa2..45c2fadae4 100644
--- a/camel/camel-folder-summary.c
+++ b/camel/camel-folder-summary.c
@@ -1382,11 +1382,8 @@ static CamelMessageContentInfo * content_info_new_from_message(CamelFolderSummar
return ci;
}
-#ifndef NO_WARNINGS
-#warning "These should be made private again, easy to fix (used in filter-driver)"
-#endif
-char *
-camel_folder_summary_format_address(struct _header_raw *h, const char *name)
+static char *
+summary_format_address(struct _header_raw *h, const char *name)
{
struct _header_address *addr;
const char *text;
@@ -1404,16 +1401,15 @@ camel_folder_summary_format_address(struct _header_raw *h, const char *name)
return ret;
}
-char *
-camel_folder_summary_format_string (struct _header_raw *h, const char *name)
+static char *
+summary_format_string (struct _header_raw *h, const char *name, const char *charset)
{
- const char *charset, *text;
+ const char *text;
text = header_raw_find (&h, name, NULL);
if (text) {
while (isspace ((unsigned) *text))
text++;
- charset = camel_charset_locale_name ();
return header_decode_string (text, charset);
} else {
return NULL;
@@ -1485,15 +1481,28 @@ message_info_new(CamelFolderSummary *s, struct _header_raw *h)
char *msgid;
int count;
char *subject, *from, *to, *cc, *mlist;
+ struct _header_content_type *ct = NULL;
+ const char *content, *charset = NULL;
mi = camel_folder_summary_info_new(s);
- subject = camel_folder_summary_format_string(h, "subject");
- from = camel_folder_summary_format_address(h, "from");
- to = camel_folder_summary_format_address(h, "to");
- cc = camel_folder_summary_format_address(h, "cc");
+ if ((content = header_raw_find(&h, "Content-Type", NULL))
+ && (ct = header_content_type_decode(content))
+ && (charset = header_content_type_param(ct, "charset"))
+ && (strcasecmp(charset, "us-ascii") == 0))
+ charset = NULL;
+
+ charset = camel_charset_to_iconv(charset);
+
+ subject = summary_format_string(h, "subject", charset);
+ from = summary_format_address(h, "from");
+ to = summary_format_address(h, "to");
+ cc = summary_format_address(h, "cc");
mlist = header_raw_check_mailing_list(&h);
+ if (ct)
+ header_content_type_unref(ct);
+
#ifdef DOEPOOLV
e_poolv_set(mi->strings, CAMEL_MESSAGE_INFO_SUBJECT, subject, TRUE);
e_poolv_set(mi->strings, CAMEL_MESSAGE_INFO_FROM, from, TRUE);
@@ -2340,13 +2349,26 @@ camel_message_info_new_from_header (struct _header_raw *header)
{
CamelMessageInfo *info;
char *subject, *from, *to, *cc, *mlist;
+ struct _header_content_type *ct = NULL;
+ const char *content, *charset = NULL;
+
+ if ((content = header_raw_find(&header, "Content-Type", NULL))
+ && (ct = header_content_type_decode(content))
+ && (charset = header_content_type_param(ct, "charset"))
+ && (strcasecmp(charset, "us-ascii") == 0))
+ charset = NULL;
+
+ charset = camel_charset_to_iconv(charset);
- subject = camel_folder_summary_format_string(header, "subject");
- from = camel_folder_summary_format_address(header, "from");
- to = camel_folder_summary_format_address(header, "to");
- cc = camel_folder_summary_format_address(header, "cc");
+ subject = summary_format_string(header, "subject", charset);
+ from = summary_format_address(header, "from");
+ to = summary_format_address(header, "to");
+ cc = summary_format_address(header, "cc");
mlist = header_raw_check_mailing_list(&header);
+ if (ct)
+ header_content_type_unref(ct);
+
info = camel_message_info_new();
camel_message_info_set_subject(info, subject);