[gmime/gmime-2-4] Rfc2047 encode ctrl characters in header values



commit 55e8ef63c1d91d037ac2d5a5ec9de63cb3f7c619
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 c36e6d3..d674d2c 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 9f1195e..4563a80 100644
--- a/gmime/gmime-utils.c
+++ b/gmime/gmime-utils.c
@@ -2499,7 +2499,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;
@@ -2518,14 +2518,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]