From 395d898e7467fb4c20fce618a3d14c0ec631557b Mon Sep 17 00:00:00 2001 From: Eduardo Chappa Date: Sun, 27 Jan 2019 19:57:26 -0700 Subject: * When saving an attachment, do an extra effort to save the name of the file, if this is in the Content-Disposition parameter. Based on a report by Holger Trapp. --- pith/save.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'pith') diff --git a/pith/save.c b/pith/save.c index 83a1d570..568501e4 100644 --- a/pith/save.c +++ b/pith/save.c @@ -1573,7 +1573,7 @@ save_ex_mask_types(char *hdr, long unsigned int *len, gf_io_t pc) char *s = NULL; if(!struncmp(hdr, "content-type:", 13)) - s = "Content-Type: Text/Plain; charset=US-ASCII\015\012X-"; + s = "Content-Type: Text/Plain; charset=UTF-8\015\012X-"; else if(!struncmp(hdr, "content-description:", 20)) s = "Content-Description: Deleted Attachment\015\012X-"; else if(!struncmp(hdr, "content-transfer-encoding:", 26) @@ -1616,6 +1616,12 @@ save_ex_explain_parts(struct mail_bodystruct *body, int depth, long unsigned int unsigned long ilen; char *name = parameter_val(body->parameter, "name"); + if(!name){ + if(body->disposition.type && + !strucmp(body->disposition.type, "ATTACHMENT")) + name = parameter_val(body->disposition.parameter, "filename"); + } + if(body->type == TYPEMULTIPART) { /* multipart gets special handling */ PART *part = body->nested.part; /* first body part */ @@ -1642,7 +1648,8 @@ save_ex_explain_parts(struct mail_bodystruct *body, int depth, long unsigned int body_type_names(body->type), MAILTMPLEN-300, body->subtype ? body->subtype : "Unknown", name ? " (Name=\"" : "", - name ? name : "", + name ? (char *) rfc1522_decode_to_utf8((unsigned char *)tmp_20k_buf, + SIZEOF_20KBUF, name) : "", name ? "\")" : ""); } @@ -1665,7 +1672,8 @@ save_ex_explain_parts(struct mail_bodystruct *body, int depth, long unsigned int body_type_names(body->type), MAILTMPLEN-300, body->subtype ? body->subtype : "Unknown", name ? " (Name=\"" : "", - name ? name : "", + name ? (char *) rfc1522_decode_to_utf8((unsigned char *)tmp_20k_buf, + SIZEOF_20KBUF, name) : "", name ? "\")" : "", comatose((body->encoding == ENCBASE64) ? ((body->size.bytes * 3)/4) -- cgit v1.2.3-54-g00ecf