Alexei Batyr' writes:
Meantime I've had to face another problem - OE cannot parse long attachment filenames, encoded by Sqwebmail, and replaces them by ATT00001.dat.Relevant headers are:Content-Type: application/octet-stream; charset=utf-8; name*0*="iso-8859-1''Enterprise%20Content%20Management%20%D1%85%D0%B7%D1%87"; name*1*="%D1%82%D0%BE.xls" Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename*0*=utf-8'en-us'Enterprise%20Content%20Management%20%D1%85%D0%B7; filename*1*=%D1%87%D1%82%D0%BE.xlsNote that "name" encoded differently than "filename", and specified charset (iso-8859-1) does not match real one (utf-8). Another difference, not so important in this case but potentially dangerous for very long encoded names, is that "name" tokens doesn't begin from new lines.
The attached patch should fix this.
I've tried to edit "name" manually and replace iso... by utf-8. OE still cannot recognize filename (Thunderbird have not any problems in both cases). Than I've tried to send the same file with Squirrelmail. OE successfully recognized filename, encoded as follows: Content-Type: application/vnd.ms-excel; name="=?utf-8?B?RW50ZXJwcmlzZSBDb250ZW50IE1hbmFnZW1lbnQg0YXQt9GH0YLQvi54bHM=?=" Content-Transfer-Encoding: base64 Content-Disposition: attachment;
I'm afraid I'm going to have to draw a hard line here. Character set encoding in MIME parameter fields is specified by RFC 2231. http://tools.ietf.org/html/rfc2231OE does not implement RFC 2231, and uses an older encoding which was originally defined for unstructured RFC 822 headers, which is specified in RFC 2047. As noted on its title page, RFC 2231 updates RFC 2047.
This is a failure of OE to implement RFC 2231 properly, and Squirrelmail is simply accomodating OE's failure.
Index: rfc2045/makemime.c
===================================================================
RCS file: /cvsroot/courier/libs/rfc2045/makemime.c,v
retrieving revision 1.16
diff -U3 -r1.16 makemime.c
--- rfc2045/makemime.c 27 Jun 2009 16:32:38 -0000 1.16
+++ rfc2045/makemime.c 22 Sep 2010 01:28:26 -0000
@@ -650,6 +650,7 @@
{
struct arg_list *a;
struct libmail_encode_info encode_info;
+const char *orig_charset=m->textplaincharset;
/* Determine encoding by reading the file, as follows:
**
@@ -682,7 +683,7 @@
if (strcmp(m->mimetype, "auto") == 0)
m->mimetype=
strcmp(m->mimeencoding, "base64") == 0
- ? (m->textplaincharset=0,
+ ? (orig_charset=0,
"application/octet-stream"):"text/plain";
}
@@ -690,12 +691,12 @@
fprintf(m->outputfp, "%s\n", a->arg);
fprintf(m->outputfp, "Content-Type: %s", m->mimetype);
- if (m->textplaincharset && *m->textplaincharset)
+ if (orig_charset && *orig_charset)
{
const char *c;
fprintf(m->outputfp, "; charset=\"");
- for (c=m->textplaincharset; *c; c++)
+ for (c=orig_charset; *c; c++)
{
if (*c != '"' && *c != '\\')
putc(*c, m->outputfp);
Index: webmail/attachments.c
===================================================================
RCS file: /cvsroot/courier/courier/webmail/attachments.c,v
retrieving revision 1.49
diff -U3 -r1.49 attachments.c
--- webmail/attachments.c 8 Nov 2009 18:14:47 -0000 1.49
+++ webmail/attachments.c 22 Sep 2010 01:28:26 -0000
@@ -912,19 +912,10 @@
const char *pp;
argvec[2]=(char *)calc_mime_type(cgi_attachfilename);
- n=3;
-
- if (strncasecmp(argvec[2], "text/", 5) == 0 ||
- strcasecmp(argvec[2], "auto") == 0)
- {
- argvec[3]="-C";
- argvec[4]=(char *)sqwebmail_content_charset;
- n=5;
- }
-
- argvec[n++]="-N";
- argvec[n++]=cgi_attachfilename ?
+ argvec[3]="-N";
+ argvec[4]=cgi_attachfilename ?
(char *)cgi_attachfilename:"filename.dat";
+ n=5;
pp=*cgi("attach_inline") ?
"Content-Disposition: inline":
@@ -943,6 +934,9 @@
}
}
+ argvec[n++]="-C";
+ argvec[n++]=(char *)sqwebmail_content_charset;
+
signal(SIGCHLD, SIG_DFL);
argvec[n++]="-";
pgpoCs8eUUy3c.pgp
Description: PGP signature
------------------------------------------------------------------------------ Start uncovering the many advantages of virtual appliances and start using them to simplify application deployment and accelerate your shift to cloud computing. http://p.sf.net/sfu/novell-sfdev2dev
_______________________________________________ courier-users mailing list [email protected] Unsubscribe: https://lists.sourceforge.net/lists/listinfo/courier-users
