talons

Fork of Claws Mail https://www.claws-mail
Log | Files | Refs | README | LICENSE

commit 532f02fadc27196fc1bd07cb9aab4656868c1649
parent 013e94ff3653aa6025e7f0992a3519308d952a01
Author: Colin Leroy <colin@colino.net>
Date:   Mon,  3 Jan 2011 20:22:13 +0000

2011-01-03 [colin]	3.7.8cvs26

	* src/unmime.c
		Better quote-checking when unmim-ing headers
		that may have comas.

Diffstat:
MChangeLog | 6++++++
MPATCHSETS | 1+
Mconfigure.ac | 2+-
Msrc/unmime.c | 16+++++++++++++++-
4 files changed, 23 insertions(+), 2 deletions(-)

diff --git a/ChangeLog b/ChangeLog @@ -1,3 +1,9 @@ +2011-01-03 [colin] 3.7.8cvs26 + + * src/unmime.c + Better quote-checking when unmim-ing headers + that may have comas. + 2011-01-03 [colin] 3.7.8cvs25 * src/unmime.c diff --git a/PATCHSETS b/PATCHSETS @@ -4099,3 +4099,4 @@ ( cvs diff -u -r 1.382.2.564 -r 1.382.2.565 src/compose.c; ) > 3.7.8cvs23.patchset ( cvs diff -u -r 1.47.2.51 -r 1.47.2.52 src/procheader.c; ) > 3.7.8cvs24.patchset ( cvs diff -u -r 1.8.2.14 -r 1.8.2.15 src/unmime.c; ) > 3.7.8cvs25.patchset +( cvs diff -u -r 1.8.2.15 -r 1.8.2.16 src/unmime.c; ) > 3.7.8cvs26.patchset diff --git a/configure.ac b/configure.ac @@ -12,7 +12,7 @@ MINOR_VERSION=7 MICRO_VERSION=8 INTERFACE_AGE=0 BINARY_AGE=0 -EXTRA_VERSION=25 +EXTRA_VERSION=26 EXTRA_RELEASE= EXTRA_GTK2_VERSION= diff --git a/src/unmime.c b/src/unmime.c @@ -45,11 +45,13 @@ gchar *unmime_header(const gchar *encoded_str) GString *outbuf; gchar *out_str; gsize out_len; + int in_quote = FALSE; outbuf = g_string_sized_new(strlen(encoded_str) * 2); while (*p != '\0') { gchar *decoded_text = NULL; + const gchar *quote_p; gint len; eword_begin_p = strstr(p, ENCODED_WORD_BEGIN); @@ -57,6 +59,18 @@ gchar *unmime_header(const gchar *encoded_str) g_string_append(outbuf, p); break; } + + quote_p = p; + while ((quote_p = strchr(quote_p, '"')) != NULL) { + if (quote_p && quote_p < eword_begin_p) { + /* Found a quote before the encoded word. */ + in_quote = !in_quote; + quote_p++; + } + if (quote_p >= eword_begin_p) + break; + } + encoding_begin_p = strchr(eword_begin_p + 2, '?'); if (!encoding_begin_p) { g_string_append(outbuf, p); @@ -119,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, ',') && !strchr(decoded_text, '"')) { + if (strchr(decoded_text, ',') && !in_quote) { gchar *tmp = g_strdup_printf("\"%s\"", decoded_text); g_free(decoded_text); decoded_text = tmp;