2011-01-03 [colin] 3.7.8cvs26
authorColin Leroy <colin@colino.net>
Mon, 3 Jan 2011 20:22:13 +0000 (20:22 +0000)
committerColin Leroy <colin@colino.net>
Mon, 3 Jan 2011 20:22:13 +0000 (20:22 +0000)
* src/unmime.c
Better quote-checking when unmim-ing headers
that may have comas.

ChangeLog
PATCHSETS
configure.ac
src/unmime.c

index 6a6ff9b..2704f2f 100644 (file)
--- 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
index 3d31557..45e201f 100644 (file)
--- a/PATCHSETS
+++ b/PATCHSETS
 ( 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
index b227b76..764003b 100644 (file)
@@ -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=
 
index 6abd31e..adb40f2 100644 (file)
@@ -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;