Bug 42825 - Pan breaks MIME charset headers (FreeBSD specific)
Summary: Pan breaks MIME charset headers (FreeBSD specific)
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: Normal Affects Only Me
Assignee: freebsd-gnome (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2002-09-16 10:50 UTC by matthias.andree
Modified: 2002-09-17 03:55 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description matthias.andree 2002-09-16 10:50:03 UTC
When Pan is used in localized environments, say, German, it emits
BROKEN character set declarations in postings. It writes headers like these:

MIME-Version: 1.0
Content-Type: text/plain; charset=iso8859-15

It should have written ...charset=iso-8859-15 instead. (mind the dash).

This must be attributed to FreeBSD's horrendously wrong decision to use X11
character set names for localization, which breaks compatibility, and harms
portability.

Impact: Pan postings don't get the non-ASCII characters of ISO 8859 right.
This leads to a mutilation of the article display in other software.

Fix: 

Solutions:

* fix FreeBSD to use proper locale names

* failing that, add code to Pan (backport from Pan2 which does the right
thing?) to normalize these charset declarations from FreeBSD's locale to use
IANA- registered charset names instead.

* remove the Pan port (not recommended)
Comment 1 Peter Pentchev freebsd_committer freebsd_triage 2002-09-16 10:59:52 UTC
Responsible Changed
From-To: freebsd-ports->gnome

Over to the maintainer group.
Comment 2 Joe Marcus Clarke freebsd_committer freebsd_triage 2002-09-16 21:08:44 UTC
Can you try the attached patch, and let me know if it works?  Thanks.

Joe

--- gmime/gmime-charset.c.orig	Mon Sep 16 16:07:29 2002
+++ gmime/gmime-charset.c	Mon Sep 16 16:07:36 2002
@@ -69,7 +69,7 @@
 		 * codeset  is  a  character  set or encoding identifier like
 		 * ISO-8859-1 or UTF-8.
 		 */
-		char *codeset, *p;
+		char *codeset, *p, *tmp;
 		
 		codeset = strchr (locale, '.');
 		if (codeset) {
@@ -77,6 +77,16 @@
 			
 			/* ; is a hack for debian systems and / is a hack for Solaris systems */
 			for (p = codeset; *p && !strchr ("@;/", *p); p++);
+
+			if (strstr(codeset, "iso") != NULL &&
+			    strlen(codeset) > 3) {
+			    tmp = (char *)g_malloc(strlen(codeset) + 1);
+			    strcpy(tmp, "iso");
+			    strcat(tmp, "-");
+			    strcat(tmp, (codeset + 3));
+			    codeset = tmp;
+			    g_free(tmp);
+			}
 			locale_charset = g_strndup (codeset, (unsigned) (p - codeset));
 			g_strdown (locale_charset);
 		} else {
-- 
Joe Marcus Clarke
FreeBSD GNOME Team	::	marcus@FreeBSD.org
http://www.FreeBSD.org/gnome
Comment 3 matthias.andree 2002-09-16 23:40:50 UTC
I hacked upon the previous patch and another one I was sent in private
mail, and this one finally works for me:

--- gmime/gmime-charset.c.orig	Tue Dec 18 21:09:40 2001
+++ gmime/gmime-charset.c	Tue Sep 17 00:34:46 2002
@@ -69,15 +69,25 @@
 		 * codeset  is  a  character  set or encoding identifier like
 		 * ISO-8859-1 or UTF-8.
 		 */
-		char *codeset, *p;
+		char *codeset, *tmp = NULL;
 		
 		codeset = strchr (locale, '.');
 		if (codeset) {
 			codeset++;
 			
+			if (strncasecmp(codeset, "iso", 3) == 0 &&
+			    strlen(codeset) > 3 && 
+			    strncasecmp(codeset, "iso-", 4) != 0) {
+			    tmp = (char *)g_malloc(strlen(codeset) + 2);
+			    strcpy(tmp, "iso");
+			    strcat(tmp, "-");
+			    strcat(tmp, (codeset + 3));
+			    codeset = tmp;
+			}
+
 			/* ; is a hack for debian systems and / is a hack for Solaris systems */
-			for (p = codeset; *p && !strchr ("@;/", *p); p++);
-			locale_charset = g_strndup (codeset, (unsigned) (p - codeset));
+			locale_charset = g_strndup (codeset, strcspn(codeset, "@;/"));
+			if (tmp) g_free(tmp);
 			g_strdown (locale_charset);
 		} else {
 			/* charset unknown */
Comment 4 Joe Marcus Clarke freebsd_committer freebsd_triage 2002-09-17 03:54:57 UTC
State Changed
From-To: open->closed

Fixed.  Thanks for your help and for reporting.