Repository: james-project
Updated Branches:
  refs/heads/master a281f59fd -> 1994df528


JAMES-1984 Charset decoding is done in Mime4j TextBody.getInputStream method


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

Branch: refs/heads/master
Commit: 1994df52883ecef96d701b30fbdf31bbd4fc4f1e
Parents: a281f59
Author: Antoine Duprat <adup...@linagora.com>
Authored: Mon Apr 3 13:02:37 2017 +0200
Committer: Antoine Duprat <adup...@linagora.com>
Committed: Mon Apr 3 15:01:42 2017 +0200

----------------------------------------------------------------------
 .../cucumber/GetMessagesMethodStepdefs.java     |  5 +++
 .../test/resources/cucumber/GetMessages.feature |  9 ++++
 .../test/resources/eml/windows1252charset.eml   | 43 ++++++++++++++++++++
 .../jmap/model/MessageContentExtractor.java     |  3 +-
 4 files changed, 59 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/1994df52/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 c88b52e..a88c824 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
@@ -223,6 +223,11 @@ public class GetMessagesMethodStepdefs {
         appendMessage(messageName, "eml/sameInlinedImages.eml");
     }
 
+    @Given("^the user has a message \"([^\"]*)\" in \"([^\"]*)\" mailbox with 
specific charset$")
+    public void appendMessageWithSpecificCharset(String messageName, String 
mailbox) throws Throwable {
+        appendMessage(messageName, "eml/windows1252charset.eml");
+    }
+
     private void appendMessage(String messageName, String emlFileName) throws 
Exception {
         ZonedDateTime dateTime = ZonedDateTime.parse("2014-10-30T14:12:00Z");
         MessageId id = 
mainStepdefs.jmapServer.getProbe(MailboxProbeImpl.class).appendMessage(userStepdefs.lastConnectedUser,

http://git-wip-us.apache.org/repos/asf/james-project/blob/1994df52/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 0018491..7d35ac4 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
@@ -276,3 +276,12 @@ Feature: GetMessages method
     And the list should contain 1 message
     And the hasAttachment of the message is "false"
     And the list of attachments of the message contains only one attachment 
with cid "1482981567586480bfca67b793175...@linagora.com"
+    
+  Scenario: Preview and bodies should respect given charset
+    Given the user has a message "m1" in "INBOX" mailbox with specific charset
+    When the user ask for messages "m1"
+    Then no error is returned
+    And the list should contain 1 message
+    And the preview of the message is "àààà éééé èèèè"
+    And the textBody of the message is "àààà
\r\n\r\néééé\r\n\r\nèèèè\r\n"
+    And the htmlBody of the message is "<html>\r\n  <p>àààà</p>\r\n  
<p>éééé</p>\r\n  <p>èèèè</p>\r\n</html>\r\n"

http://git-wip-us.apache.org/repos/asf/james-project/blob/1994df52/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/resources/eml/windows1252charset.eml
----------------------------------------------------------------------
diff --git 
a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/resources/eml/windows1252charset.eml
 
b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/resources/eml/windows1252charset.eml
new file mode 100644
index 0000000..6d37efd
--- /dev/null
+++ 
b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/resources/eml/windows1252charset.eml
@@ -0,0 +1,43 @@
+Return-Path: <adup...@linagora.com>
+Received: from alderaan.linagora.com (smtp.linagora.dc1 [172.16.18.53])
+        by imap (Cyrus v2.2.13-Debian-2.2.13-19+squeeze3) with LMTPA;
+        Mon, 03 Apr 2017 12:36:55 +0200
+X-Sieve: CMU Sieve 2.2
+Received: from [10.69.0.145] (LFbn-1-9855-213.w86-202.abo.wanadoo.fr 
[86.202.211.213])
+       (using TLSv1 with cipher DHE-RSA-AES128-SHA (128/128 bits))
+       (No client certificate requested)
+       by alderaan.linagora.com (Postfix) with ESMTPSA id 5CD7B76B
+       for <adup...@linagora.com>; Mon,  3 Apr 2017 12:36:55 +0200 (CEST)
+To: Antoine DUPRAT <adup...@linagora.com>
+From: aduprat <adup...@linagora.com>
+Subject: =?UTF-8?B?w6Agw6kgw6g=?=
+Message-ID: <3325d853-c33c-bc4a-4435-cd704f6a3...@linagora.com>
+Date: Mon, 3 Apr 2017 12:36:55 +0200
+User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
+ Thunderbird/45.8.0
+MIME-Version: 1.0
+Content-Type: multipart/alternative;
+ boundary="------------4609A4E8FA0583CE89472864"
+
+This is a multi-part message in MIME format.
+--------------4609A4E8FA0583CE89472864
+Content-Type: text/plain; charset=windows-1252; format=flowed
+Content-Transfer-Encoding: 8bit
+
+àààà
+
+éééé
+
+èèèè
+
+--------------4609A4E8FA0583CE89472864
+Content-Type: text/html; charset=windows-1252
+Content-Transfer-Encoding: 8bit
+
+<html>
+  <p>àààà</p>
+  <p>éééé</p>
+  <p>èèèè</p>
+</html>
+
+--------------4609A4E8FA0583CE89472864--

http://git-wip-us.apache.org/repos/asf/james-project/blob/1994df52/server/protocols/jmap/src/main/java/org/apache/james/jmap/model/MessageContentExtractor.java
----------------------------------------------------------------------
diff --git 
a/server/protocols/jmap/src/main/java/org/apache/james/jmap/model/MessageContentExtractor.java
 
b/server/protocols/jmap/src/main/java/org/apache/james/jmap/model/MessageContentExtractor.java
index d5b096d..08e9dc4 100644
--- 
a/server/protocols/jmap/src/main/java/org/apache/james/jmap/model/MessageContentExtractor.java
+++ 
b/server/protocols/jmap/src/main/java/org/apache/james/jmap/model/MessageContentExtractor.java
@@ -36,6 +36,7 @@ import org.apache.james.mime4j.dom.TextBody;
 
 import com.github.fge.lambdas.Throwing;
 import com.github.fge.lambdas.functions.ThrowingFunction;
+import com.google.common.base.Charsets;
 
 public class MessageContentExtractor {
 
@@ -91,7 +92,7 @@ public class MessageContentExtractor {
     }
 
     private Optional<String> asString(TextBody textBody) throws IOException {
-        return Optional.ofNullable(IOUtils.toString(textBody.getInputStream(), 
textBody.getMimeCharset()));
+        return Optional.ofNullable(IOUtils.toString(textBody.getInputStream(), 
Charsets.UTF_8));
     }
 
     private MessageContent retrieveHtmlAndPlainTextContent(Multipart 
multipart) throws IOException {


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

Reply via email to