From aa665f4977c67f1f73d08160abc92d998b15be38 Mon Sep 17 00:00:00 2001 From: Jeffrey Stedfast Date: Wed, 13 Jun 2012 19:33:21 -0400 Subject: Fixed folding of headers containing really long words 2012-06-13 Jeffrey Stedfast * gmime/gmime-utils.c (rfc2047_encode_get_rfc822_words): When breaking up really long atom tokens, change the word type to RFC2047 so that we encode them, thus preventing forced header folding which cannot be unmunged. (header_fold): Fixed for cases where the first word in a header is 68 chars. (Note: this fix is largely unnecessary due to the above fix) --- ChangeLog | 9 +++++++++ gmime/gmime-utils.c | 8 ++++++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 97bca589..c36e6d3e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2012-06-13 Jeffrey Stedfast + + * gmime/gmime-utils.c (rfc2047_encode_get_rfc822_words): When + breaking up really long atom tokens, change the word type to + RFC2047 so that we encode them, thus preventing forced header + folding which cannot be unmunged. + (header_fold): Fixed for cases where the first word in a header is + 68 chars. (Note: this fix is largely unnecessary due to the above fix) + 2012-06-13 Jeffrey Stedfast * gmime/gmime-message.c: When setting a header, make sure to diff --git a/gmime/gmime-utils.c b/gmime/gmime-utils.c index 83d7e0fc..9f1195e6 100644 --- a/gmime/gmime-utils.c +++ b/gmime/gmime-utils.c @@ -1182,7 +1182,7 @@ header_fold (const char *in, gboolean structured) len = strcspn (inptr, " \t\n"); if (len > 1 && outlen + len > GMIME_FOLD_LEN) { - if (outlen > 1 && out->len > fieldlen + 2) { + if (outlen > 1 && out->len >= fieldlen + 2) { if (last_was_lwsp) { if (structured) out->str[out->len - 1] = '\t'; @@ -1190,6 +1190,7 @@ header_fold (const char *in, gboolean structured) g_string_insert_c (out, out->len - 1, '\n'); } else g_string_append (out, "\n\t"); + outlen = 1; } @@ -1747,7 +1748,7 @@ quoted_decode (const unsigned char *in, size_t len, unsigned char *out, int *sta goto decode; } - + saved = 0; need = 0; @@ -2530,6 +2531,9 @@ rfc2047_encode_get_rfc822_words (const char *in, gboolean phrase) } if (count >= GMIME_FOLD_PREENCODED) { + if (type == WORD_ATOM) + type = WORD_2047; + word = rfc822_word_new (); word->next = NULL; word->start = start; -- cgit v1.2.1