james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From btell...@apache.org
Subject [3/6] james-project git commit: JAMES-1900 In memory message search should unfold and decode headers
Date Tue, 06 Jun 2017 02:04:26 GMT
JAMES-1900 In memory message search should unfold and decode headers


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

Branch: refs/heads/master
Commit: beefb43bd3c71701d189e9c70b385394b1f4f680
Parents: bf5a68c
Author: benwa <btellier@linagora.com>
Authored: Fri May 5 10:39:39 2017 +0700
Committer: benwa <btellier@linagora.com>
Committed: Mon Jun 5 20:24:51 2017 +0700

----------------------------------------------------------------------
 .../james/mailbox/store/search/MessageSearches.java    | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/beefb43b/mailbox/store/src/main/java/org/apache/james/mailbox/store/search/MessageSearches.java
----------------------------------------------------------------------
diff --git a/mailbox/store/src/main/java/org/apache/james/mailbox/store/search/MessageSearches.java
b/mailbox/store/src/main/java/org/apache/james/mailbox/store/search/MessageSearches.java
index 140b34b..7bb255c 100644
--- a/mailbox/store/src/main/java/org/apache/james/mailbox/store/search/MessageSearches.java
+++ b/mailbox/store/src/main/java/org/apache/james/mailbox/store/search/MessageSearches.java
@@ -51,6 +51,8 @@ import org.apache.james.mailbox.store.mail.model.impl.PropertyBuilder;
 import org.apache.james.mailbox.store.search.comparator.CombinedComparator;
 import org.apache.james.mime4j.MimeException;
 import org.apache.james.mime4j.MimeIOException;
+import org.apache.james.mime4j.codec.DecodeMonitor;
+import org.apache.james.mime4j.codec.DecoderUtil;
 import org.apache.james.mime4j.dom.Message;
 import org.apache.james.mime4j.dom.address.Address;
 import org.apache.james.mime4j.dom.address.AddressList;
@@ -67,6 +69,7 @@ import org.apache.james.mime4j.message.DefaultMessageBuilder;
 import org.apache.james.mime4j.message.DefaultMessageWriter;
 import org.apache.james.mime4j.message.HeaderImpl;
 import org.apache.james.mime4j.stream.MimeConfig;
+import org.apache.james.mime4j.util.MimeUtil;
 import org.apache.james.mime4j.utils.search.MessageMatcher;
 
 import com.google.common.base.Function;
@@ -88,6 +91,12 @@ public class MessageSearches implements Iterable<SimpleMessageSearchIndex.Search
         .setMaxLineLen(-1)
         .build();
 
+    private static String sanitizeHeaderField(String headerValue) {
+        return DecoderUtil.decodeEncodedWords(
+            MimeUtil.unfold(headerValue),
+            DecodeMonitor.SILENT);
+    }
+
     private Iterator<MailboxMessage> messages;
     private SearchQuery query;
     private MailboxSession session;
@@ -470,7 +479,7 @@ public class MessageSearches implements Iterable<SimpleMessageSearchIndex.Search
         for (Header header : headers) {
             String name = header.getName();
             if (headerName.equalsIgnoreCase(name)) {
-                String value = header.getValue();
+                String value = sanitizeHeaderField(header.getValue());
                 if (value != null) {
                     if (value.toUpperCase(Locale.US).contains(text)) {
                         result = true;
@@ -520,7 +529,7 @@ public class MessageSearches implements Iterable<SimpleMessageSearchIndex.Search
         for (Header header : headers) {
             String name = header.getName();
             if (headerName.equalsIgnoreCase(name)) {
-                value = header.getValue();
+                value = sanitizeHeaderField(header.getValue());
                 break;
             }
         }


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


Mime
View raw message