Skip to content

Parse INLINE attachments without ID as regular attachments when converting #83

Closed

Description

@fauvetg

Hello,

Apparently some mailer clients can send emails that contain one or multiple inline attachment, without any contentId :

From: Test <test@example.com>
Content-Type: multipart/mixed;
	boundary="Apple-Mail=_DF026BAA-42B1-476C-A89F-A2B2D388A362"
Subject: test PJ
Message-ID: <87B0499D-EFFC-424C-8B68-45B6CBDDBA29@resabase.com>
Date: Thu, 15 Jun 2017 09:52:02 +0200
To: Test <test@example.com>
X-Mailer: Apple Mail (2.3273)
MIME-Version: 1.0

--Apple-Mail=_DF026BAA-42B1-476C-A89F-A2B2D388A362
Content-Disposition: inline;
	filename="ALERTE SOCIALE 12 juin 2017.pdf"
Content-Type: application/pdf;
	x-unix-mode=0644;
	name="ALERTE SOCIALE 12 juin 2017.pdf"
Content-Transfer-Encoding: base64

...

--Apple-Mail=_DF026BAA-42B1-476C-A89F-A2B2D388A362
Content-Disposition: inline;
	filename="ALERTE SOCIALE 12 juin 2017.pdf"
Content-Type: application/pdf;
	x-unix-mode=0644;
	name="ALERTE SOCIALE 12 juin 2017.pdf"
Content-Transfer-Encoding: base64

...

--Apple-Mail=_DF026BAA-42B1-476C-A89F-A2B2D388A362--

In this case, the email contains 2 attachments, but the MimeMessageParser's cidMap contains only one, with a null key.

A way to fix this would be to handle an INLINE Content-Disposition without contentID just as a standard attachment :

final DataSource ds = createDataSource(part);
// If the diposition is not provided, the part should be treat as attachment
if (part.getDisposition() == null || Part.ATTACHMENT.equalsIgnoreCase(part.getDisposition())) {
    this.attachmentList.put(parseResourceName(part.getContentID(), part.getFileName()), ds);
} else if (Part.INLINE.equalsIgnoreCase(part.getDisposition())) {
    if (part.getContentID() != null) {
        this.cidMap.put(part.getContentID(), ds);
    } else {
        // Missing contentID : treated as standard attachment
        this.attachmentList.put(parseResourceName(null, part.getFileName()), ds);
    }
} else {
    throw new IllegalStateException("invalid attachment type");
}

Sincerely,

Activity

  1. bbottema commented on Jun 16, 2017

    @bbottema
    Owner

    Thanks for the report. I'll look into it.

  2. added this to the 4.3.0 milestone on Jun 16, 2017
  3. self-assigned this
    on Jun 16, 2017
  4. added a commit that references this issue on Aug 12, 2017
  5. bbottema commented on Aug 12, 2017

    @bbottema
    Owner
  6. changed the title [-]MimeMessageParser skips inlined parts without contentID[/-] [+]Parse INLINE attachments without ID as regular attachments when converting[/+] on Aug 12, 2017
  7. bbottema commented on Aug 12, 2017

    @bbottema
    Owner

    Released in 4.3.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions