3 messages in net.sourceforge.lists.courier-sqwebmailRe: [sqwebmail] [PATCH] Fixed attachm...
FromSent OnAttachments
Marcin SemeniukJun 30, 2006 3:49 am.patch
Sam VarshavchikJun 30, 2006 4:59 pm 
Marcin SemeniukJul 1, 2006 2:47 am.patch
Actions with this message:
Paste this link in email or IM:
Paste this link in email or IM:
Atom feed for this thread
Paste this URL into your reader:
Subject:Re: [sqwebmail] [PATCH] Fixed attachment name in Display actionActions...
From:Marcin Semeniuk (m.se@net.icm.edu.pl)
Date:Jul 1, 2006 2:47:21 am
List:net.sourceforge.lists.courier-sqwebmail
Attachments:

On Fri, Jun 30, 2006 at 07:59:33PM -0400, Sam Varshavchik wrote:

Marcin Semeniuk writes:

Hello Sam,

When user use Display attachment link in message view, and if browser don't know how to display it, Save As/Download window appear, but default name is meaningless number (it's probably cookie timestamp, but it doesn't matter). I know that user should use Download link to download attachment, but this bug is also available when user first display attachments (image for example), and then choose "File -> Save Page as" from browser menu or "Save Image as ..." from context menu and this is very common situation, so I made patch that set Content-Disposition: in HTTP headers, and now browser can set correct attachment name.

This is wrong. The Content-Disposition header MUST specify "inline" or "attachment". This is not optional, this is a structured MIME header.

All structured MIME headers follow the "Header: value[; [option=value]*]" format. "value" is not optional, it is mandatory.

You're right. Fixed.

best regards, Marcin Semeniuk

--- courier-0.53.2.20060630/webmail/folder.c 2006-07-01 02:44:51.000000000 +0200 +++ courier-0.53.2.20060630-work/webmail/folder.c 2006-07-01 11:40:13.000000000
+0200 @@ -4431,9 +4431,10 @@

static int download_func(const char *, size_t, void *);

-void disposition_attachment(FILE *fp, const char *p) +void disposition_attachment(FILE *fp, const char *p, int attachment) { - fprintf(fp, "Content-Disposition: attachment; filename=\""); + fprintf(fp, "Content-Disposition: %s; filename=\"", + attachment ? "attachment":"inline"); while (*p) { if (*p == '"' || *p == '\\') @@ -4512,11 +4513,14 @@

if (!p || !*p) p=content_name; if (!p || !*p) p="message.dat"; - disposition_attachment(stdout, p); + disposition_attachment(stdout, p, 1); content_type="application/octet-stream"; free(disposition_filename); + } else { + if (content_name && *content_name) + disposition_attachment(stdout, content_name, 0); } - + printf( content_name && *content_name ? "Content-Type: %s; charset=%s; name=\"%s\"\n\n":