Skip to content

PR for Issue 455 breaks detection of attachments in mixed blocks #582

@mrhewitt

Description

@mrhewitt

Describe the bug
The PR for issue #455 is causing messages with only a single attachment in a mulitpart/mixed boundry to not return the attachment but rather undecoded part (issue #567 seems to be the same problem)

It seems issues #580 and #578 are also being caused by this commit, though not attachments they are a single content block inside a multipart block and are hence being thrown away.

Additional context
This is because it altered Structure::parsePart to return only if there is more than one part, hence in cases where there is only one attachment it falls through to default return and instead returns just raw content as a part.

This was the original issue
##455

And this commit broke it:
#fad09ad

The message below will reproduce issue of not loading the attachment (but note I could not reproduce issue #455 of not loading body even when I reverted his PR)

I am working on a PR for this and will submit later (but note its only to let attachment dispositions go though so problem reported in #455 would not be affected but seeing now the extent of the issue it may be better to review why #455 needed this, but unfortunately this issue did not provide examples)

Code to Reproduce

Received: by 2002:a05:7001:a40a:b0:662:9c3d:2d8b with SMTP id
 vo10csp4472717mab; Tue, 27 May 2025 00:20:15 -0700 (PDT)
Return-Path: <[email protected]>
From: [email protected]
To: [email protected]
Date: 27 May 2025 08:20:12 +0100
Subject: redacted_Balances_GBP_
Content-Type: multipart/mixed;
 boundary=--boundary_108_1d32a5ba-d60e-4773-9939-d5614385ac16
Return-Path: [email protected]
Message-ID: <CWLP123MB51345AE20743EB4587D3CA32AC64A@CWLP123MB5134.GBRP123.PROD.OUTLOOK.COM>
MIME-Version: 1.0

----boundary_108_1d32a5ba-d60e-4773-9939-d5614385ac16
Content-Type: multipart/mixed;
 boundary=--boundary_109_fc604310-cc2e-459d-9cb7-9f39cf7d3a80

Content-Type: text/html; charset=utf-8
Content-Transfer-Encoding: quoted-printable

The body still works as it is only a single part and not attachment
(See issue #455)  [but I could not replicate it, perhaps #455 needs a sample test case

----boundary_108_1d32a5ba-d60e-4773-9939-d5614385ac16--

----boundary_108_1d32a5ba-d60e-4773-9939-d5614385ac16
Content-Type: multipart/mixed;
 boundary=--boundary_109_fc604310-cc2e-459d-9cb7-9f39cf7d3a80

----boundary_109_fc604310-cc2e-459d-9cb7-9f39cf7d3a80
Content-Type: text/csv; name=redacted_Balances_GBP_.csv
Content-Transfer-Encoding: base64
Content-Disposition: attachment;
 filename="=?utf-8?B?Q2VudHJ1bV9BY2NvdW50X0JhbGFuY2VzX0dCUF8uY3N2?="
Content-ID: <5df3148f-aa43-4dea-adeb-7d432289d3ea>

77u/cmVwb3J0X2RhdGUsQ3VycmVuY3ksdXNlcm5hbWUsYWNjb3VudF9zdGF0dXMsY3VycmVudF9i
YWxhbmNlLGxhc3RfdHJhbnNhY3Rpb25fZGF0ZXRpbWUsc3Rha2VfbGltaXQsc29mdF9saW1pdCxo

----boundary_109_fc604310-cc2e-459d-9cb7-9f39cf7d3a80--

----boundary_108_1d32a5ba-d60e-4773-9939-d5614385ac16--

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions