[gmime] Rfc2047 encode ctrl characters in header values



commit 073c405c02074e6ce60583cac6b71e70821c97d4
Author: Jeffrey Stedfast <fejj gnome org>
Date:   Wed Jun 13 20:01:01 2012 -0400

    Rfc2047 encode ctrl characters in header values
    
    2012-06-13  Jeffrey Stedfast  <fejj gnome org>
    
    	* gmime/gmime-utils.c (rfc2047_encode_get_rfc822_words): Use
    	is_blank() instead of is_lwsp() so that we only treat space and
    	tab as word delimiters (we want to rfc2047 encode \r's and
    	\n's). Check for ctrl characters when deciding what the type and
    	encoding of the word is.

 ChangeLog           |    8 ++++++++
 gmime/gmime-utils.c |   16 ++++++++++------
 2 files changed, 18 insertions(+), 6 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 70a0026..5bc4d3e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,13 @@
 2012-06-13  Jeffrey Stedfast  <fejj gnome org>
 
+	* gmime/gmime-utils.c (rfc2047_encode_get_rfc822_words): Use
+	is_blank() instead of is_lwsp() so that we only treat space and
+	tab as word delimiters (we want to rfc2047 encode \r's and
+	\n's). Check for ctrl characters when deciding what the type and
+	encoding of the word is.
+
+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
diff --git a/gmime/gmime-utils.c b/gmime/gmime-utils.c
index 40f888c..470c8ce 100644
--- a/gmime/gmime-utils.c
+++ b/gmime/gmime-utils.c
@@ -2498,7 +2498,7 @@ rfc2047_encode_get_rfc822_words (const char *in, gboolean phrase)
 		
 		inptr = newinptr;
 		
-		if (c < 256 && is_lwsp (c)) {
+		if (c < 256 && is_blank (c)) {
 			if (count > 0) {
 				word = rfc822_word_new ();
 				word->next = NULL;
@@ -2517,14 +2517,18 @@ rfc2047_encode_get_rfc822_words (const char *in, gboolean phrase)
 			encoding = 0;
 		} else {
 			count++;
-			if (phrase && c < 128) {
-				/* phrases can have qstring words */
-				if (!is_atom (c))
+			if (c < 128) {
+				if (is_ctrl (c)) {
+					type = WORD_2047;
+					encoding = MAX (encoding, 1);
+				} else if (phrase && !is_atom (c)) {
+					/* phrases can have qstring words */
 					type = MAX (type, WORD_QSTRING);
-			} else if (c > 127 && c < 256) {
+				}
+			} else if (c < 256) {
 				type = WORD_2047;
 				encoding = MAX (encoding, 1);
-			} else if (c >= 256) {
+			} else {
 				type = WORD_2047;
 				encoding = 2;
 			}



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