This is an automated email from the ASF dual-hosted git repository. matthieu pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/james-project.git
commit fe27fd6b413f1a50bb6de97b64585a23615c279a Author: Benoit Tellier <btell...@linagora.com> AuthorDate: Wed Apr 29 08:56:35 2020 +0700 MAILET-166 Remove AutomaticallySentMailDetectorImpl steam limit As the MDN can optionally include the original message, there is no reason to expect the size to be limited. Thus increase the size to 100 MB --- .../base/AutomaticallySentMailDetectorImpl.java | 6 +--- .../AutomaticallySentMailDetectorImplTest.java | 36 +++++++++++++++++++++- 2 files changed, 36 insertions(+), 6 deletions(-) diff --git a/mailet/base/src/main/java/org/apache/mailet/base/AutomaticallySentMailDetectorImpl.java b/mailet/base/src/main/java/org/apache/mailet/base/AutomaticallySentMailDetectorImpl.java index 6b39613..8953599 100644 --- a/mailet/base/src/main/java/org/apache/mailet/base/AutomaticallySentMailDetectorImpl.java +++ b/mailet/base/src/main/java/org/apache/mailet/base/AutomaticallySentMailDetectorImpl.java @@ -92,7 +92,7 @@ public class AutomaticallySentMailDetectorImpl implements AutomaticallySentMailD public boolean isMdnSentAutomatically(Mail mail) throws MessagingException { ResultCollector resultCollector = new ResultCollector(false); MimeStreamParser parser = new MimeStreamParser(MimeConfig.custom() - .setMaxContentLen(1024 * 1024) // there's no reason for a mdn report to be bigger than 1MiB + .setMaxContentLen(100 * 1024 * 1024) .setMaxHeaderCount(-1) .setMaxHeaderLen(-1) .setMaxLineLen(-1) @@ -104,10 +104,6 @@ public class AutomaticallySentMailDetectorImpl implements AutomaticallySentMailD } catch (MimeException e) { throw new MessagingException("Can not parse Mime", e); } catch (IOException e) { - // there's no reason for a mdn report to be bigger than 1MiB - if (e.getMessage().startsWith("Input stream limit exceeded")) { - return false; - } throw new MessagingException("Can not read content", e); } return resultCollector.getResult(); diff --git a/mailet/base/src/test/java/org/apache/mailet/base/AutomaticallySentMailDetectorImplTest.java b/mailet/base/src/test/java/org/apache/mailet/base/AutomaticallySentMailDetectorImplTest.java index 309ced8..d65422b 100644 --- a/mailet/base/src/test/java/org/apache/mailet/base/AutomaticallySentMailDetectorImplTest.java +++ b/mailet/base/src/test/java/org/apache/mailet/base/AutomaticallySentMailDetectorImplTest.java @@ -25,6 +25,7 @@ import java.util.Collections; import java.util.Properties; import javax.activation.DataHandler; +import javax.mail.BodyPart; import javax.mail.Session; import javax.mail.internet.MimeBodyPart; import javax.mail.internet.MimeMessage; @@ -338,7 +339,7 @@ public class AutomaticallySentMailDetectorImplTest { .addHeaders() .setMultipartWithBodyParts( MimeMessageBuilder.bodyPartBuilder() - .data("12345678\r\n".repeat(150 * 1024)), + .data("12345678\r\n".repeat(150 * 1024)), // ~ 1.5 MB MimeMessageBuilder.bodyPartBuilder() .data("12345678\r\n")); @@ -351,4 +352,37 @@ public class AutomaticallySentMailDetectorImplTest { assertThat(new AutomaticallySentMailDetectorImpl().isMdnSentAutomatically(fakeMail)).isFalse(); } + @Test + public void isMdnSentAutomaticallyShouldDetectBigMDN() throws Exception { + + MimeMessage message = MimeMessageUtil.defaultMimeMessage(); + MimeMultipart multipart = new MimeMultipart(); + MimeBodyPart scriptPart = new MimeBodyPart(); + scriptPart.setDataHandler( + new DataHandler( + new ByteArrayDataSource( + Joiner.on("\r\n").join( + "Final-Recipient: rfc822;a...@any.com", + "Disposition: automatic-action/MDN-sent-automatically; displayed", + ""), + "message/disposition-notification;") + )); + scriptPart.setHeader("Content-Type", "message/disposition-notification"); + BodyPart bigBody = MimeMessageBuilder.bodyPartBuilder() // ~3MB + .data("12345678\r\n".repeat(300 * 1024)) + .build(); + multipart.addBodyPart(bigBody); + multipart.addBodyPart(scriptPart); + message.setContent(multipart); + message.saveChanges(); + + FakeMail fakeMail = FakeMail.builder() + .name("mail") + .sender(MailAddressFixture.ANY_AT_JAMES) + .mimeMessage(message) + .build(); + + assertThat(new AutomaticallySentMailDetectorImpl().isMdnSentAutomatically(fakeMail)).isTrue(); + } + } --------------------------------------------------------------------- To unsubscribe, e-mail: server-dev-unsubscr...@james.apache.org For additional commands, e-mail: server-dev-h...@james.apache.org