You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-dev@james.apache.org by ro...@apache.org on 2016/08/19 07:49:04 UTC

[1/2] james-project git commit: JAMES-1813 Encoding issues in subject with non ASCII characters

Repository: james-project
Updated Branches:
  refs/heads/master 4ac57ec9e -> e708298ac


JAMES-1813 Encoding issues in subject with non ASCII characters


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

Branch: refs/heads/master
Commit: 4f70214aba204d533bb29f41390dc84a81d4894b
Parents: db5a3b8
Author: Laura Royet <lr...@linagora.com>
Authored: Thu Jul 28 09:42:32 2016 +0200
Committer: Laura Royet <lr...@linagora.com>
Committed: Thu Jul 28 16:42:45 2016 +0200

----------------------------------------------------------------------
 .../integration/SetMessagesMethodTest.java      | 34 ++++++++++++++++++++
 .../jmap/model/message/HeaderCollection.java    |  4 ++-
 2 files changed, 37 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/4f70214a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/SetMessagesMethodTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/SetMessagesMethodTest.java b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/SetMessagesMethodTest.java
index 2bd9003..9bb8220 100644
--- a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/SetMessagesMethodTest.java
+++ b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/SetMessagesMethodTest.java
@@ -753,6 +753,40 @@ public abstract class SetMessagesMethodTest {
             .body(ARGUMENTS + ".created", hasKey(messageCreationId))
             .body(ARGUMENTS + ".created[\""+messageCreationId+"\"].subject", equalTo(""));
     }
+    
+    @Test
+    public void setMessageShouldReturnCreatedMessageWithNonASCIICharactersInSubjectWhenPresent() {
+        String messageCreationId = "user|inbox|1";
+        String fromAddress = username;
+        String requestBody = "[" +
+                "  [" +
+                "    \"setMessages\","+
+                "    {" +
+                "      \"create\": { \"" + messageCreationId  + "\" : {" +
+                "        \"from\": { \"name\": \"Me\", \"email\": \"" + fromAddress + "\"}," +
+                "        \"to\": [{ \"name\": \"BOB\", \"email\": \"someone@example.com\"}]," +
+                "        \"subject\": \"\u062a\u0635\u0648\u0631 \u0648\u0627\u0636\u062d \u0644\u0644\u0639\u0644\u0627\u0642\u0629 \u0628\u064a\u0646 \u0627\u0644\u0646\u0645\u0648\u0630\u062c \u0627\u0644\u0631\u064a\u0627\u0636\u064a \u0627\u0644\u0645\u062b\u0627\u0644\u064a \u0648\u0645\u0646\u0638\u0648\u0645\u0629 \u0627\u0644\u0638\u0648\u0627\u0647\u0631\"," +
+                "        \"mailboxIds\": [\"" + getOutboxId(accessToken) + "\"]" +
+                "      }}" +
+                "    }," +
+                "    \"#0\"" +
+                "  ]" +
+                "]";
+
+        given()
+            .header("Authorization", accessToken.serialize())
+            .body(requestBody)
+       .when()
+            .post("/jmap")
+       .then()
+            .log().ifValidationFails()
+            .statusCode(200)
+            .body(NAME, equalTo("messagesSet"))
+            .body(ARGUMENTS + ".notCreated", aMapWithSize(0))
+            .body(ARGUMENTS + ".created", aMapWithSize(1))
+            .body(ARGUMENTS + ".created", hasKey(messageCreationId))
+            .body(ARGUMENTS + ".created[\""+messageCreationId+"\"].subject", equalTo("\u062a\u0635\u0648\u0631 \u0648\u0627\u0636\u062d \u0644\u0644\u0639\u0644\u0627\u0642\u0629 \u0628\u064a\u0646 \u0627\u0644\u0646\u0645\u0648\u0630\u062c \u0627\u0644\u0631\u064a\u0627\u0636\u064a \u0627\u0644\u0645\u062b\u0627\u0644\u064a \u0648\u0645\u0646\u0638\u0648\u0645\u0629 \u0627\u0644\u0638\u0648\u0627\u0647\u0631"));
+    }
 
     @Test
     public void setMessageShouldSupportArbitraryMessageId() {

http://git-wip-us.apache.org/repos/asf/james-project/blob/4f70214a/server/protocols/jmap/src/main/java/org/apache/james/jmap/model/message/HeaderCollection.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap/src/main/java/org/apache/james/jmap/model/message/HeaderCollection.java b/server/protocols/jmap/src/main/java/org/apache/james/jmap/model/message/HeaderCollection.java
index c08f85b..03a99f2 100644
--- a/server/protocols/jmap/src/main/java/org/apache/james/jmap/model/message/HeaderCollection.java
+++ b/server/protocols/jmap/src/main/java/org/apache/james/jmap/model/message/HeaderCollection.java
@@ -20,12 +20,14 @@
 package org.apache.james.jmap.model.message;
 
 import com.google.common.annotations.VisibleForTesting;
+import com.google.common.base.Charsets;
 import com.google.common.base.Preconditions;
 import com.google.common.collect.ArrayListMultimap;
 import com.google.common.collect.ImmutableMultimap;
 import com.google.common.collect.ImmutableSet;
 import com.google.common.collect.Multimap;
 import org.apache.james.mailbox.store.search.SearchUtil;
+import org.apache.james.mime4j.codec.DecoderUtil;
 import org.apache.james.mime4j.dom.address.Address;
 import org.apache.james.mime4j.dom.address.Group;
 import org.apache.james.mime4j.dom.address.Mailbox;
@@ -80,7 +82,7 @@ public class HeaderCollection {
         public Builder add(Field field) {
             Preconditions.checkNotNull(field);
             String headerName = field.getName().toLowerCase();
-            String headerValue = field.getBody();
+            String headerValue = DecoderUtil.decodeEncodedWords(field.getBody(), Charsets.ISO_8859_1);
             headers.put(headerName, headerValue);
             handleSpecificHeader(headerName, headerValue);
             return this;


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


[2/2] james-project git commit: Merge remote-tracking branch 'laura/JAMES-1813-2'

Posted by ro...@apache.org.
Merge remote-tracking branch 'laura/JAMES-1813-2'


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

Branch: refs/heads/master
Commit: e708298ac25b22c3253fcc2d8bfa14fe9e8c3ae4
Parents: 4ac57ec 4f70214
Author: Raphael Ouazana <ra...@linagora.com>
Authored: Fri Aug 19 09:45:53 2016 +0200
Committer: Raphael Ouazana <ra...@linagora.com>
Committed: Fri Aug 19 09:45:53 2016 +0200

----------------------------------------------------------------------
 .../integration/SetMessagesMethodTest.java      | 34 ++++++++++++++++++++
 .../jmap/model/message/HeaderCollection.java    |  4 ++-
 2 files changed, 37 insertions(+), 1 deletion(-)
----------------------------------------------------------------------



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