[Evolution-hackers] There's no need to be so hard on iconv



In case iconv does not succeed in decoding for example the Subject
header, it returns the base64 encoded one. That is is obviously not
readable at all. The decoded one after base64 decoding (which did
succeed in my test case) or whatever iconv could recover from it, sounds
like a better option.

This changeset (patch) on camel-mime-utils.c deals with the error
situation (in case iconv did not return -1) by returning what(ever)
iconv could recover from the string:

http://tinymail.org/trac/tinymail/changeset/2830#file2

I attached:

svn diff libtinymail-camel/camel-lite/camel/camel-mime-utils.c -r 2829 > /home/pvanhoof/diff.diff

This is the Subject line of my test target:

Subject: =?ISO-2022-JP?B?GyRCM048QiRLOkdEY0Z8NWsbKEI=?=

=?ISO-2022-JP?B?GyRCIzJLfDFfIUFGfEonJCQkRyQqRU8kN0NXJDckXiQ5ISMlYSE8GyhC?=
        =?ISO-2022-JP?B?GyRCJWslXiUsJTglcxsoQg==?=


I also opened a bug for this one:
http://bugzilla.gnome.org/show_bug.cgi?id=485677


-- 
Philip Van Hoof, software developer
home: me at pvanhoof dot be 
gnome: pvanhoof at gnome dot org 
http://www.pvanhoof.be/blog



Index: libtinymail-camel/camel-lite/camel/camel-mime-utils.c
===================================================================
--- libtinymail-camel/camel-lite/camel/camel-mime-utils.c	(revision 2829)
+++ libtinymail-camel/camel-lite/camel/camel-mime-utils.c	(working copy)
@@ -904,7 +904,14 @@
 					e_iconv (ic, NULL, 0, &outbuf, &outlen);
 					*outbuf = 0;
 					decoded = g_strdup (outbase);
+				} else {
+					perror ("iconv");
+					e_iconv (ic, NULL, 0, &outbuf, &outlen);
+					*outbuf = 0;
+					decoded = g_strdup (outbase);
+					/* decoded = g_strdup (inbuf); */
 				}
+
 				e_iconv_close (ic);
 			} else {
 				w(g_warning ("Cannot decode charset, header display may be corrupt: %s: %s",


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