2006-03-26 [colin] 2.0.0cvs172
[claws.git] / src / procheader.c
index c2e151e2b7ba7eb0dae3aeb703222a5758277818..bca7e19ef8cfc72f79dbcfe6ca7eaaec65a950ee 100644 (file)
@@ -453,7 +453,22 @@ static MsgInfo *parse_stream(void *data, gboolean isstring, MsgFlags flags,
                        if (msginfo->date) break;
                        msginfo->date_t =
                                procheader_date_parse(NULL, hp, 0);
-                       msginfo->date = g_strdup(hp);
+                       if (g_utf8_validate(hp, -1, NULL)) {
+                               msginfo->date = g_strdup(hp);
+                       } else {
+                               gchar *utf = conv_codeset_strdup(
+                                       hp, 
+                                       conv_get_locale_charset_str_no_utf8(),
+                                       CS_INTERNAL);
+                               if (utf == NULL || 
+                                   !g_utf8_validate(utf, -1, NULL)) {
+                                       g_free(utf);
+                                       utf = g_malloc(strlen(buf)*2+1);
+                                       conv_localetodisp(utf, 
+                                               strlen(hp)*2+1, hp);
+                               }
+                               msginfo->date = utf;
+                       }
                        break;
                case H_FROM:
                        if (msginfo->from) break;