From a6ef1d708bd89b669cd758f55b97b7488d55e934 Mon Sep 17 00:00:00 2001 From: Colin Leroy Date: Thu, 6 Jan 2011 15:38:07 +0000 Subject: [PATCH] 2011-01-06 [colin] 3.7.8cvs31 * src/addrharvest.c * src/codeconv.c * src/codeconv.h * src/compose.c * src/news.c * src/procheader.c * src/procmime.c * src/unmime.c * src/unmime.h Unmime headers differently whether they're addresses or not: It's useless to quote things containing commas if it's in subject, for example. (introduced in 3.7.8cvs26) --- ChangeLog | 15 +++++++++++++++ PATCHSETS | 1 + configure.ac | 2 +- src/addrharvest.c | 2 +- src/codeconv.c | 9 +++++---- src/codeconv.h | 3 ++- src/compose.c | 8 ++++---- src/news.c | 4 ++-- src/procheader.c | 36 +++++++++++++++++++++++++++++++----- src/procmime.c | 24 ++++++++++++------------ src/unmime.c | 4 ++-- src/unmime.h | 2 +- 12 files changed, 77 insertions(+), 33 deletions(-) diff --git a/ChangeLog b/ChangeLog index 4df7e310e..81e9ca840 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,18 @@ +2011-01-06 [colin] 3.7.8cvs31 + + * src/addrharvest.c + * src/codeconv.c + * src/codeconv.h + * src/compose.c + * src/news.c + * src/procheader.c + * src/procmime.c + * src/unmime.c + * src/unmime.h + Unmime headers differently whether they're addresses or not: + It's useless to quote things containing commas if it's in + subject, for example. (introduced in 3.7.8cvs26) + 2011-01-06 [colin] 3.7.8cvs30 * src/gtk/gtkaspell.c diff --git a/PATCHSETS b/PATCHSETS index 5f7d98192..1b73e6d69 100644 --- a/PATCHSETS +++ b/PATCHSETS @@ -4104,3 +4104,4 @@ ( cvs diff -u -r 1.8.2.29 -r 1.8.2.30 src/export.c; cvs diff -u -r 1.13.2.28 -r 1.13.2.29 src/import.c; cvs diff -u -r 1.94.2.210 -r 1.94.2.211 src/messageview.c; cvs diff -u -r 1.60.2.71 -r 1.60.2.72 src/prefs_actions.c; cvs diff -u -r 1.49.2.134 -r 1.49.2.135 src/procmime.c; cvs diff -u -r 1.9.2.70 -r 1.9.2.71 src/gtk/gtkaspell.c; cvs diff -u -r 1.1.2.45 -r 1.1.2.46 src/plugins/pgpinline/pgpinline.c; cvs diff -u -r 1.1.2.56 -r 1.1.2.57 src/plugins/pgpmime/pgpmime.c; cvs diff -u -r 1.1.2.8 -r 1.1.2.9 src/plugins/smime/smime.c; ) > 3.7.8cvs28.patchset ( cvs diff -u -r 1.100.2.76 -r 1.100.2.77 AUTHORS; cvs diff -u -r 1.654.2.4177 -r 1.654.2.4178 configure.ac; diff -u /dev/null po/lt.po; cvs diff -u -r 1.1.2.70 -r 1.1.2.71 src/gtk/authors.h; ) > 3.7.8cvs29.patchset ( cvs diff -u -r 1.94.2.211 -r 1.94.2.212 src/messageview.c; cvs diff -u -r 1.9.2.71 -r 1.9.2.72 src/gtk/gtkaspell.c; cvs diff -u -r 1.1.2.46 -r 1.1.2.47 src/plugins/pgpinline/pgpinline.c; ) > 3.7.8cvs30.patchset +( cvs diff -u -r 1.6.10.23 -r 1.6.10.24 src/addrharvest.c; cvs diff -u -r 1.65.2.70 -r 1.65.2.71 src/codeconv.c; cvs diff -u -r 1.15.2.24 -r 1.15.2.25 src/codeconv.h; cvs diff -u -r 1.382.2.565 -r 1.382.2.566 src/compose.c; cvs diff -u -r 1.101.2.62 -r 1.101.2.63 src/news.c; cvs diff -u -r 1.47.2.52 -r 1.47.2.53 src/procheader.c; cvs diff -u -r 1.49.2.135 -r 1.49.2.136 src/procmime.c; cvs diff -u -r 1.8.2.16 -r 1.8.2.17 src/unmime.c; cvs diff -u -r 1.2.10.7 -r 1.2.10.8 src/unmime.h; ) > 3.7.8cvs31.patchset diff --git a/configure.ac b/configure.ac index 4f1ecad70..151f5ec99 100644 --- a/configure.ac +++ b/configure.ac @@ -12,7 +12,7 @@ MINOR_VERSION=7 MICRO_VERSION=8 INTERFACE_AGE=0 BINARY_AGE=0 -EXTRA_VERSION=30 +EXTRA_VERSION=31 EXTRA_RELEASE= EXTRA_GTK2_VERSION= diff --git a/src/addrharvest.c b/src/addrharvest.c index 02919f598..1e4dcfe96 100644 --- a/src/addrharvest.c +++ b/src/addrharvest.c @@ -529,7 +529,7 @@ static void addrharvest_parse_address( } else { name = buffer; - name = conv_unmime_header(buffer, NULL); + name = conv_unmime_header(buffer, NULL, TRUE); } /* Insert into address book */ diff --git a/src/codeconv.c b/src/codeconv.c index 629e88ad5..b1666c049 100644 --- a/src/codeconv.c +++ b/src/codeconv.c @@ -1502,12 +1502,13 @@ static gboolean conv_is_ja_locale(void) return is_ja_locale != 0; } -gchar *conv_unmime_header(const gchar *str, const gchar *default_encoding) +gchar *conv_unmime_header(const gchar *str, const gchar *default_encoding, + gboolean addr_field) { gchar buf[BUFFSIZE]; if (is_ascii_str(str)) - return unmime_header(str); + return unmime_header(str, addr_field); if (default_encoding) { gchar *utf8_buf; @@ -1517,7 +1518,7 @@ gchar *conv_unmime_header(const gchar *str, const gchar *default_encoding) if (utf8_buf) { gchar *decoded_str; - decoded_str = unmime_header(utf8_buf); + decoded_str = unmime_header(utf8_buf, addr_field); g_free(utf8_buf); return decoded_str; } @@ -1528,7 +1529,7 @@ gchar *conv_unmime_header(const gchar *str, const gchar *default_encoding) else conv_localetodisp(buf, sizeof(buf), str); - return unmime_header(buf); + return unmime_header(buf, addr_field); } #define MAX_LINELEN 76 diff --git a/src/codeconv.h b/src/codeconv.h index 5856d876e..de7cbc5fa 100644 --- a/src/codeconv.h +++ b/src/codeconv.h @@ -196,7 +196,8 @@ const gchar *conv_get_outgoing_charset_str (void); const gchar *conv_get_current_locale (void); gchar *conv_unmime_header (const gchar *str, - const gchar *default_encoding); + const gchar *default_encoding, + gboolean addr_field); void conv_encode_header (gchar *dest, gint len, const gchar *src, diff --git a/src/compose.c b/src/compose.c index ca3532d6f..f9a51f652 100644 --- a/src/compose.c +++ b/src/compose.c @@ -2745,13 +2745,13 @@ static gint compose_parse_header(Compose *compose, MsgInfo *msginfo) if (hentry[H_REPLY_TO].body[0] != '\0') { compose->replyto = conv_unmime_header(hentry[H_REPLY_TO].body, - NULL); + NULL, TRUE); } g_free(hentry[H_REPLY_TO].body); hentry[H_REPLY_TO].body = NULL; } if (hentry[H_CC].body != NULL) { - compose->cc = conv_unmime_header(hentry[H_CC].body, NULL); + compose->cc = conv_unmime_header(hentry[H_CC].body, NULL, TRUE); g_free(hentry[H_CC].body); hentry[H_CC].body = NULL; } @@ -2768,7 +2768,7 @@ static gint compose_parse_header(Compose *compose, MsgInfo *msginfo) if (hentry[H_BCC].body != NULL) { if (compose->mode == COMPOSE_REEDIT) compose->bcc = - conv_unmime_header(hentry[H_BCC].body, NULL); + conv_unmime_header(hentry[H_BCC].body, NULL, TRUE); g_free(hentry[H_BCC].body); hentry[H_BCC].body = NULL; } @@ -2780,7 +2780,7 @@ static gint compose_parse_header(Compose *compose, MsgInfo *msginfo) if (hentry[H_FOLLOWUP_TO].body[0] != '\0') { compose->followup_to = conv_unmime_header(hentry[H_FOLLOWUP_TO].body, - NULL); + NULL, TRUE); } g_free(hentry[H_FOLLOWUP_TO].body); hentry[H_FOLLOWUP_TO].body = NULL; diff --git a/src/news.c b/src/news.c index 5457efa0c..040d15073 100644 --- a/src/news.c +++ b/src/news.c @@ -800,10 +800,10 @@ static MsgInfo *news_parse_xover(struct newsnntp_xover_resp_item *item) msginfo->date = g_strdup(item->ovr_date); msginfo->date_t = procheader_date_parse(NULL, item->ovr_date, 0); - msginfo->from = conv_unmime_header(item->ovr_author, NULL); + msginfo->from = conv_unmime_header(item->ovr_author, NULL, TRUE); msginfo->fromname = procheader_get_fromname(msginfo->from); - msginfo->subject = conv_unmime_header(item->ovr_subject, NULL); + msginfo->subject = conv_unmime_header(item->ovr_subject, NULL, TRUE); remove_return(msginfo->from); remove_return(msginfo->fromname); diff --git a/src/procheader.c b/src/procheader.c index 752013511..e14953ad6 100644 --- a/src/procheader.c +++ b/src/procheader.c @@ -256,11 +256,36 @@ gboolean procheader_headername_equal(char * hdr1, char * hdr2) header->name = "From:" header->body = "dinh@enseirb.fr" */ +static gboolean header_is_addr_field(const gchar *hdr) +{ + static char *addr_headers[] = { + "To:", + "Cc:", + "Bcc:", + "From:", + "Reply-To:", + "Followup-To:", + "Followup-and-Reply-To:", + "Disposition-Notification-To:", + "Return-Receipt-To:", + NULL}; + int i; + + if (!hdr) + return FALSE; + + for (i = 0; addr_headers[i] != NULL; i++) + if (!strcasecmp(hdr, addr_headers[i])) + return FALSE; + + return FALSE; +} Header * procheader_parse_header(gchar * buf) { gchar *p = buf; Header * header; + gboolean addr_field = FALSE; if ((*buf == ':') || (*buf == ' ')) return NULL; @@ -269,9 +294,10 @@ Header * procheader_parse_header(gchar * buf) if ((*p == ':') || (*p == ' ')) { header = g_new(Header, 1); header->name = g_strndup(buf, p - buf + 1); + addr_field = header_is_addr_field(header->name); p++; while (*p == ' ' || *p == '\t') p++; - header->body = conv_unmime_header(p, NULL); + header->body = conv_unmime_header(p, NULL, addr_field); return header; } } @@ -510,13 +536,13 @@ static MsgInfo *parse_stream(void *data, gboolean isstring, MsgFlags flags, break; case H_FROM: if (msginfo->from) break; - msginfo->from = conv_unmime_header(hp, NULL); + msginfo->from = conv_unmime_header(hp, NULL, TRUE); msginfo->fromname = procheader_get_fromname(msginfo->from); remove_return(msginfo->from); remove_return(msginfo->fromname); break; case H_TO: - tmp = conv_unmime_header(hp, NULL); + tmp = conv_unmime_header(hp, NULL, TRUE); remove_return(tmp); if (msginfo->to) { p = msginfo->to; @@ -528,7 +554,7 @@ static MsgInfo *parse_stream(void *data, gboolean isstring, MsgFlags flags, g_free(tmp); break; case H_CC: - tmp = conv_unmime_header(hp, NULL); + tmp = conv_unmime_header(hp, NULL, TRUE); remove_return(tmp); if (msginfo->cc) { p = msginfo->cc; @@ -550,7 +576,7 @@ static MsgInfo *parse_stream(void *data, gboolean isstring, MsgFlags flags, break; case H_SUBJECT: if (msginfo->subject) break; - msginfo->subject = conv_unmime_header(hp, NULL); + msginfo->subject = conv_unmime_header(hp, NULL, FALSE); unfold_line(msginfo->subject); break; case H_MSG_ID: diff --git a/src/procmime.c b/src/procmime.c index eaec403b8..4b13271ff 100644 --- a/src/procmime.c +++ b/src/procmime.c @@ -1386,32 +1386,32 @@ static void procmime_parse_message_rfc822(MimeInfo *mimeinfo, gboolean short_sca fseek(fp, mimeinfo->offset, SEEK_SET); procheader_get_header_fields(fp, hentry); if (hentry[0].body != NULL) { - tmp = conv_unmime_header(hentry[0].body, NULL); + tmp = conv_unmime_header(hentry[0].body, NULL, FALSE); g_free(hentry[0].body); hentry[0].body = tmp; } if (hentry[2].body != NULL) { - tmp = conv_unmime_header(hentry[2].body, NULL); + tmp = conv_unmime_header(hentry[2].body, NULL, FALSE); g_free(hentry[2].body); hentry[2].body = tmp; } if (hentry[4].body != NULL) { - tmp = conv_unmime_header(hentry[4].body, NULL); + tmp = conv_unmime_header(hentry[4].body, NULL, FALSE); g_free(hentry[4].body); hentry[4].body = tmp; } if (hentry[5].body != NULL) { - tmp = conv_unmime_header(hentry[5].body, NULL); + tmp = conv_unmime_header(hentry[5].body, NULL, FALSE); g_free(hentry[5].body); hentry[5].body = tmp; } if (hentry[7].body != NULL) { - tmp = conv_unmime_header(hentry[7].body, NULL); + tmp = conv_unmime_header(hentry[7].body, NULL, FALSE); g_free(hentry[7].body); hentry[7].body = tmp; } if (hentry[8].body != NULL) { - tmp = conv_unmime_header(hentry[8].body, NULL); + tmp = conv_unmime_header(hentry[8].body, NULL, FALSE); g_free(hentry[8].body); hentry[8].body = tmp; } @@ -1509,32 +1509,32 @@ bail: #define GET_HEADERS() { \ procheader_get_header_fields(fp, hentry); \ if (hentry[0].body != NULL) { \ - tmp = conv_unmime_header(hentry[0].body, NULL); \ + tmp = conv_unmime_header(hentry[0].body, NULL, FALSE); \ g_free(hentry[0].body); \ hentry[0].body = tmp; \ } \ if (hentry[2].body != NULL) { \ - tmp = conv_unmime_header(hentry[2].body, NULL); \ + tmp = conv_unmime_header(hentry[2].body, NULL, FALSE); \ g_free(hentry[2].body); \ hentry[2].body = tmp; \ } \ if (hentry[4].body != NULL) { \ - tmp = conv_unmime_header(hentry[4].body, NULL); \ + tmp = conv_unmime_header(hentry[4].body, NULL, FALSE); \ g_free(hentry[4].body); \ hentry[4].body = tmp; \ } \ if (hentry[5].body != NULL) { \ - tmp = conv_unmime_header(hentry[5].body, NULL); \ + tmp = conv_unmime_header(hentry[5].body, NULL, FALSE); \ g_free(hentry[5].body); \ hentry[5].body = tmp; \ } \ if (hentry[6].body != NULL) { \ - tmp = conv_unmime_header(hentry[6].body, NULL); \ + tmp = conv_unmime_header(hentry[6].body, NULL, FALSE); \ g_free(hentry[6].body); \ hentry[6].body = tmp; \ } \ if (hentry[7].body != NULL) { \ - tmp = conv_unmime_header(hentry[7].body, NULL); \ + tmp = conv_unmime_header(hentry[7].body, NULL, FALSE); \ g_free(hentry[7].body); \ hentry[7].body = tmp; \ } \ diff --git a/src/unmime.c b/src/unmime.c index adb40f2a3..6feb016fd 100644 --- a/src/unmime.c +++ b/src/unmime.c @@ -34,7 +34,7 @@ /* Decodes headers based on RFC2045 and RFC2047. */ -gchar *unmime_header(const gchar *encoded_str) +gchar *unmime_header(const gchar *encoded_str, gboolean addr_field) { const gchar *p = encoded_str; const gchar *eword_begin_p, *encoding_begin_p, *text_begin_p, @@ -133,7 +133,7 @@ gchar *unmime_header(const gchar *encoded_str) * We check there are no quotes just to be sure. If there * are, well, the comma won't pose a problem, probably. */ - if (strchr(decoded_text, ',') && !in_quote) { + if (addr_field && strchr(decoded_text, ',') && !in_quote) { gchar *tmp = g_strdup_printf("\"%s\"", decoded_text); g_free(decoded_text); decoded_text = tmp; diff --git a/src/unmime.h b/src/unmime.h index abba6c7f3..ff725cf47 100644 --- a/src/unmime.h +++ b/src/unmime.h @@ -22,6 +22,6 @@ #include -gchar *unmime_header (const gchar *encoded_str); +gchar *unmime_header (const gchar *encoded_str, gboolean addr_field); #endif /* __UNMIME_H__ */ -- 2.25.1