From fdf30924895f00d1e83915d09b3e5b01bc417e5f Mon Sep 17 00:00:00 2001 From: Damien Riegel Date: Mon, 7 Nov 2016 18:06:13 -0800 Subject: [PATCH] attach_format: add new %F placeholder This new placeholder allows to print the attachment name as it will be seen on the recipient side. --- init.h | 1 + recvattach.c | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/init.h b/init.h index 6756004e6..3a9b07857 100644 --- a/init.h +++ b/init.h @@ -253,6 +253,7 @@ struct option_t MuttVars[] = { ** .dt %D .dd deleted flag ** .dt %d .dd description ** .dt %e .dd MIME content-transfer-encoding + ** .dt %F .dd filename for content-disposition header ** .dt %f .dd filename ** .dt %I .dd disposition (``I'' for inline, ``A'' for attachment) ** .dt %m .dd major MIME type diff --git a/recvattach.c b/recvattach.c index 86ecdffca..0dd3baa1b 100644 --- a/recvattach.c +++ b/recvattach.c @@ -160,6 +160,7 @@ ATTACHPTR **mutt_gen_attach_list (BODY *m, * %D = deleted flag * %d = description * %e = MIME content-transfer-encoding + * %F = filename for content-disposition header * %f = filename * %I = content-disposition, either I (inline) or A (attachment) * %t = tagged flag @@ -263,6 +264,25 @@ const char *mutt_attach_fmt (char *dest, else if(!aptr->content->filename) optional = 0; break; + case 'F': + if (!optional) + { + char fname[_POSIX_PATH_MAX]; + char *src = NULL; + + if (aptr->content->d_filename) + src = aptr->content->d_filename; + else if (aptr->content->filename) + src = aptr->content->filename; + else + break; + + strfcpy (fname, mutt_basename (NONULL (src)), sizeof (fname)); + mutt_format_s (dest, destlen, prefix, fname); + } + else if (!aptr->content->d_filename && !aptr->content->filename) + optional = 0; + break; case 'D': if(!optional) snprintf (dest, destlen, "%c", aptr->content->deleted ? 'D' : ' '); -- 2.40.0