Patch: fix parsing of broken rfc2047 recipient headers from gmail
- From: José Dapena Paz <jdapena igalia com>
- To: tinymail-devel-list <tinymail-devel-list gnome org>
- Subject: Patch: fix parsing of broken rfc2047 recipient headers from gmail
- Date: Tue, 03 Jun 2008 17:39:38 +0200
Hi,
This patch fixes in camel lite parsing of rfc2047 recipient headers as
sent by gmail imap server.
Example of failing message:
=?ISO-8859-1?Q?Jos=E9_Dapena_Paz_<nospam no spam>?=
Closing the rfc2047 in the end of the header is a not valid header. The
patch moves the final ?= to the fullname part.
Changelog would be:
* libtinymail-camel/camel-lite/camel/camel-mime-utils.c:
* Parse properly broken rfc2047 recipient headers sent from gmail imap.
--
José Dapena Paz <jdapena igalia com>
Igalia
Index: libtinymail-camel/camel-lite/camel/camel-mime-utils.c
===================================================================
--- libtinymail-camel/camel-lite/camel/camel-mime-utils.c (revision 3686)
+++ libtinymail-camel/camel-lite/camel/camel-mime-utils.c (working copy)
@@ -2462,6 +2462,24 @@
*(word) '<' [ *('@' domain ) ':' ] word *( '.' word) @ domain
*/
+static void
+fix_broken_rfc2047 (const char **in)
+{
+ gchar *p, *q, *r;
+
+ p = g_strrstr (*in, "<");
+ if (!p)
+ return;
+ q = g_strrstr (p, ">");
+ if (!q) return;
+ r = g_strrstr (q, "?=");
+ if (!r) return;
+
+ memmove (p+2, p, r-p);
+ p[0] = '?';
+ p[1] = '=';
+}
+
static struct _camel_header_address *
header_decode_mailbox(const char **in, const char *charset)
{
@@ -2475,6 +2493,11 @@
addr = g_string_new("");
+ if (strncmp (inptr, "=?", 2)==0) {
+ /* check if we've got a wrong string as gmail sends and fix it.*/
+ fix_broken_rfc2047 (in);
+ }
+
/* for each address */
pre = header_decode_word (&inptr);
header_decode_lwsp(&inptr);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]