This is an automated email from the ASF dual-hosted git repository. rcordier pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/james-project.git
commit a9cbc58604e403258a7e27dde15358e4684984db Author: Benoit TELLIER <[email protected]> AuthorDate: Wed Feb 14 01:11:35 2024 +0100 [FIX] Do not double index multipart/alternative Was both indexing textPlain version and text/html version. --- .../java/org/apache/james/mailbox/opensearch/json/MimePart.java | 5 ++++- mailbox/opensearch/src/test/resources/eml/alternative_simple.json | 2 +- mailbox/store/src/test/resources/eml/htmlMail.json | 2 +- .../org/apache/james/imap/scripts/UidSearchAtomsIndexer.test | 8 ++++---- 4 files changed, 10 insertions(+), 7 deletions(-) diff --git a/mailbox/opensearch/src/main/java/org/apache/james/mailbox/opensearch/json/MimePart.java b/mailbox/opensearch/src/main/java/org/apache/james/mailbox/opensearch/json/MimePart.java index be9c1a3fdc..30ee7e3923 100644 --- a/mailbox/opensearch/src/main/java/org/apache/james/mailbox/opensearch/json/MimePart.java +++ b/mailbox/opensearch/src/main/java/org/apache/james/mailbox/opensearch/json/MimePart.java @@ -297,8 +297,11 @@ public class MimePart { @JsonIgnore public Optional<String> locateFirstHtmlBody() { - return firstBody(textAttachments() + if (locateFirstTextBody().isEmpty()) { + return firstBody(textAttachments() .filter(this::isHtmlSubType)); + } + return Optional.empty(); } private Optional<String> firstBody(Stream<MimePart> mimeParts) { diff --git a/mailbox/opensearch/src/test/resources/eml/alternative_simple.json b/mailbox/opensearch/src/test/resources/eml/alternative_simple.json index a3640dc0e8..50ce79eeec 100644 --- a/mailbox/opensearch/src/test/resources/eml/alternative_simple.json +++ b/mailbox/opensearch/src/test/resources/eml/alternative_simple.json @@ -1,7 +1,7 @@ { "attachments":[], "bcc":[], - "htmlBody":"<div>Test<br><br></div>\r\n", + "htmlBody": null, "textBody":"Test\r\n", "cc":[], "date":"2015-06-07T00:00:00+0200", diff --git a/mailbox/store/src/test/resources/eml/htmlMail.json b/mailbox/store/src/test/resources/eml/htmlMail.json index 8effa69e3c..e9803bc164 100644 --- a/mailbox/store/src/test/resources/eml/htmlMail.json +++ b/mailbox/store/src/test/resources/eml/htmlMail.json @@ -121,7 +121,7 @@ "sentDate":"2015-06-04T07:36:08+0000", "attachments":[], "textBody": "The text/plain part is not matching the html one.\r\n", - "htmlBody": "<html>\r\n <head>\r\n\r\n <meta http-equiv=\"content-type\" content=\"text/html; charset=utf-8\">\r\n </head>\r\n <body bgcolor=\"#FFFFFF\" text=\"#000000\">\r\n <i>This is a mail with <b>beautifull</b> html content which contains a banana.</i><br>\r\n </body>\r\n</html>\r\n", + "htmlBody": null, "isDeleted":true, "isDraft":false, "isAnswered":false, diff --git a/mpt/impl/imap-mailbox/core/src/main/resources/org/apache/james/imap/scripts/UidSearchAtomsIndexer.test b/mpt/impl/imap-mailbox/core/src/main/resources/org/apache/james/imap/scripts/UidSearchAtomsIndexer.test index 72868bddd6..0ab2ae18b1 100644 --- a/mpt/impl/imap-mailbox/core/src/main/resources/org/apache/james/imap/scripts/UidSearchAtomsIndexer.test +++ b/mpt/impl/imap-mailbox/core/src/main/resources/org/apache/james/imap/scripts/UidSearchAtomsIndexer.test @@ -1948,7 +1948,7 @@ S: \* 19 EXISTS S: \* 19 RECENT S: A82 OK (\[.+\] )?APPEND completed\. -C: A801 APPEND testmailbox {900+} +C: A801 APPEND testmailbox {929+} C: From: Timothy Tayler <[email protected]> C: To: Samual Smith <[email protected]> C: Date: Wed, 20 Jul 2016 15:30:00 +0000 (GMT) @@ -1963,7 +1963,7 @@ C: --------------E8CB67F44E1EBC80F62E6ACF C: Content-Type: text/plain; charset=utf-8; format=flowed C: Content-Transfer-Encoding: 7bit C: -C: Text +C: This is html mail, with a banana. C: C: --------------E8CB67F44E1EBC80F62E6ACF C: Content-Type: text/html; charset=utf-8 @@ -1984,7 +1984,7 @@ S: \* 20 EXISTS S: \* 20 RECENT S: A801 OK (\[.+\] )?APPEND completed\. -C: A802 APPEND testmailbox {886+} +C: A802 APPEND testmailbox {915+} C: From: Timothy Tayler <[email protected]> C: To: Samual Smith <[email protected]> C: Date: Wed, 20 Jul 2016 15:30:00 +0000 (GMT) @@ -1999,7 +1999,7 @@ C: --------------E8CB67F44E1EBC80F62E6ACF C: Content-Type: text/plain; charset=utf-8; format=flowed C: Content-Transfer-Encoding: 7bit C: -C: Text +C: This is html mail, with a banana. C: C: --------------E8CB67F44E1EBC80F62E6ACF C: Content-Type: text/html; charset=utf-8 --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
