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 bt...@apache.org on 2017/05/15 01:13:16 UTC
[2/5] james-project git commit: JAMES-2019 The preview string should
be normalizied
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 <qn...@linagora.com>
Authored: Mon May 8 16:32:34 2017 +0700
Committer: benwa <bt...@linagora.com>
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: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org