From: ashiire <ashiire@users.noreply.github.com>
To: ml@inbox.vuxu.org
Subject: Re: [PR PATCH] [Updated] improve named part/attachment detection
Date: Wed, 16 Aug 2023 16:46:43 +0200 [thread overview]
Message-ID: <20230816144643.oHNlOMfG5JcGPnw3QHDd-7I7aSvRl0gZ_zLATURHPUY@z> (raw)
In-Reply-To: <gh-mailinglist-notifications-fa6558a0-26e0-48f6-803f-f5a8af34f6a8-mblaze-232@inbox.vuxu.org>
[-- Attachment #1: Type: text/plain, Size: 627 bytes --]
There is an updated pull request by ashiire against master on the mblaze repository
https://github.com/ashiire/mblaze ashiire-patch-1
https://github.com/leahneukirchen/mblaze/pull/232
improve named part/attachment detection
This will add filename detection for parts which specify Content-Disposition _without_ a filename parameter and Content-Type _with_ a name parameter. I'm not sure whether omitting this possibility was intentional, e.g. to adhere to standard, but messages which name their attachments in this way occur in the wild.
A patch file from https://github.com/leahneukirchen/mblaze/pull/232.patch is attached
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-ashiire-patch-1-232.patch --]
[-- Type: text/x-diff, Size: 4250 bytes --]
From da49ac5b1e1e11878c3fdf9c58c1d24a0354f158 Mon Sep 17 00:00:00 2001
From: ashiire <31418397+ashiire@users.noreply.github.com>
Date: Wed, 11 Jan 2023 12:20:51 +0100
Subject: [PATCH 1/3] improve named part/attachment detection
will now detect filenames for parts if the part specifies Content-Disposition without a filename parameter and Content-Type with a name parameter
---
mshow.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/mshow.c b/mshow.c
index 1cd2cbc..b4463e9 100644
--- a/mshow.c
+++ b/mshow.c
@@ -158,11 +158,11 @@ mime_filename(struct message *msg)
static char buf[512];
char *v;
char *filename = 0;
-
- if ((v = blaze822_hdr(msg, "content-disposition"))) {
- if (blaze822_mime2231_parameter(v, "filename",
- buf, sizeof buf, "UTF-8"))
- filename = buf;
+
+ if ((v = blaze822_hdr(msg, "content-disposition")) &&
+ blaze822_mime2231_parameter(v, "filename",
+ buf, sizeof buf, "UTF-8")) {
+ filename = buf;
} else if ((v = blaze822_hdr(msg, "content-type"))) {
if (blaze822_mime2231_parameter(v, "name",
buf, sizeof buf, "UTF-8"))
From 52dbd42252147a1b2c9d6e58d04be2ea0c6aea1a Mon Sep 17 00:00:00 2001
From: ashiire <31418397+ashiire@users.noreply.github.com>
Date: Wed, 11 Jan 2023 12:20:51 +0100
Subject: [PATCH 2/3] improve named part/attachment detection
will now detect filenames for parts if the part specifies Content-Disposition without a filename parameter and Content-Type with a name parameter
---
mshow.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/mshow.c b/mshow.c
index b4463e9..d0871f2 100644
--- a/mshow.c
+++ b/mshow.c
@@ -158,7 +158,7 @@ mime_filename(struct message *msg)
static char buf[512];
char *v;
char *filename = 0;
-
+
if ((v = blaze822_hdr(msg, "content-disposition")) &&
blaze822_mime2231_parameter(v, "filename",
buf, sizeof buf, "UTF-8")) {
From ef0406d94baab08d3b6e737790aeff504de58e69 Mon Sep 17 00:00:00 2001
From: nay <nay@nays.cz>
Date: Wed, 16 Aug 2023 16:50:05 +0200
Subject: [PATCH 3/3] t/1702-mshow-attachments.t: add tests for named
part/attachment detection
---
t/1702-mshow-attachments.t | 53 ++++++++++++++++++++++++++++++++++++++
1 file changed, 53 insertions(+)
create mode 100755 t/1702-mshow-attachments.t
diff --git a/t/1702-mshow-attachments.t b/t/1702-mshow-attachments.t
new file mode 100755
index 0000000..73f2517
--- /dev/null
+++ b/t/1702-mshow-attachments.t
@@ -0,0 +1,53 @@
+#!/bin/sh -e
+cd ${0%/*}
+. ./lib.sh
+plan 2
+
+# Different naming scenarios for named parts
+cat <<EOF >tmp
+Content-Type: multipart/mixed; boundary=----_NextPart_000_00DE_01D6A2E8.A7446C80
+
+------_NextPart_000_00DE_01D6A2E8.A7446C80
+
+no header, part is not attachment
+------_NextPart_000_00DE_01D6A2E8.A7446C80
+Content-Type: text/plain; charset=UTF-8
+
+CT w/o name, part is not attachment
+------_NextPart_000_00DE_01D6A2E8.A7446C80
+Content-Type: text/plain; charset=UTF-8; name="ctn.txt"
+
+CT with name, part is attachment
+------_NextPart_000_00DE_01D6A2E8.A7446C80
+Content-Disposition: attachment
+
+CD w/o filename, part is not attachment
+------_NextPart_000_00DE_01D6A2E8.A7446C80
+Content-Type: text/plain; charset=UTF-8
+Content-Disposition: attachment
+
+CD w/o filename, CT w/o name, part is not attachment
+------_NextPart_000_00DE_01D6A2E8.A7446C80
+Content-Type: text/plain; charset=UTF-8; name="cd_ctn.txt"
+Content-Disposition: attachment
+
+CD w/o filename, CT with name, part is attachment
+------_NextPart_000_00DE_01D6A2E8.A7446C80
+Content-Disposition: attachment; filename="cdf.txt"
+
+CD with filename, part is attachment
+------_NextPart_000_00DE_01D6A2E8.A7446C80
+Content-Type: text/plain; charset=UTF-8; name="cdf_ct.txt"
+Content-Disposition: attachment
+
+CD with filename, CT w/o name, part is attachment
+------_NextPart_000_00DE_01D6A2E8.A7446C80
+Content-Type: text/plain; charset=UTF-8; name="cdf_ctn.txt"
+Content-Disposition: attachment; filename="cdf_ctn.txt"
+
+CD with filename, CT with name, part is attachment
+------_NextPart_000_00DE_01D6A2E8.A7446C80--
+EOF
+
+check 'mail has 10 parts' 'mshow -t ./tmp | wc -l | grep 11'
+check 'mail has 5 named parts/attachments' 'mshow -t ./tmp | grep .*name=\".*\" | wc -l | grep 5'
next prev parent reply other threads:[~2023-08-16 14:46 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <gh-mailinglist-notifications-fa6558a0-26e0-48f6-803f-f5a8af34f6a8-mblaze-232@inbox.vuxu.org>
2023-02-12 10:38 ` ashiire
2023-08-11 11:37 ` ashiire
2023-08-11 13:31 ` leahneukirchen
2023-08-16 11:09 ` [PR PATCH] [Updated] " ashiire
2023-08-16 14:46 ` ashiire [this message]
2024-09-11 19:36 ` [PR PATCH] [Merged]: " leahneukirchen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230816144643.oHNlOMfG5JcGPnw3QHDd-7I7aSvRl0gZ_zLATURHPUY@z \
--to=ashiire@users.noreply.github.com \
--cc=ml@inbox.vuxu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).