CAMEL-6654: Attachments with null filename should not be allowed. Thanks to 
Christian Posta for the patch.


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/3d93c7fb
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/3d93c7fb
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/3d93c7fb

Branch: refs/heads/camel-2.11.x
Commit: 3d93c7fb36addeee9a5bd16f01a76d31b00743f2
Parents: 83e0e5c
Author: Claus Ibsen <davscl...@apache.org>
Authored: Tue Oct 1 10:37:59 2013 +0200
Committer: Claus Ibsen <davscl...@apache.org>
Committed: Tue Oct 1 10:38:25 2013 +0200

----------------------------------------------------------------------
 .../java/org/apache/camel/component/mail/MailBinding.java    | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/3d93c7fb/components/camel-mail/src/main/java/org/apache/camel/component/mail/MailBinding.java
----------------------------------------------------------------------
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 e1efc45..806c771 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
@@ -321,7 +321,7 @@ public class MailBinding {
                     LOG.trace("Part #{}: LineCount: {}", i, 
part.getLineCount());
                 }
 
-                if ((disposition != null && 
(disposition.equalsIgnoreCase(Part.ATTACHMENT) || 
disposition.equalsIgnoreCase(Part.INLINE)))
+                if (validDisposition(disposition, fileName)
                         || fileName != null) {
                     LOG.debug("Mail contains file attachment: {}", fileName);
                     if (!map.containsKey(fileName)) {
@@ -335,6 +335,12 @@ public class MailBinding {
         }
     }
 
+    private boolean validDisposition(String disposition, String fileName) {
+        return disposition != null
+                && fileName != null
+                && (disposition.equalsIgnoreCase(Part.ATTACHMENT) || 
disposition.equalsIgnoreCase(Part.INLINE));
+    }
+
     /**
      * Appends the Mail headers from the Camel {@link MailMessage}
      */

Reply via email to