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
commit 39afa483bd80723c63ca31d3f7ae63eaa322fc09 Author: Rene Cordier <rcord...@linagora.com> AuthorDate: Fri Sep 27 14:35:27 2019 +0700 JAMES-2241 can reindex header fields with dots after upgrading to ES6 --- .../mailbox/elasticsearch/json/HeaderCollection.java | 5 ++--- .../mailbox/elasticsearch/json/HeaderCollectionTest.java | 4 ++-- .../store/search/SimpleMessageSearchIndexTest.java | 5 +++++ .../store/search/AbstractMessageSearchIndexTest.java | 15 +++++++++++++++ 4 files changed, 24 insertions(+), 5 deletions(-) diff --git a/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/json/HeaderCollection.java b/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/json/HeaderCollection.java index f007e69..6e98444 100644 --- a/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/json/HeaderCollection.java +++ b/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/json/HeaderCollection.java @@ -74,9 +74,8 @@ public class HeaderCollection { String rawHeaderValue = field.getBody(); String sanitizedValue = MimeUtil.unscrambleHeaderValue(rawHeaderValue); - if (!headerName.contains(".")) { - headers.put(headerName, sanitizedValue); - } + headers.put(headerName, sanitizedValue); + handleSpecificHeader(headerName, sanitizedValue, rawHeaderValue); return this; } diff --git a/mailbox/elasticsearch/src/test/java/org/apache/james/mailbox/elasticsearch/json/HeaderCollectionTest.java b/mailbox/elasticsearch/src/test/java/org/apache/james/mailbox/elasticsearch/json/HeaderCollectionTest.java index 647bdf8..4252230 100644 --- a/mailbox/elasticsearch/src/test/java/org/apache/james/mailbox/elasticsearch/json/HeaderCollectionTest.java +++ b/mailbox/elasticsearch/src/test/java/org/apache/james/mailbox/elasticsearch/json/HeaderCollectionTest.java @@ -116,13 +116,13 @@ class HeaderCollectionTest { } @Test - void getHeadersShouldIgnoreHeadersWithDots() { + void getHeadersShouldNotIgnoreHeadersWithDots() { HeaderCollection headerCollection = HeaderCollection.builder() .add(new FieldImpl("a.b.c", "value")) .build(); assertThat(headerCollection.getHeaders().get("a.b.c")) - .isEmpty(); + .containsExactly("value"); } @Test diff --git a/mailbox/scanning-search/src/test/java/org/apache/james/mailbox/store/search/SimpleMessageSearchIndexTest.java b/mailbox/scanning-search/src/test/java/org/apache/james/mailbox/store/search/SimpleMessageSearchIndexTest.java index 48ffb16..e44dac6 100644 --- a/mailbox/scanning-search/src/test/java/org/apache/james/mailbox/store/search/SimpleMessageSearchIndexTest.java +++ b/mailbox/scanning-search/src/test/java/org/apache/james/mailbox/store/search/SimpleMessageSearchIndexTest.java @@ -238,4 +238,9 @@ public class SimpleMessageSearchIndexTest extends AbstractMessageSearchIndexTest @Override public void searchWithTextShouldReturnMailsWhenHtmlBodyMatchesWithStemming() throws Exception { } + + @Ignore + @Override + public void headerWithDotsShouldBeIndexed() throws MailboxException { + } } diff --git a/mailbox/store/src/test/java/org/apache/james/mailbox/store/search/AbstractMessageSearchIndexTest.java b/mailbox/store/src/test/java/org/apache/james/mailbox/store/search/AbstractMessageSearchIndexTest.java index 460b4fc..4e78516 100644 --- a/mailbox/store/src/test/java/org/apache/james/mailbox/store/search/AbstractMessageSearchIndexTest.java +++ b/mailbox/store/src/test/java/org/apache/james/mailbox/store/search/AbstractMessageSearchIndexTest.java @@ -423,6 +423,21 @@ public abstract class AbstractMessageSearchIndexTest { } @Test + public void headerWithDotsShouldBeIndexed() throws MailboxException { + + ComposedMessageId mailWithDotsInHeader = myFolderMessageManager.appendMessage( + MessageManager.AppendCommand.builder() + .build(ClassLoader.getSystemResourceAsStream("eml/headerWithDot.eml")), + session); + await(); + + SearchQuery searchQuery = new SearchQuery(SearchQuery.headerExists("X-header.with.dots")); + + assertThat(messageSearchIndex.search(session, mailbox2, searchQuery)) + .contains(mailWithDotsInHeader.getUid()); + } + + @Test public void searchShouldBeExactOnEmailAddresses() throws MailboxException { Assume.assumeTrue(storeMailboxManager.getSupportedSearchCapabilities().contains(MailboxManager.SearchCapabilities.Text)); --------------------------------------------------------------------- To unsubscribe, e-mail: server-dev-unsubscr...@james.apache.org For additional commands, e-mail: server-dev-h...@james.apache.org