JAMES-2351 James should consider ICS as attachments
Project: http://git-wip-us.apache.org/repos/asf/james-project/repo Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/0f1f2f27 Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/0f1f2f27 Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/0f1f2f27 Branch: refs/heads/master Commit: 0f1f2f2702badd2c57db509ffce1e7024e731698 Parents: 8a44af4 Author: benwa <[email protected]> Authored: Wed Mar 14 17:14:40 2018 +0700 Committer: benwa <[email protected]> Committed: Thu Mar 15 15:53:50 2018 +0700 ---------------------------------------------------------------------- .../store/mail/model/impl/MessageParser.java | 5 ++- .../mail/model/impl/MessageParserTest.java | 10 +++++ .../store/src/test/resources/eml/calendar.eml | 39 ++++++++++++++++++++ 3 files changed, 53 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/james-project/blob/0f1f2f27/mailbox/store/src/main/java/org/apache/james/mailbox/store/mail/model/impl/MessageParser.java ---------------------------------------------------------------------- diff --git a/mailbox/store/src/main/java/org/apache/james/mailbox/store/mail/model/impl/MessageParser.java b/mailbox/store/src/main/java/org/apache/james/mailbox/store/mail/model/impl/MessageParser.java index fa8744f..7bb86c9 100644 --- a/mailbox/store/src/main/java/org/apache/james/mailbox/store/mail/model/impl/MessageParser.java +++ b/mailbox/store/src/main/java/org/apache/james/mailbox/store/mail/model/impl/MessageParser.java @@ -61,9 +61,11 @@ public class MessageParser { private static final List<String> ATTACHMENT_CONTENT_DISPOSITIONS = ImmutableList.of( ContentDispositionField.DISPOSITION_TYPE_ATTACHMENT.toLowerCase(Locale.US), ContentDispositionField.DISPOSITION_TYPE_INLINE.toLowerCase(Locale.US)); + private static final String TEXT_CALENDAR = "text/calendar"; private static final ImmutableList<String> ATTACHMENT_CONTENT_TYPES = ImmutableList.of( "application/pgp-signature", - "message/disposition-notification"); + "message/disposition-notification", + TEXT_CALENDAR); private static final Logger LOGGER = LoggerFactory.getLogger(MessageParser.class); private final Cid.CidParser cidParser; @@ -193,6 +195,7 @@ public class MessageParser { private boolean isTextPart(Entity part) { return getContentTypeField(part) + .filter(header -> !ATTACHMENT_CONTENT_TYPES.contains(header.getMimeType())) .map(ContentTypeField::getMediaType) .map(TEXT_MEDIA_TYPE::equals) .orElse(false); http://git-wip-us.apache.org/repos/asf/james-project/blob/0f1f2f27/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/impl/MessageParserTest.java ---------------------------------------------------------------------- diff --git a/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/impl/MessageParserTest.java b/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/impl/MessageParserTest.java index 3bb63a8..40b73ec 100644 --- a/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/impl/MessageParserTest.java +++ b/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/impl/MessageParserTest.java @@ -265,6 +265,16 @@ public class MessageParserTest { } @Test + public void getAttachmentsShouldConsiderICSAsAttachments() throws Exception { + List<MessageAttachment> attachments = testee.retrieveAttachments( + ClassLoader.getSystemResourceAsStream("eml/calendar.eml")); + + assertThat(attachments) + .hasSize(1) + .allMatch(messageAttachment -> messageAttachment.getAttachment().getType().equals("text/calendar")); + } + + @Test public void gpgSignatureShouldBeConsideredAsAnAttachment() throws Exception { List<MessageAttachment> attachments = testee.retrieveAttachments( ClassLoader.getSystemResourceAsStream("eml/signedMessage.eml")); http://git-wip-us.apache.org/repos/asf/james-project/blob/0f1f2f27/mailbox/store/src/test/resources/eml/calendar.eml ---------------------------------------------------------------------- diff --git a/mailbox/store/src/test/resources/eml/calendar.eml b/mailbox/store/src/test/resources/eml/calendar.eml new file mode 100644 index 0000000..05dbb0e --- /dev/null +++ b/mailbox/store/src/test/resources/eml/calendar.eml @@ -0,0 +1,39 @@ +From: Test 1 <[email protected]> +To: Test 2 <[email protected]> +Subject: New Time Proposed: New event from Test: lole +Date: Tue, 13 Mar 2018 14:36:08 +0000 +Message-ID: <am5p190mb03542a58e344c68475a951af...@am5p190mb0354.eurp190.prod.outlook.com> +Accept-Language: en-US +Content-Language: en-US +Content-Type: multipart/alternative; + boundary="_000_AM5P190MB03542A58E344F2C68475A951AFD20AM5P190MB0354EURP_" +MIME-Version: 1.0 + +--_000_AM5P190MB03542A58E344F2C68475A951AFD20AM5P190MB0354EURP_ +Content-Type: text/plain; charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable + +Will be better for me, thx + +--_000_AM5P190MB03542A58E344F2C68475A951AFD20AM5P190MB0354EURP_ +Content-Type: text/html; charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable + +<html> + <p>Will be better for me, thx</p> +</html> + +--_000_AM5P190MB03542A58E344F2C68475A951AFD20AM5P190MB0354EURP_ +Content-Type: text/calendar; charset="utf-8"; method=COUNTER +Content-Transfer-Encoding: base64 + +QkVHSU46VkNBTEVOREFSDQpNRVRIT0Q6Q09VTlRFUg0KUFJPRElEOk1pY3Jvc29mdCBFeGNoYW5n +ZSBTZXJ2ZXIgMjAxMA0KVkVSU0lPTjoyLjANCkJFR0lOOlZUSU1FWk9ORQ0KVFpJRDpFdXJvcGUv +QmVybGluDQpCRUdJTjpTVEFOREFSRA0KRFRTVEFSVDoxNjAxMDEwMVQwMzAwMDANClRaT0ZGU0VU +RlJPTTorMDIwMA0KVFpPRkZTRVRUTzorMDEwMA0KUlJVTEU6RlJFUT1ZRUFSTFk7SU5URVJWQUw9 +MTtCWURBWT0tMVNVO0JZTU9OVEg9MTANCkVORDpTVEFOREFSRA0KQkVHSU46REFZTElHSFQNCkRU +U0VRVUVOQ0U6MA0KRFRTVEFNUDoyMDE4MDMxM1QxNDM2MDdaDQpDT01NRU5UO0xBTkdVQUdFPWVu +LVVTOldpbGwgYmUgYmV0dGVyIGZvciBtZVwsIHRoeFxuDQpFTkQ6VkVWRU5UDQpFTkQ6VkNBTEVO +REFSDQo= + +--_000_AM5P190MB03542A58E344F2C68475A951AFD20AM5P190MB0354EURP_-- \ No newline at end of file --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
