JAMES-2019 The preview string should be normalizied
Project: http://git-wip-us.apache.org/repos/asf/james-project/repo Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/6573fc89 Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/6573fc89 Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/6573fc89 Branch: refs/heads/master Commit: 6573fc895bf4d167d52b19c344c18329e7b7a8d9 Parents: a56cdba Author: quynhn <[email protected]> Authored: Mon May 8 16:32:34 2017 +0700 Committer: benwa <[email protected]> Committed: Mon May 15 08:10:44 2017 +0700 ---------------------------------------------------------------------- .../org/apache/james/jmap/model/MessagePreviewGenerator.java | 2 +- .../apache/james/jmap/model/MessagePreviewGeneratorTest.java | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/james-project/blob/6573fc89/server/protocols/jmap/src/main/java/org/apache/james/jmap/model/MessagePreviewGenerator.java ---------------------------------------------------------------------- diff --git a/server/protocols/jmap/src/main/java/org/apache/james/jmap/model/MessagePreviewGenerator.java b/server/protocols/jmap/src/main/java/org/apache/james/jmap/model/MessagePreviewGenerator.java index dd1a831..3e4ed12 100644 --- a/server/protocols/jmap/src/main/java/org/apache/james/jmap/model/MessagePreviewGenerator.java +++ b/server/protocols/jmap/src/main/java/org/apache/james/jmap/model/MessagePreviewGenerator.java @@ -35,6 +35,6 @@ public class MessagePreviewGenerator { } private String truncateToMaxLength(String body) { - return StringUtils.left(body, MAX_PREVIEW_LENGTH); + return StringUtils.left(StringUtils.normalizeSpace(body), MAX_PREVIEW_LENGTH); } } http://git-wip-us.apache.org/repos/asf/james-project/blob/6573fc89/server/protocols/jmap/src/test/java/org/apache/james/jmap/model/MessagePreviewGeneratorTest.java ---------------------------------------------------------------------- diff --git a/server/protocols/jmap/src/test/java/org/apache/james/jmap/model/MessagePreviewGeneratorTest.java b/server/protocols/jmap/src/test/java/org/apache/james/jmap/model/MessagePreviewGeneratorTest.java index 54930a9..dd7eef0 100644 --- a/server/protocols/jmap/src/test/java/org/apache/james/jmap/model/MessagePreviewGeneratorTest.java +++ b/server/protocols/jmap/src/test/java/org/apache/james/jmap/model/MessagePreviewGeneratorTest.java @@ -64,4 +64,12 @@ public class MessagePreviewGeneratorTest { .hasSize(MessagePreviewGenerator.MAX_PREVIEW_LENGTH) .isEqualTo(expected); } + + @Test + public void computeShouldReturnNormalizeSpaceString() throws Exception { + String body = " this is\n the\r preview\t content\n\n "; + + assertThat(testee.compute(Optional.of(body))) + .isEqualTo("this is the preview content"); + } } --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
