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 6a6ff9b3f60e37b45405c9fc80f7079e8d3a9c25..2704f2f6af493f99af6fb77ef5fc47d9d0619a20 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 3d315571f47e6634c937fc240dffc3f904b13200..45e201feb4e8669a631aeb4d224c79db916014ec 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 b227b76e77e35df7af54a540eb0b5294671cc952..764003b466eed8a7dfee63a86a59e4e1be7be186 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 6abd31ebd94f2bb4ae339605ce6f7138ac0d2990..adb40f2a3028c6a61a67a4c07506348130489615 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;