From 7f89a8dd8a0444e1344450b24dfcd978202e3342 Mon Sep 17 00:00:00 2001 From: Niklas Therning Date: Thu, 10 Jul 2008 19:37:09 +0000 Subject: [PATCH] Resolved MIME4J-47: Applied patch contributed by Oleg Kalnichevski. git-svn-id: https://svn.eu.apache.org/repos/asf/james/mime4j/trunk@675695 13f79535-47bb-0310-9956-ffa450edef68 --- .../james/mime4j/MimeBoundaryInputStream.java | 1 + .../apache/james/mime4j/MultipartTokensTest.java | 43 ++++++++++++++++++++++ 2 files changed, 44 insertions(+) diff --git a/src/main/java/org/apache/james/mime4j/MimeBoundaryInputStream.java b/src/main/java/org/apache/james/mime4j/MimeBoundaryInputStream.java index 822c2a9..4e019c5 100644 --- a/src/main/java/org/apache/james/mime4j/MimeBoundaryInputStream.java +++ b/src/main/java/org/apache/james/mime4j/MimeBoundaryInputStream.java @@ -127,6 +127,7 @@ public class MimeBoundaryInputStream extends BufferingInputStream { public void reset() { atBoundary = false; limit = -1; + eof = false; } public int readLine(final ByteArrayBuffer dst) throws IOException { diff --git a/src/test/java/org/apache/james/mime4j/MultipartTokensTest.java b/src/test/java/org/apache/james/mime4j/MultipartTokensTest.java index 51e8011..36e33be 100644 --- a/src/test/java/org/apache/james/mime4j/MultipartTokensTest.java +++ b/src/test/java/org/apache/james/mime4j/MultipartTokensTest.java @@ -101,6 +101,49 @@ public class MultipartTokensTest extends TestCase { checkState(MimeTokenStream.T_END_OF_STREAM); } + public void testShouldParseMoreComplexMessage() throws Exception { + String message = + "Content-Type: multipart/alternative; boundary=\"outer-boundary\"\r\n" + + "\r\n" + + "--outer-boundary\r\n" + + "Content-Type: multipart/alternative; boundary=\"inner-boundary\"\r\n" + + "\r\n" + + "--inner-boundary\r\n" + + "Content-Type: text/plain\r\n" + + "\r\n" + + "Some text\r\n" + + "--inner-boundary--\r\n" + + "\r\n" + + "foo\r\n" + + "--outer-boundary--\r\n"; + + parser.parse(new ByteArrayInputStream(US_ASCII.encode(message).array())); + checkState(MimeTokenStream.T_START_HEADER); + checkState(MimeTokenStream.T_FIELD); + checkState(MimeTokenStream.T_END_HEADER); + checkState(MimeTokenStream.T_START_MULTIPART); + checkState(MimeTokenStream.T_PREAMBLE); + checkState(MimeTokenStream.T_START_BODYPART); + checkState(MimeTokenStream.T_START_HEADER); + checkState(MimeTokenStream.T_FIELD); + checkState(MimeTokenStream.T_END_HEADER); + checkState(MimeTokenStream.T_START_MULTIPART); + checkState(MimeTokenStream.T_PREAMBLE); + checkState(MimeTokenStream.T_START_BODYPART); + checkState(MimeTokenStream.T_START_HEADER); + checkState(MimeTokenStream.T_FIELD); + checkState(MimeTokenStream.T_END_HEADER); + checkState(MimeTokenStream.T_BODY); + checkState(MimeTokenStream.T_END_BODYPART); + checkState(MimeTokenStream.T_EPILOGUE); + checkState(MimeTokenStream.T_END_MULTIPART); + checkState(MimeTokenStream.T_END_BODYPART); + checkState(MimeTokenStream.T_EPILOGUE); + checkState(MimeTokenStream.T_END_MULTIPART); + checkState(MimeTokenStream.T_END_MESSAGE); + checkState(MimeTokenStream.T_END_OF_STREAM); + } + public void testShouldParseMessageWithEmbeddedMessage() throws Exception { parser.parse(new ByteArrayInputStream(US_ASCII.encode(COMPLEX_MESSAGE).array())); checkState(MimeTokenStream.T_START_HEADER); -- 2.11.4.GIT