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 <lro...@linagora.com> Authored: Thu Jul 28 09:42:32 2016 +0200 Committer: Laura Royet <lro...@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\": \"some...@example.com\"}]," + + " \"subject\": \"تصÙر ÙØ§Ø¶Ø ÙÙعÙاÙØ© بÙ٠اÙÙÙ Ùذج اÙرÙاض٠اÙ٠ثاÙÙ ÙÙ ÙظÙÙ Ø© اÙظÙاÙر\"," + + " \"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("تصÙر ÙØ§Ø¶Ø ÙÙعÙاÙØ© بÙ٠اÙÙÙ Ùذج اÙرÙاض٠اÙ٠ثاÙÙ ÙÙ ÙظÙÙ Ø© اÙظÙاÙر")); + } @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-unsubscr...@james.apache.org For additional commands, e-mail: server-dev-h...@james.apache.org