You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2023/10/23 13:05:33 UTC

[camel] branch camel-4.0.x updated: CAMEL-20028: camel-mail - Make disposition optional if filename is non empty (#11811)

This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch camel-4.0.x
in repository https://gitbox.apache.org/repos/asf/camel.git


The following commit(s) were added to refs/heads/camel-4.0.x by this push:
     new a8005f063b8 CAMEL-20028: camel-mail - Make disposition optional if filename is non empty (#11811)
a8005f063b8 is described below

commit a8005f063b8cc872f5a523ca50aa4f197e495996
Author: Benjamin Graf <gr...@users.noreply.github.com>
AuthorDate: Mon Oct 23 15:03:58 2023 +0200

    CAMEL-20028: camel-mail - Make disposition optional if filename is non empty (#11811)
---
 .../apache/camel/component/mail/MailBinding.java   |  2 +-
 .../component/mail/MailAttachmentNamesTest.java    | 12 ++++++++++
 .../src/test/resources/disposition_none.txt        | 26 ++++++++++++++++++++++
 3 files changed, 39 insertions(+), 1 deletion(-)

diff --git a/components/camel-mail/src/main/java/org/apache/camel/component/mail/MailBinding.java b/components/camel-mail/src/main/java/org/apache/camel/component/mail/MailBinding.java
index 7b0399e0b7c..ffaccb1184f 100644
--- a/components/camel-mail/src/main/java/org/apache/camel/component/mail/MailBinding.java
+++ b/components/camel-mail/src/main/java/org/apache/camel/component/mail/MailBinding.java
@@ -399,7 +399,7 @@ public class MailBinding {
                     LOG.trace("Part #{}: LineCount: {}", i, part.getLineCount());
                 }
 
-                if (validDisposition(disposition, fileName)) {
+                if (validDisposition(disposition, fileName) || (fileName != null && !fileName.isEmpty())) {
                     LOG.debug("Mail contains file attachment: {}", fileName);
                     if (handleDuplicateAttachmentNames != null) {
                         if (handleDuplicateAttachmentNames
diff --git a/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailAttachmentNamesTest.java b/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailAttachmentNamesTest.java
index 464d8407c75..abfb26695ac 100644
--- a/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailAttachmentNamesTest.java
+++ b/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailAttachmentNamesTest.java
@@ -246,6 +246,18 @@ public class MailAttachmentNamesTest extends CamelTestSupport {
         }
     }
 
+    @Test
+    public void testAttachmentWithNoDisposition() throws Exception {
+        sendTestMessage("disposition_none.txt", default_);
+
+        resultDefaultEndpoint.assertIsSatisfied();
+        Exchange exchange = resultDefaultEndpoint.getReceivedExchanges().get(0);
+        assertEquals(1, exchange.getIn(AttachmentMessage.class).getAttachmentObjects().entrySet().size());
+
+        Map<String, Attachment> attachments = exchange.getIn(AttachmentMessage.class).getAttachmentObjects();
+        assertNotNull(attachments.get("test.jpg"));
+    }
+
     private void sendTestMessage(String filename, MailboxUser recipient) throws MessagingException, FileNotFoundException {
         MimeMessage message = populateMimeMessage(session, filename);
         message.setRecipients(Message.RecipientType.TO, recipient.getEmail());
diff --git a/components/camel-mail/src/test/resources/disposition_none.txt b/components/camel-mail/src/test/resources/disposition_none.txt
new file mode 100644
index 00000000000..848cd75b4a8
--- /dev/null
+++ b/components/camel-mail/src/test/resources/disposition_none.txt
@@ -0,0 +1,26 @@
+Date: Fri, 25 Feb 2022 20:55:29 +0100 (CET)
+From: receiver@test.com
+To: receiver@test.com
+Message-ID: <51...@host.docker.internal>
+Subject: This is the mail subject
+MIME-Version: 1.0
+Content-Type: multipart/mixed; 
+	boundary="----=_Part_0_932607259.1645818929513"
+
+------=_Part_0_932607259.1645818929513
+Content-Type: text/plain; charset=us-ascii
+Content-Transfer-Encoding: 7bit
+
+This is the message body
+------=_Part_0_932607259.1645818929513
+Content-Type: image/jpeg; name="test.jpg"
+Content-Transfer-Encoding: base64
+
+/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAAUDBAQEAwUEBAQFBQUGBwwIBwcHBw8LCwkMEQ8SEhEP
+ERETFhwXExQaFRERGCEYGh0dHx8fExciJCIeJBweHx7/2wBDAQUFBQcGBw4ICA4eFBEUHh4eHh4e
+Hh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh7/wAARCAFhAWMDASIA
+AhEBAxEB/8QAHwAAAQUBAQEBAQEAAAAAAAAAAAECAwQFBgcICQoL/8QAtRAAAgEDAwIEAwUFBAQA
+AAF9AQIDAAQRBRIhMUEGE1FhByJxFDKBkaEII0KxwRVS0fAkM2JyggkKFhcYGRolJicoKSo0NTY3
+ODk6Q0RFRkdISUpTVFVWV1hZWmNkZ
+------=_Part_0_932607259.1645818929513--
+