[gmime/gmime-2-4] Fixed folding of headers containing really long words



commit aa665f4977c67f1f73d08160abc92d998b15be38
Author: Jeffrey Stedfast <fejj gnome org>
Date:   Wed Jun 13 19:33:21 2012 -0400

    Fixed folding of headers containing really long words
    
    2012-06-13  Jeffrey Stedfast  <fejj gnome org>
    
    	* 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 97bca58..c36e6d3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,14 @@
 2012-06-13  Jeffrey Stedfast  <fejj gnome org>
 
+	* 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  <fejj gnome org>
+
 	* gmime/gmime-message.c: When setting a header, make sure to
 	always clear the header list cache of the toplevel mime_part as
 	well.
diff --git a/gmime/gmime-utils.c b/gmime/gmime-utils.c
index 83d7e0f..9f1195e 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;



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]