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 4aebc71754d77e16463588b5c6db97c10a3e1f6f Author: Benoit TELLIER <[email protected]> AuthorDate: Wed Feb 14 01:23:33 2024 +0100 [FIX] multipart/alternative with attachment had no text value indexed The text extraction algorithm was not walking down the mime structure but stopped at the first level. --- .../java/org/apache/james/mailbox/opensearch/json/MimePart.java | 9 ++++++--- mailbox/opensearch/src/test/resources/eml/alternative.eml | 2 +- mailbox/opensearch/src/test/resources/eml/alternative.json | 8 ++++---- 3 files changed, 11 insertions(+), 8 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 30ee7e3923..b400929f71 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 @@ -312,10 +312,13 @@ public class MimePart { } private Stream<MimePart> textAttachments() { + return allAttachments().filter(this::isTextMediaType); + } + + private Stream<MimePart> allAttachments() { return Stream.concat( - Stream.of(this), - attachments.stream()) - .filter(this::isTextMediaType); + Stream.of(this), + attachments.stream().flatMap(MimePart::allAttachments)); } private boolean isTextMediaType(MimePart mimePart) { diff --git a/mailbox/opensearch/src/test/resources/eml/alternative.eml b/mailbox/opensearch/src/test/resources/eml/alternative.eml index 812cdb9e44..30b57dd743 100644 --- a/mailbox/opensearch/src/test/resources/eml/alternative.eml +++ b/mailbox/opensearch/src/test/resources/eml/alternative.eml @@ -26,7 +26,7 @@ Content-Transfer-Encoding: quoted-printable ---=Part.17e.48ac92d73c356567.18da4b40791.360a293e2f389efe=--- ---=Part.17f.732e3d28e1c76db4.18da4b40791.62ef5e3fa995057d=- -Content-Type: text/plain; name="=?US-ASCII?Q?id=5Frsa.txt?=" +Content-Type: application/json; name="=?US-ASCII?Q?id=5Frsa.txt?=" Content-Disposition: attachment Content-Transfer-Encoding: base64 diff --git a/mailbox/opensearch/src/test/resources/eml/alternative.json b/mailbox/opensearch/src/test/resources/eml/alternative.json index 3cdb6043d1..4c08c45d45 100644 --- a/mailbox/opensearch/src/test/resources/eml/alternative.json +++ b/mailbox/opensearch/src/test/resources/eml/alternative.json @@ -1,17 +1,17 @@ { "attachments":[ { - "mediaType":"text", - "subtype":"plain", + "mediaType":"application", + "subtype":"json", "fileName":null, "fileExtension":null, "contentDisposition":"attachment", - "textContent":"ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQCkGW2JysiJGhPewA9tkmQEBnDV4ZCIe//vdZ2WDrnvb6VKC7iZWc81iSVdLW1RDANYxsq17GPjzU8YVvOlFAIJMVNoDIhnAkX9OUQBiwXi8yGgqK4dtFb1s2AG3kBlMPQI8NJ2JKOfy1nuVrnlKhT9BVzX2nbJ3NjOOfY1BRDh6YqYukdnz0TOi5FJuaBS46PzlwygHkGsypKTs6caT60Qv9wyaZvn2zsuFcL/z62gwhfrdaljAuPdWpDe4mHEQf1p6IsQ07OoIpNdGCKKdtYBUSrKsMti2YKPfiK0vXe5/z0EbDVTckPkcspCg0aVne0vxUlDkvSjpWkbBFta99zBc9YI/DN+o/FkN6QSuuySom46djfiR7jK3LFbJRHZzoAnSoi6oFTt1mKZ3sjn8nvVPmOWzIXv4NmNGQ1dqkWXWqKrB9H [...] + "textContent":null } ], "bcc":[], "htmlBody":null, - "textBody":"ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQCkGW2JysiJGhPewA9tkmQEBnDV4ZCIe//vdZ2WDrnvb6VKC7iZWc81iSVdLW1RDANYxsq17GPjzU8YVvOlFAIJMVNoDIhnAkX9OUQBiwXi8yGgqK4dtFb1s2AG3kBlMPQI8NJ2JKOfy1nuVrnlKhT9BVzX2nbJ3NjOOfY1BRDh6YqYukdnz0TOi5FJuaBS46PzlwygHkGsypKTs6caT60Qv9wyaZvn2zsuFcL/z62gwhfrdaljAuPdWpDe4mHEQf1p6IsQ07OoIpNdGCKKdtYBUSrKsMti2YKPfiK0vXe5/z0EbDVTckPkcspCg0aVne0vxUlDkvSjpWkbBFta99zBc9YI/DN+o/FkN6QSuuySom46djfiR7jK3LFbJRHZzoAnSoi6oFTt1mKZ3sjn8nvVPmOWzIXv4NmNGQ1dqkWXWqKrB9HeFbBtOY [...] + "textBody": "Test\r\n", "cc":[], "date":"2015-06-07T00:00:00+0200", "from":[{"name":"Benoit TELLIER","address":"[email protected]","domain":"linagora"}], --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
