james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From btell...@apache.org
Subject [03/17] james-project git commit: JAMES-2562 JMAP should Handle messages inlined messages with CID but without content disposition
Date Mon, 15 Oct 2018 06:28:26 GMT
JAMES-2562 JMAP should Handle messages inlined messages with CID but without content disposition


Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/3bdf79b4
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/3bdf79b4
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/3bdf79b4

Branch: refs/heads/master
Commit: 3bdf79b4424993ed9af8ee0716f8ad0d70ac4807
Parents: d5d5c9c
Author: Raphael Ouazana <raphael.ouazana@linagora.com>
Authored: Fri Oct 12 17:38:25 2018 +0200
Committer: Benoit Tellier <btellier@linagora.com>
Committed: Mon Oct 15 13:16:06 2018 +0700

----------------------------------------------------------------------
 .../store/mail/model/impl/MessageParser.java    |  6 +-
 .../mail/model/impl/MessageParserTest.java      |  7 ++
 .../eml/noContentDispositionWithCID.eml         | 23 +++++++
 .../cucumber/GetMessagesMethodStepdefs.java     |  7 +-
 .../test/resources/cucumber/GetMessages.feature | 14 ++++
 ...oneInlinedImageWithoutContentDisposition.eml | 72 ++++++++++++++++++++
 6 files changed, 127 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/3bdf79b4/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 7bb86c9..fc78eb4 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
