You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@james.apache.org by bt...@apache.org on 2021/08/13 04:56:53 UTC
[james-project] branch master updated: JAMES-3516
SearchUtil::getBaseSubject should not rely on regex to normalize spaces
(#585)
This is an automated email from the ASF dual-hosted git repository.
btellier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git
The following commit(s) were added to refs/heads/master by this push:
new 262dced JAMES-3516 SearchUtil::getBaseSubject should not rely on regex to normalize spaces (#585)
262dced is described below
commit 262dcedfba4cdbc57f650da1f43b58b50f4f253b
Author: Tellier Benoit <bt...@linagora.com>
AuthorDate: Fri Aug 13 11:56:50 2021 +0700
JAMES-3516 SearchUtil::getBaseSubject should not rely on regex to normalize spaces (#585)
The usage of this method is now common due
to the thread guessing stuff, we can easily
get rid of the regex by relying on
commonsString StringUtils::normalizeSpace
---
.../org/apache/james/mailbox/store/search/SearchUtil.java | 12 +++++-------
1 file changed, 5 insertions(+), 7 deletions(-)
diff --git a/mailbox/store/src/main/java/org/apache/james/mailbox/store/search/SearchUtil.java b/mailbox/store/src/main/java/org/apache/james/mailbox/store/search/SearchUtil.java
index 3a45f7f..8046cc3 100644
--- a/mailbox/store/src/main/java/org/apache/james/mailbox/store/search/SearchUtil.java
+++ b/mailbox/store/src/main/java/org/apache/james/mailbox/store/search/SearchUtil.java
@@ -18,13 +18,12 @@
****************************************************************/
package org.apache.james.mailbox.store.search;
-import static java.nio.charset.StandardCharsets.UTF_8;
-
import java.util.HashSet;
import java.util.Locale;
import java.util.Set;
import java.util.function.Predicate;
+import org.apache.commons.lang3.StringUtils;
import org.apache.james.mailbox.model.MessageId;
import org.apache.james.mailbox.model.ThreadId;
import org.apache.james.mailbox.store.mail.model.MailboxMessage;
@@ -53,7 +52,7 @@ public class SearchUtil {
private static final char OPEN_SQUARE_BRACKED = '[';
private static final char CLOSE_SQUARE_BRACKED = ']';
private static final char COLON = ':';
-
+
/**
* Return the DISPLAY ADDRESS for the given {@link Mailbox}.
*
@@ -240,11 +239,10 @@ public class SearchUtil {
// as described in "Internationalization Considerations".
// Convert all tabs and continuations to space. Convert all
// multiple spaces to a single space.
- String decodedSubject = MimeUtil.unfold(DecoderUtil.decodeEncodedWords(subject, DecodeMonitor.SILENT));
- decodedSubject = new String(decodedSubject.getBytes(UTF_8), UTF_8);
-
// replace all tabs with spaces and replace multiple spaces with one space
- decodedSubject = decodedSubject.replaceAll("\t", " ").replaceAll("( ){2,}", " ");
+ String decodedSubject = StringUtils.normalizeSpace(
+ MimeUtil.unfold(
+ DecoderUtil.decodeEncodedWords(subject, DecodeMonitor.SILENT)));
while (true) {
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For additional commands, e-mail: notifications-help@james.apache.org