-
-
Notifications
You must be signed in to change notification settings - Fork 275
Closed
Description
Hello,
Apparently some mailer clients can send emails that contain one or multiple inline attachment, without any contentId :
From: Test <[email protected]>
Content-Type: multipart/mixed;
boundary="Apple-Mail=_DF026BAA-42B1-476C-A89F-A2B2D388A362"
Subject: test PJ
Message-ID: <[email protected]>
Date: Thu, 15 Jun 2017 09:52:02 +0200
To: Test <[email protected]>
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,