@@ -190,7 +190,7 @@ public class MessageParser {
         if (context == Context.BODY && isTextPart(part)) {
             return false;
         }
-        return attachmentDispositionCriterion(part) || attachmentContentTypeCriterion(part);
+        return attachmentDispositionCriterion(part) || attachmentContentTypeCriterion(part)
|| hadCID(part);
     }
 
     private boolean isTextPart(Entity part) {
@@ -217,6 +217,10 @@ public class MessageParser {
             .orElse(false);
     }
 
+    private boolean hadCID(Entity part) {
+        return readHeader(part, CONTENT_ID, ContentIdField.class).isPresent();
+    }
+
     private byte[] getBytes(Body body) throws IOException {
         DefaultMessageWriter messageWriter = new DefaultMessageWriter();
         ByteArrayOutputStream out = new ByteArrayOutputStream();

http://git-wip-us.apache.org/repos/asf/james-project/blob/3bdf79b4/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 ff2d9a2..abb864f 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
@@ -230,6 +230,13 @@ public class MessageParserTest {
     }
 
     @Test
+    public void getAttachmentsShouldConsiderNoContentDispositionAsAttachmentsWhenCID() throws
Exception {
+        List<MessageAttachment> attachments = testee.retrieveAttachments(ClassLoader.getSystemResourceAsStream("eml/noContentDispositionWithCID.eml"));
+
+        assertThat(attachments).hasSize(1);
+    }
+
+    @Test
     public void getAttachmentsShouldRetrieveAttachmentsWhenNoCidForInlined() throws Exception
{
         List<MessageAttachment> attachments = testee.retrieveAttachments(ClassLoader.getSystemResourceAsStream("eml/oneInlinedAttachmentWithNoCid.eml"));
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/3bdf79b4/mailbox/store/src/test/resources/eml/noContentDispositionWithCID.eml
----------------------------------------------------------------------
diff --git a/mailbox/store/src/test/resources/eml/noContentDispositionWithCID.eml b/mailbox/store/src/test/resources/eml/noContentDispositionWithCID.eml
new file mode 100644
index 0000000..fae090d
--- /dev/null
+++ b/mailbox/store/src/test/resources/eml/noContentDispositionWithCID.eml
@@ -0,0 +1,23 @@
+To: me@linagora.com
+From: Benoit Tellier <me@linagora.com>
+Subject: Mail with text attachment
+Message-ID: <befd8cab-9c9c-5537-4e77-937f32326087@any.com>
+Date: Thu, 13 Oct 2016 10:26:20 +0200
+MIME-Version: 1.0
+Content-Type: multipart/mixed;
+ boundary="------------4FD2D252DB453546C22C25B2"
+
+This is a multi-part message in MIME format.
+--------------4FD2D252DB453546C22C25B2
+Content-Type: text/plain; charset=utf-8
+Content-Transfer-Encoding: 7bit
+
+I'm the body!
+
+--------------4FD2D252DB453546C22C25B2
+Content-Type: text/plain; charset=UTF-8;
+ name="attachment.txt"
+Content-ID: <id>
+
+I'm a Schroedinger cat
+--------------4FD2D252DB453546C22C25B2--

http://git-wip-us.apache.org/repos/asf/james-project/blob/3bdf79b4/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/cucumber/GetMessagesMethodStepdefs.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/cucumber/GetMessagesMethodStepdefs.java
b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/cucumber/GetMessagesMethodStepdefs.java
index 13819e5..d3818d3 100644
--- a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/cucumber/GetMessagesMethodStepdefs.java
+++ b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/cucumber/GetMessagesMethodStepdefs.java
@@ -335,10 +335,15 @@ public class GetMessagesMethodStepdefs {
     }
 
     @Given("^\"([^\"]*)\" has a message \"([^\"]*)\" in the \"([^\"]*)\" mailbox with inlined
attachments without content disposition$")
-    public void appendMessageWithInlinedImageButNoContentDisposition(String username, String
messageName, String mailbox) throws Exception {
+    public void appendMessageWithInlinedAttachmentButNoContentDisposition(String username,
String messageName, String mailbox) throws Exception {
         userStepdefs.execWithUser(username, () -> appendMessage(messageName, mailbox,
"eml/inlinedWithoutContentDisposition.eml"));
     }
 
+    @Given("^\"([^\"]*)\" has a message \"([^\"]*)\" in the \"([^\"]*)\" mailbox with inlined
image without content disposition$")
+    public void appendMessageWithInlinedImageButNoContentDisposition(String username, String
messageName, String mailbox) throws Exception {
+        userStepdefs.execWithUser(username, () -> appendMessage(messageName, mailbox,
"eml/oneInlinedImageWithoutContentDisposition.eml"));
+    }
+
     @Given("^\"([^\"]*)\" has a message \"([^\"]*)\" in the \"([^\"]*)\" mailbox with inlined
image without content ID$")
     public void appendMessageWithInlinedImageButNoContentID(String username, String messageName,
String mailbox) throws Exception {
         userStepdefs.execWithUser(username, () -> appendMessage(messageName, mailbox,
"eml/inlinedWithoutContentID.eml"));

http://git-wip-us.apache.org/repos/asf/james-project/blob/3bdf79b4/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/resources/cucumber/GetMessages.feature
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/resources/cucumber/GetMessages.feature
b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/resources/cucumber/GetMessages.feature
index 7e79e5c..efd23d5 100644
--- a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/resources/cucumber/GetMessages.feature
+++ b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/resources/cucumber/GetMessages.feature
@@ -406,6 +406,20 @@ Feature: GetMessages method
       |name     |"encrypted.asc"               |
       |isInline |false                         |
 
+  Scenario: Retrieving message should be possible when message with inlined image but without
content disposition
+    Given "alice@domain.tld" has a message "m1" in the "INBOX" mailbox with inlined image
without content disposition
+    When "alice@domain.tld" ask for messages "m1"
+    Then no error is returned
+    And the list should contain 1 message
+    And the hasAttachment of the message is "true"
+    And the list of attachments of the message contains 1 attachments
+    And the first attachment is:
+      |key      | value                                           |
+      |type     |"image/png"                                      |
+      |cid      |"14672787885774e5c4d4cee471352039@linagora.com"  |
+      |name     |"vlc.png"                                        |
+      |isInline |false                                            |
+
   Scenario: Retrieving message should be possible when message with inlined attachment but
without content ID
     Given "alice@domain.tld" has a message "m1" in the "INBOX" mailbox with inlined image
without content ID
     When "alice@domain.tld" ask for messages "m1"

http://git-wip-us.apache.org/repos/asf/james-project/blob/3bdf79b4/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/resources/eml/oneInlinedImageWithoutContentDisposition.eml
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/resources/eml/oneInlinedImageWithoutContentDisposition.eml
b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/resources/eml/oneInlinedImageWithoutContentDisposition.eml
new file mode 100644
index 0000000..6e165cf
--- /dev/null
+++ b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/resources/eml/oneInlinedImageWithoutContentDisposition.eml
@@ -0,0 +1,72 @@
+Return-Path: <test@linagora.com>
+MIME-Version: 1.0
+Content-Type: multipart/alternative;
+ boundary="=_78be9b39405e216b14ea426a30eef65c"
+Date: Thu, 30 Jun 2016 11:26:28 +0200
+From: Test <test@linagora.com>
+To: test <test@linagora.com>
+Subject: Mail with inlined image
+Message-ID: <e544b5c4bb46598380ce57c7dd1f5340@linagora.com>
+X-Sender: test@linagora.com
+User-Agent: Roundcube Webmail/1.1.4
+
+--=_78be9b39405e216b14ea426a30eef65c
+Content-Transfer-Encoding: 7bit
+Content-Type: text/plain; charset=US-ASCII
+
+Inlined image: 
+
+Signature. 
+--=_78be9b39405e216b14ea426a30eef65c
+Content-Type: multipart/related;
+ boundary="=_09507e56cd9618e600636c7ef4ea9f8f"
+
+--=_09507e56cd9618e600636c7ef4ea9f8f
+Content-Transfer-Encoding: quoted-printable
+Content-Type: text/html; charset=UTF-8
+
+<html><head><meta http-equiv=3D"Content-Type" content=3D"text/html; charset=
+=3DUTF-8" /></head><body style=3D'font-size: 10pt; font-family: Verdana,Gen=
+eva,sans-serif'>
+<p>Inlined image:</p>
+<p><img src=3D"cid:14672787885774e5c4d4cee471352039@linagora.com" alt=3D"" =
+width=3D"32" height=3D"32" /></p>
+<p>Signature.</p>
+</body></html>
+
+--=_09507e56cd9618e600636c7ef4ea9f8f
+Content-Transfer-Encoding: base64
+Content-ID: <14672787885774e5c4d4cee471352039@linagora.com>
+Content-Type: image/png;
+ name=vlc.png
+
+iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAFrUlEQVRYw8WWW2wc1RnHf+fMZS+z
+O7veXXZtr+M4Bl+IHNwrSau0ahEkNIloeCgttKoaJFT1oZUqRUJqEaqqPoAoSLRqK4FaISFUIVQQ
+IMETCBmqBpSGm9OIOKbEju11vNfZnZ29zUwfxiGUkta17PZIZ85I55zv+8///11G+L7P/3Oom704
+c2ff8R169ftCF2LBijz65cfs+zdjR2yGgSe+O5KciizOT2S9lBaF2bPCOtXIjB576mLpv7UlN/X5
+DWt/POKlXBd6LiQivql1e1/ajKlNAYhJ55AhgRaILpgaxGjd/D+R4JcPPahPpDgzHZ0bDbUdhGhi
+qzn+vJT425LfN3338eO9bQ3C/PDoFz0zPeLuOcaq0yYeCbFSrDI4XL529dRf9wBvbqsEyyuF/SP5
+q6RdK2HqPrZVJmMoVCtlkR/I3bHtMTA+dvVttuMQixlYdZuYEaVWbzCcH6Swunb9tgJ4/Mmnd5fr
+zlgmlabesDHjBg27SdKMU7HqjI2P773v4d8NbxsA56WH9l17lRa2bJuYmaTaBsNMU3Vcspk01tzJ
+UHb+2Ru3LQjN8385HP3jUZLXXI00hsipCWQIdno1eoUFxt+e5/RF/yDwhy1Pw9/fviuetRffmxh0
+B/pM0NugeiBjIMLQacOFBZgtKIVaenDyricXalsqgddsfj6mugOK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4elNlEIqDLdz/CRA+EEmishECELveJXutyq8YPJBKaq2vO
+uzddEUCYMwdlEqS33u1k0GQ8Fbw6+CJwosh/DR5//eETnNOyIDPBfcS6LRW0zmvfAX7ziQCs99/b
+l5w+tG7lMgAxAEqPIJ8ueRMfK6mXVhkwhxYA+XB/HYS7+MI+9Uox8NQzyZ9PzbzwINs4zhYTP/3e
+0U38km3X+Aeuu0L8ysHGdwAAAABJRU5ErkJggg==
+--=_09507e56cd9618e600636c7ef4ea9f8f--
+
+--=_78be9b39405e216b14ea426a30eef65c--


---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org


Mime
View raw message