Repository: james-project Updated Branches: refs/heads/master 18bca9849 -> 37761372f
MAILET-107 Regarding RFC-2183 content disposition should be used for attachment detection Especially one can use inlined files that are not considered as attachments, as they should be displayed in the message body by the MUA Project: http://git-wip-us.apache.org/repos/asf/james-project/repo Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/829dfc69 Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/829dfc69 Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/829dfc69 Branch: refs/heads/master Commit: 829dfc697ca47cb55d21d868873679c18a5aed8d Parents: 18bca98 Author: Benoit Tellier <btell...@linagora.com> Authored: Wed Aug 17 15:03:57 2016 +0700 Committer: Benoit Tellier <btell...@linagora.com> Committed: Mon Aug 29 19:28:59 2016 +0700 ---------------------------------------------------------------------- .../apache/james/transport/matchers/HasAttachment.java | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/james-project/blob/829dfc69/mailet/standard/src/main/java/org/apache/james/transport/matchers/HasAttachment.java ---------------------------------------------------------------------- diff --git a/mailet/standard/src/main/java/org/apache/james/transport/matchers/HasAttachment.java b/mailet/standard/src/main/java/org/apache/james/transport/matchers/HasAttachment.java index a7b842b..a998039 100644 --- a/mailet/standard/src/main/java/org/apache/james/transport/matchers/HasAttachment.java +++ b/mailet/standard/src/main/java/org/apache/james/transport/matchers/HasAttachment.java @@ -31,6 +31,8 @@ import javax.mail.Part; import javax.mail.internet.MimeMessage; import java.util.Collection; +import com.google.common.base.Objects; + /** * Checks whether this message has an attachment * @@ -64,8 +66,7 @@ public class HasAttachment extends GenericMatcher { for (int i = 0; i < multipart.getCount(); i++) { try { Part part = multipart.getBodyPart(i); - String fileName = part.getFileName(); - if (fileName != null) { + if (isAttachment(part)) { return mail.getRecipients(); // file found } } catch (MessagingException e) { @@ -73,8 +74,7 @@ public class HasAttachment extends GenericMatcher { } // ignore any messaging exception and process next bodypart } } else { - String fileName = message.getFileName(); - if (fileName != null) { + if (isAttachment(message)) { return mail.getRecipients(); // file found } } @@ -89,4 +89,8 @@ public class HasAttachment extends GenericMatcher { return null; // no attachment found } + + private boolean isAttachment(Part part) throws MessagingException { + return Objects.equal(part.getDisposition(), MimeMessage.ATTACHMENT); + } } --------------------------------------------------------------------- To unsubscribe, e-mail: server-dev-unsubscr...@james.apache.org For additional commands, e-mail: server-dev-h...@james.apache.org