Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
fauvetg opened this issue Jun 15, 2017 · 3 comments
Closed
Assignees
Milestone

Comments

@fauvetg
Copy link

fauvetg commented Jun 15, 2017

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,

@bbottema
Copy link
Owner

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

@bbottema
Copy link
Owner

Related to smiley22/S22.Imap#81.

@bbottema bbottema changed the title MimeMessageParser skips inlined parts without contentID Parse INLINE attachments without ID as regular attachments when converting Aug 12, 2017
@bbottema
Copy link
Owner

Released in 4.3.0.

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

No branches or pull requests

2 participants