[evolution-patches] fix for bug #62771 (User-Agent doesn't get decoded in mail view)



http://bugzilla.ximian.com/show_bug.cgi?id=62771

2-part patch. 

implemented another decode function (maybe it can be merged into
header_decode_text?) that decodes structured header bodies that can
contain comments

also had to fix the mailer code to actually decode the User-Agent/X-
Mailer header values using this new function (it didn't even try to
decode before)

Jeff

-- 
Jeffrey Stedfast
Evolution Hacker - Novell, Inc.
fejj ximian com  - www.novell.com
? 24026.patch
? 62136.patch
? 62771-camel.patch
? body
? body.c
? body.txt
? body2.txt
? build.patch
? charset-map.c
? charset-map.diff
? class.sh
? cmsutil.c
? date.patch
? flags
? foo
? foo.txt
? foo2.txt
? gw-body.txt
? iso
? iso.c
? lang.patch
? namespace.sh
? smime
? providers/imap4/reconnect.patch
? tests/data/camel-mime-tests.tar.gz
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution/camel/ChangeLog,v
retrieving revision 1.2237
diff -u -r1.2237 ChangeLog
--- ChangeLog	6 Aug 2004 19:24:03 -0000	1.2237
+++ ChangeLog	10 Aug 2004 19:09:10 -0000
@@ -1,3 +1,11 @@
+2004-08-10  Jeffrey Stedfast  <fejj novell com>
+
+	Fix for bug #62771
+
+	* camel-mime-utils.c (header_decode_ctext): New function to decode
+	ctext field bodies.
+	(camel_header_decode_ctext): public interface for above.
+
 2004-08-06  Jeffrey Stedfast  <fejj novell com>
 
 	* providers/imap4/camel-imap4-summary.c (untagged_fetch_all): Call
Index: camel-mime-utils.c
===================================================================
RCS file: /cvs/gnome/evolution/camel/camel-mime-utils.c,v
retrieving revision 1.212
diff -u -r1.212 camel-mime-utils.c
--- camel-mime-utils.c	30 Jul 2004 15:30:38 -0000	1.212
+++ camel-mime-utils.c	10 Aug 2004 19:09:11 -0000
@@ -1118,6 +1118,68 @@
 	
 }
 
+static char *
+header_decode_ctext (const char *in, size_t inlen, const char *default_charset)
+{
+	const char *inptr, *inend, *start, *chunk, *locale_charset;
+	char *dword = NULL;
+	GString *out;
+	
+	locale_charset = e_iconv_locale_charset ();
+	
+	out = g_string_new ("");
+	inptr = in;
+	inend = inptr + inlen;
+	chunk = NULL;
+	
+	while (inptr < inend) {
+		start = inptr;
+		while (inptr < inend && !camel_mime_is_atom (*inptr))
+			inptr++;
+		
+		if (inptr == inend) {
+			g_string_append_len (out, start, inptr - start);
+			break;
+		} else if (dword == NULL) {
+			g_string_append_len (out, start, inptr - start);
+		} else {
+			chunk = start;
+		}
+		
+		start = inptr;
+		while (inptr < inend && camel_mime_is_atom (*inptr))
+			inptr++;
+		
+		dword = rfc2047_decode_word (start, inptr - start);
+		if (dword) {
+			g_string_append (out, dword);
+			g_free (dword);
+		} else {
+			if (!chunk)
+				chunk = start;
+			
+			if ((default_charset == NULL || !append_8bit (out, chunk, inptr - chunk, default_charset))
+			    && (locale_charset == NULL || !append_8bit (out, chunk, inptr - chunk, locale_charset)))
+				append_latin1 (out, chunk, inptr - chunk);
+		}
+		
+		chunk = NULL;
+	}
+	
+	dword = out->str;
+	g_string_free (out, FALSE);
+	
+	return dword;
+}
+
+char *
+camel_header_decode_ctext (const char *in, const char *default_charset)
+{
+	if (in == NULL)
+		return NULL;
+	return header_decode_ctext (in, strlen (in), default_charset);
+}
+
 /* decodes a simple text, rfc822 + rfc2047 */
 static char *
 header_decode_text (const char *in, size_t inlen, const char *default_charset)
Index: camel-mime-utils.h
===================================================================
RCS file: /cvs/gnome/evolution/camel/camel-mime-utils.h,v
retrieving revision 1.56
diff -u -r1.56 camel-mime-utils.h
--- camel-mime-utils.h	18 Jun 2004 20:07:09 -0000	1.56
+++ camel-mime-utils.h	10 Aug 2004 19:09:11 -0000
@@ -194,6 +194,9 @@
 char *camel_header_decode_string (const char *in, const char *default_charset);
 char *camel_header_encode_string (const unsigned char *in);
 
+/* decode ctext */
+char *camel_header_decode_ctext (const char *in, const char *default_charset);
+
 /* encode a phrase, like the real name of an address */
 char *camel_header_encode_phrase (const unsigned char *in);
 
? 55303-2.patch
? 55303.patch
? 62377.patch
? 62771-mailer.patch
? oops.patch
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution/mail/ChangeLog,v
retrieving revision 1.3430
diff -u -r1.3430 ChangeLog
--- ChangeLog	10 Aug 2004 19:10:06 -0000	1.3430
+++ ChangeLog	10 Aug 2004 19:11:07 -0000
@@ -1,3 +1,12 @@
+2004-08-10  Jeffrey Stedfast  <fejj novell com>
+
+	Partial fix for bug #62771
+
+	* em-format-quote.c (emfq_format_header): Same.
+
+	* em-format-html.c (efh_format_header): Decode the
+	X-Mailer/User-Agent headers.
+
 2004-08-06  Jeffrey Stedfast  <fejj novell com>
 
 	* em-folder-tree-model.c (em_folder_tree_model_get_selected):
Index: em-format-html.c
===================================================================
RCS file: /cvs/gnome/evolution/mail/em-format-html.c,v
retrieving revision 1.62
diff -u -r1.62 em-format-html.c
--- em-format-html.c	10 Jul 2004 01:31:04 -0000	1.62
+++ em-format-html.c	10 Aug 2004 19:11:07 -0000
@@ -1552,7 +1552,7 @@
 	} else if (!strcmp(name, "x-evolution-mailer")) {
 		/* pseudo-header */
 		label = _("Mailer");
-		txt = header->value;
+		txt = value = camel_header_decode_ctext (header->value, charset);
 		flags |= EM_FORMAT_HEADER_BOLD;
 	} else if (!strcmp(name, "date") || !strcmp(name, "resent-date")) {
 		int msg_offset, local_tz;
Index: em-format-quote.c
===================================================================
RCS file: /cvs/gnome/evolution/mail/em-format-quote.c,v
retrieving revision 1.12
diff -u -r1.12 em-format-quote.c
--- em-format-quote.c	10 Jul 2004 01:31:04 -0000	1.12
+++ em-format-quote.c	10 Aug 2004 19:11:07 -0000
@@ -309,6 +309,8 @@
 			if (!(txt = camel_medium_get_header (part, "user-agent")))
 				return;
 		
+		txt = value = camel_header_decode_ctext (txt, charset);
+		
 		label = _("Mailer");
 		flags |= EM_FORMAT_HEADER_BOLD;
 	} else if (!strcmp (name, "date") || !strcmp (name, "resent-date")) {

Attachment: smime.p7s
Description: S/MIME cryptographic signature



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