* Re: improve named part/attachment detection
[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
` (4 subsequent siblings)
5 siblings, 0 replies; 6+ messages in thread
From: ashiire @ 2023-02-12 10:38 UTC (permalink / raw)
To: ml
[-- Attachment #1: Type: text/plain, Size: 1852 bytes --]
New comment by ashiire on mblaze repository
https://github.com/leahneukirchen/mblaze/pull/232#issuecomment-1426997809
Comment:
Fabricated example of the behavior in question.
```
$ ls mail_s_poezii.txt | mshow -t
mail_s_poezii.txt
1: multipart/mixed size=825
2: text/plain size=30
3: text/plain size=53 name="kocka_leze_dirou.txt"
4: text/plain size=98
$ ls mail_s_poezii.txt | mshow-patched -t
mail_s_poezii.txt
1: multipart/mixed size=825
2: text/plain size=30
3: text/plain size=53 name="kocka_leze_dirou.txt"
4: text/plain size=98 name="za_pravdu_je_ruzna_sazba.txt"
```
file contents:
```
From: Petr Klic <p.klic@example.com>
To: <umeni@example.com>
Subject: Poezie
Date: Wed, 14 Oct 2020 12:18:08 +0200
Message-ID: <setrise3750@example.com>
MIME-Version: 1.0
Content-Type: multipart/mixed;
boundary="----=_NextPart_000_00DE_01D6A2E8.A7446C80"
Content-Language: cs
This is a multipart message in MIME format.
------=_NextPart_000_00DE_01D6A2E8.A7446C80
Content-Type: text/plain;
charset="UTF-8"
Content-Transfer-Encoding: 8bit
Dobry den,
posilam poezii.
------=_NextPart_000_00DE_01D6A2E8.A7446C80
Content-Type: text/plain;
charset="UTF-8";
name="kocka_leze_dirou.txt"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
filename="kocka_leze_dirou.txt"
kocka leze dirou
pes oknem
nebude-li prset
nezmoknem
------=_NextPart_000_00DE_01D6A2E8.A7446C80
Content-Type: text/plain;
charset="UTF-8";
name="za_pravdu_je_ruzna_sazba.txt"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment
za pravdu je ruzna sazba
nekdy pomnik
jindy vazba
kdo ji rika driv nez vcas
tomu pravda
zlame vaz
------=_NextPart_000_00DE_01D6A2E8.A7446C80--
```
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: improve named part/attachment detection
[not found] <gh-mailinglist-notifications-fa6558a0-26e0-48f6-803f-f5a8af34f6a8-mblaze-232@inbox.vuxu.org>
2023-02-12 10:38 ` improve named part/attachment detection ashiire
@ 2023-08-11 11:37 ` ashiire
2023-08-11 13:31 ` leahneukirchen
` (3 subsequent siblings)
5 siblings, 0 replies; 6+ messages in thread
From: ashiire @ 2023-08-11 11:37 UTC (permalink / raw)
To: ml
[-- Attachment #1: Type: text/plain, Size: 459 bytes --]
New comment by ashiire on mblaze repository
https://github.com/leahneukirchen/mblaze/pull/232#issuecomment-1674606438
Comment:
Please let me know if there are any problems with the patch so I can try to correct them.
To clarify, I believe the current behavior is a problem because in the affected emails I have come across, these mimeparts are clearly intended to be treated as attachments and appear to be treated as such by other MUAs, but not mblaze.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: improve named part/attachment detection
[not found] <gh-mailinglist-notifications-fa6558a0-26e0-48f6-803f-f5a8af34f6a8-mblaze-232@inbox.vuxu.org>
2023-02-12 10:38 ` improve named part/attachment detection ashiire
2023-08-11 11:37 ` ashiire
@ 2023-08-11 13:31 ` leahneukirchen
2023-08-16 11:09 ` [PR PATCH] [Updated] " ashiire
` (2 subsequent siblings)
5 siblings, 0 replies; 6+ messages in thread
From: leahneukirchen @ 2023-08-11 13:31 UTC (permalink / raw)
To: ml
[-- Attachment #1: Type: text/plain, Size: 325 bytes --]
New comment by leahneukirchen on mblaze repository
https://github.com/leahneukirchen/mblaze/pull/232#issuecomment-1674800830
Comment:
This looks good and probably is what we intended in the first place.
Please remove the spurious whitespace in one line, and if you can, add a test that checks all possible 4 situations.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PR PATCH] [Updated] improve named part/attachment detection
[not found] <gh-mailinglist-notifications-fa6558a0-26e0-48f6-803f-f5a8af34f6a8-mblaze-232@inbox.vuxu.org>
` (2 preceding siblings ...)
2023-08-11 13:31 ` leahneukirchen
@ 2023-08-16 11:09 ` ashiire
2023-08-16 14:46 ` ashiire
2024-09-11 19:36 ` [PR PATCH] [Merged]: " leahneukirchen
5 siblings, 0 replies; 6+ messages in thread
From: ashiire @ 2023-08-16 11:09 UTC (permalink / raw)
To: ml
[-- 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: 1907 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/2] 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/2] 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")) {
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PR PATCH] [Updated] improve named part/attachment detection
[not found] <gh-mailinglist-notifications-fa6558a0-26e0-48f6-803f-f5a8af34f6a8-mblaze-232@inbox.vuxu.org>
` (3 preceding siblings ...)
2023-08-16 11:09 ` [PR PATCH] [Updated] " ashiire
@ 2023-08-16 14:46 ` ashiire
2024-09-11 19:36 ` [PR PATCH] [Merged]: " leahneukirchen
5 siblings, 0 replies; 6+ messages in thread
From: ashiire @ 2023-08-16 14:46 UTC (permalink / raw)
To: ml
[-- 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'
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PR PATCH] [Merged]: improve named part/attachment detection
[not found] <gh-mailinglist-notifications-fa6558a0-26e0-48f6-803f-f5a8af34f6a8-mblaze-232@inbox.vuxu.org>
` (4 preceding siblings ...)
2023-08-16 14:46 ` ashiire
@ 2024-09-11 19:36 ` leahneukirchen
5 siblings, 0 replies; 6+ messages in thread
From: leahneukirchen @ 2024-09-11 19:36 UTC (permalink / raw)
To: ml
[-- Attachment #1: Type: text/plain, Size: 475 bytes --]
There's a merged pull request on the mblaze repository
improve named part/attachment detection
https://github.com/leahneukirchen/mblaze/pull/232
Description:
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.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2024-09-11 19:36 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <gh-mailinglist-notifications-fa6558a0-26e0-48f6-803f-f5a8af34f6a8-mblaze-232@inbox.vuxu.org>
2023-02-12 10:38 ` improve named part/attachment detection 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
2024-09-11 19:36 ` [PR PATCH] [Merged]: " leahneukirchen
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).