From 64531cf1db1e9531990c077ea5c0b70cfa50f3be Mon Sep 17 00:00:00 2001 From: Emil Nicolaie Perhinschi Date: Fri, 16 Jul 2021 22:01:26 +0300 Subject: [PATCH] fixes for attachment processing, as instructed by A.Ruppe --- email.d | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/email.d b/email.d index 2af4dfe..39be8fe 100644 --- a/email.d +++ b/email.d @@ -351,6 +351,9 @@ class MimePart { string gpgproto; MimeAttachment toMimeAttachment() { + if(type == "multipart/mixed" && stuff.length == 1) + return stuff[0].toMimeAttachment; + MimeAttachment att; att.type = type; att.filename = filename; @@ -407,6 +410,8 @@ class MimePart { auto name = h[0 .. idx].strip.toLower; auto content = h[idx + 1 .. $].strip; + string[4] filenames_found; + switch(name) { case "content-type": parseContentType(content); @@ -423,6 +428,19 @@ class MimePart { case "filename": filename = v; break; + // FIXME: https://datatracker.ietf.org/doc/html/rfc2184#section-3 is what it is SUPPOSED to do + case "filename*0": + filenames_found[0] = v; + break; + case "filename*1": + filenames_found[1] = v; + break; + case "filename*2": + filenames_found[2] = v; + break; + case "filename*3": + filenames_found[3] = v; + break; default: } } @@ -432,6 +450,12 @@ class MimePart { break; default: } + + if (filenames_found[0] != "") { + foreach (string v; filenames_found) { + this.filename ~= v; + } + } } }