mblaze

Unix utilities to deal with Maildir - my mirror
git clone https://pi.duncano.de/git/mblaze.git
Log | Files | Refs | README | COPYING

commit 93bfc9cf5f88727eb5d1e2a7f8fce526769fa66d
parent c6480f4785987aa97db25e7baa5adb394f8007a8
Author: Leah Neukirchen <leah@vuxu.org>
Date:   Thu,  6 Apr 2017 21:01:11 +0200

mshow: use blaze822_mime2231_parameter for filenames

Diffstat:
Makefile | 2+-
mshow.c | 23+++++++++++------------
2 files changed, 12 insertions(+), 13 deletions(-)

diff --git a/Makefile b/Makefile @@ -24,7 +24,7 @@ maddr magrep mexport mflag mgenmid mhdr mlist mpick mscan msed mseq mshow msort mthread : seq.o slurp.o maddr magrep mhdr mpick mscan mshow : rfc2047.o magrep mshow : rfc2045.o -mshow : filter.o safe_u8putstr.c +mshow : filter.o safe_u8putstr.c rfc2231.c msort : mystrverscmp.o mmime : slurp.o diff --git a/mshow.c b/mshow.c @@ -146,14 +146,18 @@ tlmimetype(char *ct) char * mime_filename(struct message *msg) { - char *filename = 0, *fn, *fne, *v; + static char buf[512]; + char *v; + char *filename = 0; if ((v = blaze822_hdr(msg, "content-disposition"))) { - if (blaze822_mime_parameter(v, "filename", &fn, &fne)) - filename = strndup(fn, fne-fn); + if (blaze822_mime2231_parameter(v, "filename", + buf, sizeof buf, "UTF-8")) + filename = buf; } else if ((v = blaze822_hdr(msg, "content-type"))) { - if (blaze822_mime_parameter(v, "name", &fn, &fne)) - filename = strndup(fn, fne-fn); + if (blaze822_mime2231_parameter(v, "name", + buf, sizeof buf, "UTF-8")) + filename = buf; } return filename; @@ -177,10 +181,8 @@ render_mime(int depth, struct message *msg, char *body, size_t bodylen) for (i = 0; i < depth+1; i++) printf("--- "); printf("%d: %s size=%zd", mimecount, mt, bodylen); - if (filename) { + if (filename) printf(" name=\"%s\"", filename); - free(filename); - } char *cmd; blaze822_mime_action r = MIME_CONTINUE; @@ -354,10 +356,8 @@ list_mime(int depth, struct message *msg, char *body, size_t bodylen) char *filename = mime_filename(msg); printf(" %*.s%d: %s size=%zd", depth*2, "", ++mimecount, mt, bodylen); - if (filename) { + if (filename) printf(" name=\"%s\"", filename); - free(filename); - } printf("\n"); return MIME_CONTINUE; @@ -496,7 +496,6 @@ extract_mime(int depth, struct message *msg, char *body, size_t bodylen) } } - free(filename); return MIME_CONTINUE; }