leahneukirchen / mblaze

Unix utilities to deal with Maildir
Other
447 stars 48 forks source link

improve named part/attachment detection #232

Closed ashiire closed 3 weeks ago

ashiire commented 1 year ago

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.

ashiire commented 1 year ago

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--
ashiire commented 1 year ago

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.

leahneukirchen commented 1 year ago

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.