RFC2047 encoding and header wrap

Laurent Wacrenier <[email protected]> Wed, 4 Aug 2004 16:25:13 +0200
Newsgroups gmane.mail.sqwebmail
Message-ID <[email protected]>
Hi,

 I'm using sqwebmail 4.0.6. When I send a message with a long Subject
header containing non ASCII characters, the header is RFC2047 encoded
and wrapped. The problem is that the split may appear into the RFC2047
atom.

For example, when I send a message with the Subject,
  àÚâÀ éÚêë îï Îö ùûÌ Â Ê Î Ô Û Ä Ë Ï Ö Ü ç Ç 
It is converted to the two lines :

Subject: =?UTF-8?B?w6DDqMOiw6Qgw6nDqMOqw6sgw67DryDDtMO2IMO5w7vDvCDDgiDDiiDD
  jiDDlCDD?= =?UTF-8?B?myDDhCDDiyDDjyDDliDDnCDDpyDDhyDDnw==?=

Which is illegal and cause reading trouble to some mail agent
(including sqwebmail)

See below for a patch who allow the split only on spaces, the header
become :

Subject: =?UTF-8?B?w6DDqMOiw6Qgw6nDqMOqw6sgw67DryDDtMO2IMO5w7vDvCDDgiDDiiDDjiDDlCDD?=
  =?UTF-8?B?myDDhCDDiyDDjyDDliDDnCDDpyDDhyDDnw==?=


--- sqwebmail/newmsg_create.c.orig	Wed Aug  4 16:10:53 2004
+++ sqwebmail/newmsg_create.c	Wed Aug  4 16:11:27 2004
@@ -121,10 +121,9 @@
 
 		for (spc=0, i=0; hdr[i]; i++)
 		{
-			if (i + offset >= 75)
+			if (i + offset >= 75 && spc)
 			{
-				if (spc)
-					i = spc;
+			        i = spc;
 				offset = 0;
 				break;
 			}