james-mime4j-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From b...@apache.org
Subject svn commit: r894645 - in /james/mime4j/branches/cycleclean/core/src: main/java/org/apache/james/mime4j/parser/ test/java/org/apache/james/mime4j/message/ test/java/org/apache/james/mime4j/parser/ test/resources/testmsgs/
Date Wed, 30 Dec 2009 15:22:11 GMT
Author: bago
Date: Wed Dec 30 15:22:10 2009
New Revision: 894645

URL: http://svn.apache.org/viewvc?rev=894645&view=rev
Log:
Refactoring for MimeEntity:
- now takes a simple InputStream in input and add the buffering internally.
- now wants a MutableBodyDescripor to be used for this entity (and not a parent reference
like before) (MIME5J-156)
- MimeEntity/AbstractEntity do not more depend on Maximal/Default BodyDescriptor implementations.
- removed T_IN_BODYPART and T_IN_MESSAGE "dummy" states (they are no more needed) (MIME4J-152)
- Zero parts multipart messages were parsed as 1 empty part multipart messages. Fixed (MIME4J-152)
- Added testmessages for the zero part multipart issue (MIME4J-152)
- MimeEntity.skipHeader removed. Headless parsing is now done simply passing a MutableBodyDescriptor
with the right contenttype and a custom startState to the MimeEntity class (no hacks inside
MimeEntity) (related to MIME4J-153)
- MimeTokenStream headless parsing doesn't start from T_END_HEADER state anymore but from
the following state (MIME4J-153)
- mimeStream renamed to mimePartStream (and also related methods).
- MimeTokenStream now proxy the stop() request to the root mime entity (implemented MimeEntity.stop()).

Added:
    james/mime4j/branches/cycleclean/core/src/test/resources/testmsgs/missing-boundary.msg
    james/mime4j/branches/cycleclean/core/src/test/resources/testmsgs/missing-boundary.out
    james/mime4j/branches/cycleclean/core/src/test/resources/testmsgs/missing-boundary.xml
  (with props)
    james/mime4j/branches/cycleclean/core/src/test/resources/testmsgs/missing-boundary_decoded.xml
  (with props)
    james/mime4j/branches/cycleclean/core/src/test/resources/testmsgs/missing-inner-start-boundary.msg
    james/mime4j/branches/cycleclean/core/src/test/resources/testmsgs/missing-inner-start-boundary.out
    james/mime4j/branches/cycleclean/core/src/test/resources/testmsgs/missing-inner-start-boundary.xml
  (with props)
    james/mime4j/branches/cycleclean/core/src/test/resources/testmsgs/missing-inner-start-boundary_decoded.xml
  (with props)
    james/mime4j/branches/cycleclean/core/src/test/resources/testmsgs/missing-inner-start-boundary_decoded_1_1.txt
  (with props)
Modified:
    james/mime4j/branches/cycleclean/core/src/main/java/org/apache/james/mime4j/parser/AbstractEntity.java
    james/mime4j/branches/cycleclean/core/src/main/java/org/apache/james/mime4j/parser/MimeEntity.java
    james/mime4j/branches/cycleclean/core/src/main/java/org/apache/james/mime4j/parser/MimeTokenStream.java
    james/mime4j/branches/cycleclean/core/src/test/java/org/apache/james/mime4j/message/MessageHeadlessParserTest.java
    james/mime4j/branches/cycleclean/core/src/test/java/org/apache/james/mime4j/parser/MimeEntityTest.java
    james/mime4j/branches/cycleclean/core/src/test/java/org/apache/james/mime4j/parser/MultipartTokensTest.java
    james/mime4j/branches/cycleclean/core/src/test/resources/testmsgs/missing-inner-boundary.out
    james/mime4j/branches/cycleclean/core/src/test/resources/testmsgs/missing-inner-boundary.xml
    james/mime4j/branches/cycleclean/core/src/test/resources/testmsgs/missing-inner-boundary_decoded.xml

Modified: james/mime4j/branches/cycleclean/core/src/main/java/org/apache/james/mime4j/parser/AbstractEntity.java
URL: http://svn.apache.org/viewvc/james/mime4j/branches/cycleclean/core/src/main/java/org/apache/james/mime4j/parser/AbstractEntity.java?rev=894645&r1=894644&r2=894645&view=diff
==============================================================================
--- james/mime4j/branches/cycleclean/core/src/main/java/org/apache/james/mime4j/parser/AbstractEntity.java
(original)
+++ james/mime4j/branches/cycleclean/core/src/main/java/org/apache/james/mime4j/parser/AbstractEntity.java
Wed Dec 30 15:22:10 2009
@@ -25,8 +25,6 @@
 import org.apache.commons.logging.LogFactory;
 import org.apache.james.mime4j.MimeException;
 import org.apache.james.mime4j.descriptor.BodyDescriptor;
-import org.apache.james.mime4j.descriptor.DefaultBodyDescriptor;
-import org.apache.james.mime4j.descriptor.MaximalBodyDescriptor;
 import org.apache.james.mime4j.descriptor.MutableBodyDescriptor;
 import org.apache.james.mime4j.io.LineReaderInputStream;
 import org.apache.james.mime4j.io.MaxHeaderLengthLimitException;
@@ -42,7 +40,6 @@
 
     protected final Log log;
     
-    protected final BodyDescriptor parent;
     protected final int startState;
     protected final int endState;
     protected final MimeEntityConfig config;
@@ -67,17 +64,16 @@
     private static final int T_IN_MESSAGE = -3;
 
     AbstractEntity(
-            BodyDescriptor parent,
+            MutableBodyDescriptor body,
             int startState, 
             int endState,
             MimeEntityConfig config) {
         this.log = LogFactory.getLog(getClass());        
-        this.parent = parent;
         this.state = startState;
         this.startState = startState;
         this.endState = endState;
         this.config = config;
-        this.body = newBodyDescriptor(parent);
+        this.body = body;
         this.linebuf = new ByteArrayBuffer(64);
         this.lineCount = 0;
         this.endOfHeader = false;
@@ -87,21 +83,6 @@
     public int getState() {
         return state;
     }
-    
-    /**
-     * Creates a new instance of {@link BodyDescriptor}. Subclasses may override
-     * this in order to create body descriptors, that provide more specific
-     * information.
-     */
-    protected MutableBodyDescriptor newBodyDescriptor(BodyDescriptor pParent) {
-        final MutableBodyDescriptor result;
-        if (config.isMaximalBodyDescriptor()) {
-            result = new MaximalBodyDescriptor(pParent);
-        } else {
-            result = new DefaultBodyDescriptor(pParent);
-        }
-        return result;
-    }
 
     /**
      * Returns the current line number or <code>-1</code> if line number
@@ -157,8 +138,7 @@
                     }
                 }
             }
-        }
-        catch (MaxLineLimitException e) {
+        } catch (MaxLineLimitException e) {
             throw new MimeException(e);
         }
 
@@ -167,6 +147,7 @@
 
     protected boolean parseField() throws MimeException, IOException {
         int maxHeaderCount = config.getMaxHeaderCount();
+        // the loop is here to transparently skip invalid headers
         for (;;) {
             if (endOfHeader) {
                 return false;

Modified: james/mime4j/branches/cycleclean/core/src/main/java/org/apache/james/mime4j/parser/MimeEntity.java
URL: http://svn.apache.org/viewvc/james/mime4j/branches/cycleclean/core/src/main/java/org/apache/james/mime4j/parser/MimeEntity.java?rev=894645&r1=894644&r2=894645&view=diff
==============================================================================
--- james/mime4j/branches/cycleclean/core/src/main/java/org/apache/james/mime4j/parser/MimeEntity.java
(original)
+++ james/mime4j/branches/cycleclean/core/src/main/java/org/apache/james/mime4j/parser/MimeEntity.java
Wed Dec 30 15:22:10 2009
@@ -25,7 +25,7 @@
 import org.apache.james.mime4j.MimeException;
 import org.apache.james.mime4j.codec.Base64InputStream;
 import org.apache.james.mime4j.codec.QuotedPrintableInputStream;
-import org.apache.james.mime4j.descriptor.BodyDescriptor;
+import org.apache.james.mime4j.descriptor.MutableBodyDescriptor;
 import org.apache.james.mime4j.io.BufferedLineReaderInputStream;
 import org.apache.james.mime4j.io.LimitedInputStream;
 import org.apache.james.mime4j.io.LineNumberSource;
@@ -36,48 +36,38 @@
 
 public class MimeEntity extends AbstractEntity {
 
-    /**
-     * Internal state, not exposed.
-     */
-    private static final int T_IN_BODYPART = -2;
-    /**
-     * Internal state, not exposed.
-     */
-    private static final int T_IN_MESSAGE = -3;
-
     private final LineNumberSource lineSource;
     private final BufferedLineReaderInputStream inbuffer;
     
     private int recursionMode;
-    private MimeBoundaryInputStream mimeStream;
+    private MimeBoundaryInputStream currentMimePartStream;
     private LineReaderInputStreamAdaptor dataStream;
-    private boolean skipHeader;
     
     private byte[] tmpbuf;
     
     public MimeEntity(
             LineNumberSource lineSource,
-            BufferedLineReaderInputStream inbuffer,
-            BodyDescriptor parent, 
+            InputStream instream,
+            MutableBodyDescriptor body, 
             int startState, 
             int endState,
             MimeEntityConfig config) {
-        super(parent, startState, endState, config);
+        super(body, startState, endState, config);
         this.lineSource = lineSource;
-        this.inbuffer = inbuffer;
+        this.inbuffer = new BufferedLineReaderInputStream(
+                instream,
+                4 * 1024,
+                config.getMaxLineLen());
         this.dataStream = new LineReaderInputStreamAdaptor(
                 inbuffer,
                 config.getMaxLineLen());
-        this.skipHeader = false;
     }
 
     public MimeEntity(
             LineNumberSource lineSource,
-            BufferedLineReaderInputStream inbuffer,
-            BodyDescriptor parent, 
-            int startState, 
-            int endState) {
-        this(lineSource, inbuffer, parent, startState, endState, 
+            InputStream instream,
+            MutableBodyDescriptor body) {
+        this(lineSource, instream, body, EntityStates.T_START_MESSAGE, EntityStates.T_END_MESSAGE,

                 new MimeEntityConfig());
     }
 
@@ -89,14 +79,10 @@
         this.recursionMode = recursionMode;
     }
 
-    public void skipHeader(String contentType) {
-        if (state != EntityStates.T_START_MESSAGE) {
-            throw new IllegalStateException("Invalid state: " + stateToString(state));
-        }
-        skipHeader = true;
-        body.addField(new RawField("Content-Type", contentType));
+    public void stop() {
+    	this.inbuffer.truncate();
     }
-
+    
     @Override
     protected int getLineNumber() {
         if (lineSource == null)
@@ -113,11 +99,7 @@
     public EntityStateMachine advance() throws IOException, MimeException {
         switch (state) {
         case EntityStates.T_START_MESSAGE:
-            if (skipHeader) {
-                state = EntityStates.T_END_HEADER;
-            } else {
-                state = EntityStates.T_START_HEADER;
-            }
+            state = EntityStates.T_START_HEADER;
             break;
         case EntityStates.T_START_BODYPART:
             state = EntityStates.T_START_HEADER;
@@ -132,10 +114,10 @@
                 state = EntityStates.T_BODY;
             } else if (MimeUtil.isMultipart(mimeType)) {
                 state = EntityStates.T_START_MULTIPART;
-                clearMimeStream();
+                clearMimePartStream();
             } else if (recursionMode != RecursionMode.M_NO_RECURSE 
                     && MimeUtil.isMessage(mimeType)) {
-                state = T_IN_MESSAGE;
+                state = EntityStates.T_BODY;
                 return nextMessage();
             } else {
                 state = EntityStates.T_BODY;
@@ -146,35 +128,25 @@
                 advanceToBoundary();            
                 state = EntityStates.T_END_MULTIPART;
             } else {
-                createMimeStream();
+                createMimePartStream();
                 state = EntityStates.T_PREAMBLE;
             }
             break;
         case EntityStates.T_PREAMBLE:
-            advanceToBoundary();            
-            if (mimeStream.isLastPart()) {
-                clearMimeStream();
-                state = EntityStates.T_END_MULTIPART;
-            } else {
-                clearMimeStream();
-                createMimeStream();
-                state = T_IN_BODYPART;
-                return nextMimeEntity();
-            }
-            break;
-        case T_IN_BODYPART:
+        	// removed specific code. Fallback to T_IN_BODYPART that
+        	// better handle missing parts.
+        	// Removed the T_IN_BODYPART state (always use T_PREAMBLE)
             advanceToBoundary();
-            if (mimeStream.eof() && !mimeStream.isLastPart()) {
+            if (currentMimePartStream.eof() && !currentMimePartStream.isLastPart())
{
                 monitor(Event.MIME_BODY_PREMATURE_END);
             } else {
-                if (!mimeStream.isLastPart()) {
-                    clearMimeStream();
-                    createMimeStream();
-                    state = T_IN_BODYPART;
+                if (!currentMimePartStream.isLastPart()) {
+                    clearMimePartStream();
+                    createMimePartStream();
                     return nextMimeEntity();
                 }
             }
-            clearMimeStream();
+            clearMimePartStream();
             state = EntityStates.T_EPILOGUE;
             break;
         case EntityStates.T_EPILOGUE:
@@ -182,7 +154,6 @@
             break;
         case EntityStates.T_BODY:
         case EntityStates.T_END_MULTIPART:
-        case T_IN_MESSAGE:
             state = endState;
             break;
         default:
@@ -195,35 +166,26 @@
         return null;
     }
 
-    private void createMimeStream() throws MimeException, IOException {
+    private void createMimePartStream() throws MimeException, IOException {
         String boundary = body.getBoundary();
         int bufferSize = 2 * boundary.length();
         if (bufferSize < 4096) {
             bufferSize = 4096;
         }
         try {
-            if (mimeStream != null) {
-                mimeStream = new MimeBoundaryInputStream(
-                        new BufferedLineReaderInputStream(
-                                mimeStream, 
-                                bufferSize, 
-                                config.getMaxLineLen()), 
-                        boundary);
-            } else {
-                inbuffer.ensureCapacity(bufferSize);
-                mimeStream = new MimeBoundaryInputStream(inbuffer, boundary);
-            }
+            inbuffer.ensureCapacity(bufferSize);
+            currentMimePartStream = new MimeBoundaryInputStream(inbuffer, boundary);
         } catch (IllegalArgumentException e) {
             // thrown when boundary is too long
             throw new MimeException(e.getMessage(), e);
         }
         dataStream = new LineReaderInputStreamAdaptor(
-                mimeStream,
-                config.getMaxLineLen()); 
+                currentMimePartStream,
+                config.getMaxLineLen());
     }
     
-    private void clearMimeStream() {
-        mimeStream = null;
+    private void clearMimePartStream() {
+        currentMimePartStream = null;
         dataStream = new LineReaderInputStreamAdaptor(
                 inbuffer,
                 config.getMaxLineLen()); 
@@ -242,22 +204,22 @@
     
     private EntityStateMachine nextMessage() {
         String transferEncoding = body.getTransferEncoding();
-        InputStream instream;
+        // optimize nesting of streams returning the "lower" stream instead of
+        // always return dataStream (that would add a LineReaderInputStreamAdaptor in the
chain)
+        InputStream instream = currentMimePartStream != null ? currentMimePartStream : inbuffer;
         if (MimeUtil.isBase64Encoding(transferEncoding)) {
             log.debug("base64 encoded message/rfc822 detected");
-            instream = new Base64InputStream(dataStream);                    
+            instream = new Base64InputStream(instream);                    
         } else if (MimeUtil.isQuotedPrintableEncoded(transferEncoding)) {
             log.debug("quoted-printable encoded message/rfc822 detected");
-            instream = new QuotedPrintableInputStream(dataStream);                    
-        } else {
-            instream = dataStream;
+            instream = new QuotedPrintableInputStream(instream);
         }
 
         return nextMimeEntity(EntityStates.T_START_MESSAGE, EntityStates.T_END_MESSAGE, instream);
     }
     
     private EntityStateMachine nextMimeEntity() {
-    	return nextMimeEntity(EntityStates.T_START_BODYPART, EntityStates.T_END_BODYPART, mimeStream);
+    	return nextMimeEntity(EntityStates.T_START_BODYPART, EntityStates.T_END_BODYPART, currentMimePartStream);
     }
     
     private EntityStateMachine nextMimeEntity(int startState, int endState, InputStream instream)
{
@@ -265,14 +227,10 @@
             RawEntity message = new RawEntity(instream);
             return message;
         } else {
-            BufferedLineReaderInputStream stream = new BufferedLineReaderInputStream(
-            		instream, 
-                    4 * 1024,
-                    config.getMaxLineLen());
             MimeEntity mimeentity = new MimeEntity(
                     lineSource, 
-                    stream,
-                    body, 
+                    instream,
+                    body.newChild(), 
                     startState, 
                     endState,
                     config);

Modified: james/mime4j/branches/cycleclean/core/src/main/java/org/apache/james/mime4j/parser/MimeTokenStream.java
URL: http://svn.apache.org/viewvc/james/mime4j/branches/cycleclean/core/src/main/java/org/apache/james/mime4j/parser/MimeTokenStream.java?rev=894645&r1=894644&r2=894645&view=diff
==============================================================================
--- james/mime4j/branches/cycleclean/core/src/main/java/org/apache/james/mime4j/parser/MimeTokenStream.java
(original)
+++ james/mime4j/branches/cycleclean/core/src/main/java/org/apache/james/mime4j/parser/MimeTokenStream.java
Wed Dec 30 15:22:10 2009
@@ -32,7 +32,9 @@
 import org.apache.james.mime4j.codec.Base64InputStream;
 import org.apache.james.mime4j.codec.QuotedPrintableInputStream;
 import org.apache.james.mime4j.descriptor.BodyDescriptor;
-import org.apache.james.mime4j.io.BufferedLineReaderInputStream;
+import org.apache.james.mime4j.descriptor.DefaultBodyDescriptor;
+import org.apache.james.mime4j.descriptor.MaximalBodyDescriptor;
+import org.apache.james.mime4j.descriptor.MutableBodyDescriptor;
 import org.apache.james.mime4j.io.LineNumberInputStream;
 import org.apache.james.mime4j.io.LineNumberSource;
 import org.apache.james.mime4j.util.CharsetUtil;
@@ -106,7 +108,7 @@
     private int state = T_END_OF_STREAM;
     private EntityStateMachine currentStateMachine;
     private int recursionMode = M_RECURSE;
-    private BufferedLineReaderInputStream inbuffer;
+	private MimeEntity rootentity;
     
     /**
      * Constructs a standard (lax) stream.
@@ -157,32 +159,42 @@
             stream = lineInput;
         }
 
-        inbuffer = new BufferedLineReaderInputStream(
-                stream, 
-                4 * 1024,
-                config.getMaxLineLen());
-        if (recursionMode == M_RAW) {
-            RawEntity rawentity = new RawEntity(inbuffer);
-            currentStateMachine = rawentity;
-        } else {
-            MimeEntity mimeentity = new MimeEntity(
-                    lineSource,
-                    inbuffer,
-                    null, 
-                    T_START_MESSAGE, 
-                    T_END_MESSAGE,
-                    config);
-            mimeentity.setRecursionMode(recursionMode);
-            if (contentType != null) {
-                mimeentity.skipHeader(contentType);
-            }
-            currentStateMachine = mimeentity;
+        MutableBodyDescriptor newBodyDescriptor = newBodyDescriptor(null);
+        int start = T_START_MESSAGE;
+        if (contentType != null) {
+        	start = T_END_HEADER;
+        	newBodyDescriptor.addField(new RawField("Content-Type", contentType));
         }
+		rootentity = new MimeEntity(
+                lineSource,
+                stream,
+                newBodyDescriptor, 
+                start, 
+                T_END_MESSAGE,
+                config);
+        rootentity.setRecursionMode(recursionMode);
+        currentStateMachine = rootentity;
+
         entities.add(currentStateMachine);
         state = currentStateMachine.getState();
     }
 
     /**
+     * Creates a new instance of {@link BodyDescriptor}. Subclasses may override
+     * this in order to create body descriptors, that provide more specific
+     * information.
+     */
+    protected MutableBodyDescriptor newBodyDescriptor(BodyDescriptor pParent) {
+        final MutableBodyDescriptor result;
+        if (config.isMaximalBodyDescriptor()) {
+            result = new MaximalBodyDescriptor(pParent);
+        } else {
+            result = new DefaultBodyDescriptor(pParent);
+        }
+        return result;
+    }
+
+    /**
      * Determines if this parser is currently in raw mode.
      * 
      * @return <code>true</code> if in raw mode, <code>false</code>
@@ -235,7 +247,7 @@
      * {@link ContentHandler#startMessage()}, etc.
      */
     public void stop() {
-        inbuffer.truncate();
+        rootentity.stop();
     }
 
     /**

Modified: james/mime4j/branches/cycleclean/core/src/test/java/org/apache/james/mime4j/message/MessageHeadlessParserTest.java
URL: http://svn.apache.org/viewvc/james/mime4j/branches/cycleclean/core/src/test/java/org/apache/james/mime4j/message/MessageHeadlessParserTest.java?rev=894645&r1=894644&r2=894645&view=diff
==============================================================================
--- james/mime4j/branches/cycleclean/core/src/test/java/org/apache/james/mime4j/message/MessageHeadlessParserTest.java
(original)
+++ james/mime4j/branches/cycleclean/core/src/test/java/org/apache/james/mime4j/message/MessageHeadlessParserTest.java
Wed Dec 30 15:22:10 2009
@@ -29,6 +29,46 @@
 
 public class MessageHeadlessParserTest extends TestCase {
 
+
+	public void testMalformedHeaderShouldEndHeader() throws Exception {
+		String headlessContent = "Subject: my subject\r\n"
+			    + "Hi, how are you?\r\n"
+				+ "This is a simple message with no CRLFCELF between headers and body.\r\n"
+				+ "ThisIsNotAnHeader: because this should be already in the body\r\n"
+				+ "\r\n"
+				+ "Instead this should be better parsed as a text/plain body\r\n";
+
+		Message message = new Message(new ByteArrayInputStream(headlessContent
+				.getBytes("UTF-8")));
+		assertEquals("text/plain", message.getMimeType());
+		assertEquals(1, message.getHeader().getFields().size());
+		ContentTypeField contentTypeField = ((ContentTypeField) message
+				.getHeader().getField(FieldName.CONTENT_TYPE));
+		assertEquals("foo", contentTypeField.getBoundary());
+		Multipart multipart = (Multipart) message.getBody();
+		assertEquals(3, multipart.getCount());
+	}
+
+	public void testSimpleNonMimeTextHeadless() throws Exception {
+		String headlessContent = "Hi, how are you?\r\n"
+				+ "This is a simple message with no headers. While mime messages should start with\r\n"
+				+ "header: headervalue\r\n"
+				+ "\r\n"
+				+ "Instead this should be better parsed as a text/plain body\r\n";
+
+		MimeEntityConfig mimeEntityConfig = new MimeEntityConfig();
+		mimeEntityConfig.setDefaultContentType("text/plain");
+		Message message = new Message(new ByteArrayInputStream(headlessContent
+				.getBytes("UTF-8")), mimeEntityConfig);
+		assertEquals("text/plain", message.getMimeType());
+		assertEquals(1, message.getHeader().getFields().size());
+		ContentTypeField contentTypeField = ((ContentTypeField) message
+				.getHeader().getField(FieldName.CONTENT_TYPE));
+		assertEquals("foo", contentTypeField.getBoundary());
+		Multipart multipart = (Multipart) message.getBody();
+		assertEquals(3, multipart.getCount());
+	}
+
 	public void testMultipartFormContent() throws Exception {
 		String contentType = "multipart/form-data; boundary=foo";
 		String headlessContent = "\r\n"

Modified: james/mime4j/branches/cycleclean/core/src/test/java/org/apache/james/mime4j/parser/MimeEntityTest.java
URL: http://svn.apache.org/viewvc/james/mime4j/branches/cycleclean/core/src/test/java/org/apache/james/mime4j/parser/MimeEntityTest.java?rev=894645&r1=894644&r2=894645&view=diff
==============================================================================
--- james/mime4j/branches/cycleclean/core/src/test/java/org/apache/james/mime4j/parser/MimeEntityTest.java
(original)
+++ james/mime4j/branches/cycleclean/core/src/test/java/org/apache/james/mime4j/parser/MimeEntityTest.java
Wed Dec 30 15:22:10 2009
@@ -24,6 +24,7 @@
 
 import org.apache.commons.io.IOUtils;
 import org.apache.james.mime4j.MimeException;
+import org.apache.james.mime4j.descriptor.DefaultBodyDescriptor;
 import org.apache.james.mime4j.io.BufferedLineReaderInputStream;
 import org.apache.james.mime4j.io.MaxHeaderLengthLimitException;
 import org.apache.james.mime4j.io.MaxHeaderLimitException;
@@ -54,10 +55,7 @@
         
         MimeEntity entity = new MimeEntity(
                 lineInput,
-                rawstream,
-                null,
-                EntityStates.T_START_MESSAGE,
-                EntityStates.T_END_MESSAGE);
+                rawstream, new DefaultBodyDescriptor());
         
         
         assertEquals(EntityStates.T_START_MESSAGE, entity.getState());
@@ -133,10 +131,7 @@
         
         MimeEntity entity = new MimeEntity(
                 lineInput,
-                rawstream,
-                null,
-                EntityStates.T_START_MESSAGE,
-                EntityStates.T_END_MESSAGE);
+                rawstream, new DefaultBodyDescriptor());
         
         
         assertEquals(EntityStates.T_START_MESSAGE, entity.getState());
@@ -220,10 +215,7 @@
         
         MimeEntity entity = new MimeEntity(
                 lineInput,
-                rawstream,
-                null,
-                EntityStates.T_START_MESSAGE,
-                EntityStates.T_END_MESSAGE);
+                rawstream, new DefaultBodyDescriptor());
         
         assertEquals(EntityStates.T_START_MESSAGE, entity.getState());
         entity.advance();
@@ -333,10 +325,7 @@
         
         MimeEntity entity = new MimeEntity(
                 lineInput,
-                rawstream,
-                null,
-                EntityStates.T_START_MESSAGE,
-                EntityStates.T_END_MESSAGE);
+                rawstream, new DefaultBodyDescriptor());
         
         entity.setRecursionMode(RecursionMode.M_RAW);
         
@@ -430,7 +419,7 @@
         MimeEntity entity = new MimeEntity(
                 lineInput,
                 rawstream,
-                null,
+                new DefaultBodyDescriptor(),
                 EntityStates.T_START_MESSAGE,
                 EntityStates.T_END_MESSAGE,
                 config);
@@ -484,7 +473,7 @@
         MimeEntity entity = new MimeEntity(
                 lineInput,
                 rawstream,
-                null,
+                new DefaultBodyDescriptor(),
                 EntityStates.T_START_MESSAGE,
                 EntityStates.T_END_MESSAGE,
                 config);
@@ -532,7 +521,7 @@
         MimeEntity entity = new MimeEntity(
                 lineInput,
                 rawstream,
-                null,
+                new DefaultBodyDescriptor(),
                 EntityStates.T_START_MESSAGE,
                 EntityStates.T_END_MESSAGE,
                 config);
@@ -583,7 +572,7 @@
         MimeEntity entity = new MimeEntity(
                 lineInput,
                 rawstream,
-                null,
+                new DefaultBodyDescriptor(),
                 EntityStates.T_START_MESSAGE,
                 EntityStates.T_END_MESSAGE,
                 config);
@@ -631,7 +620,7 @@
         MimeEntity entity = new MimeEntity(
                 lineInput,
                 rawstream,
-                null,
+                new DefaultBodyDescriptor(),
                 EntityStates.T_START_MESSAGE,
                 EntityStates.T_END_MESSAGE,
                 config);

Modified: james/mime4j/branches/cycleclean/core/src/test/java/org/apache/james/mime4j/parser/MultipartTokensTest.java
URL: http://svn.apache.org/viewvc/james/mime4j/branches/cycleclean/core/src/test/java/org/apache/james/mime4j/parser/MultipartTokensTest.java?rev=894645&r1=894644&r2=894645&view=diff
==============================================================================
--- james/mime4j/branches/cycleclean/core/src/test/java/org/apache/james/mime4j/parser/MultipartTokensTest.java
(original)
+++ james/mime4j/branches/cycleclean/core/src/test/java/org/apache/james/mime4j/parser/MultipartTokensTest.java
Wed Dec 30 15:22:10 2009
@@ -275,7 +275,8 @@
     public void testMultipartMessageWithoutHeader() throws Exception {
         parser.parseHeadless(new ByteArrayInputStream(US_ASCII.encode(BODY).array()), 
                 "multipart/mixed;boundary=1729");
-        checkState(MimeTokenStream.T_END_HEADER);
+        // see https://issues.apache.org/jira/browse/MIME4J-153
+        // checkState(MimeTokenStream.T_END_HEADER);
         checkState(MimeTokenStream.T_START_MULTIPART);
         checkState(MimeTokenStream.T_PREAMBLE);
         checkState(MimeTokenStream.T_START_BODYPART);

Added: james/mime4j/branches/cycleclean/core/src/test/resources/testmsgs/missing-boundary.msg
URL: http://svn.apache.org/viewvc/james/mime4j/branches/cycleclean/core/src/test/resources/testmsgs/missing-boundary.msg?rev=894645&view=auto
==============================================================================
--- james/mime4j/branches/cycleclean/core/src/test/resources/testmsgs/missing-boundary.msg
(added)
+++ james/mime4j/branches/cycleclean/core/src/test/resources/testmsgs/missing-boundary.msg
Wed Dec 30 15:22:10 2009
@@ -0,0 +1,4 @@
+Content-Type: multipart/alternative; boundary="inner-boundary"
+
+AAA
+

Added: james/mime4j/branches/cycleclean/core/src/test/resources/testmsgs/missing-boundary.out
URL: http://svn.apache.org/viewvc/james/mime4j/branches/cycleclean/core/src/test/resources/testmsgs/missing-boundary.out?rev=894645&view=auto
==============================================================================
--- james/mime4j/branches/cycleclean/core/src/test/resources/testmsgs/missing-boundary.out
(added)
+++ james/mime4j/branches/cycleclean/core/src/test/resources/testmsgs/missing-boundary.out
Wed Dec 30 15:22:10 2009
@@ -0,0 +1,6 @@
+Content-Type: multipart/alternative; boundary="inner-boundary"
+
+AAA
+
+
+--inner-boundary--

Added: james/mime4j/branches/cycleclean/core/src/test/resources/testmsgs/missing-boundary.xml
URL: http://svn.apache.org/viewvc/james/mime4j/branches/cycleclean/core/src/test/resources/testmsgs/missing-boundary.xml?rev=894645&view=auto
==============================================================================
--- james/mime4j/branches/cycleclean/core/src/test/resources/testmsgs/missing-boundary.xml
(added)
+++ james/mime4j/branches/cycleclean/core/src/test/resources/testmsgs/missing-boundary.xml
Wed Dec 30 15:22:10 2009
@@ -0,0 +1,14 @@
+<message>
+<header>
+<field>
+Content-Type: multipart/alternative; boundary="inner-boundary"</field>
+</header>
+<multipart>
+<preamble>
+AAA
+
+</preamble>
+<epilogue>
+</epilogue>
+</multipart>
+</message>

Propchange: james/mime4j/branches/cycleclean/core/src/test/resources/testmsgs/missing-boundary.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: james/mime4j/branches/cycleclean/core/src/test/resources/testmsgs/missing-boundary.xml
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: james/mime4j/branches/cycleclean/core/src/test/resources/testmsgs/missing-boundary_decoded.xml
URL: http://svn.apache.org/viewvc/james/mime4j/branches/cycleclean/core/src/test/resources/testmsgs/missing-boundary_decoded.xml?rev=894645&view=auto
==============================================================================
--- james/mime4j/branches/cycleclean/core/src/test/resources/testmsgs/missing-boundary_decoded.xml
(added)
+++ james/mime4j/branches/cycleclean/core/src/test/resources/testmsgs/missing-boundary_decoded.xml
Wed Dec 30 15:22:10 2009
@@ -0,0 +1,14 @@
+<message>
+<header>
+<field>
+Content-Type: multipart/alternative; boundary="inner-boundary"</field>
+</header>
+<multipart>
+<preamble>
+AAA
+
+</preamble>
+<epilogue>
+</epilogue>
+</multipart>
+</message>

Propchange: james/mime4j/branches/cycleclean/core/src/test/resources/testmsgs/missing-boundary_decoded.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: james/mime4j/branches/cycleclean/core/src/test/resources/testmsgs/missing-boundary_decoded.xml
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: james/mime4j/branches/cycleclean/core/src/test/resources/testmsgs/missing-inner-boundary.out
URL: http://svn.apache.org/viewvc/james/mime4j/branches/cycleclean/core/src/test/resources/testmsgs/missing-inner-boundary.out?rev=894645&r1=894644&r2=894645&view=diff
==============================================================================
Binary files - no diff available.

Modified: james/mime4j/branches/cycleclean/core/src/test/resources/testmsgs/missing-inner-boundary.xml
URL: http://svn.apache.org/viewvc/james/mime4j/branches/cycleclean/core/src/test/resources/testmsgs/missing-inner-boundary.xml?rev=894645&r1=894644&r2=894645&view=diff
==============================================================================
Binary files - no diff available.

Modified: james/mime4j/branches/cycleclean/core/src/test/resources/testmsgs/missing-inner-boundary_decoded.xml
URL: http://svn.apache.org/viewvc/james/mime4j/branches/cycleclean/core/src/test/resources/testmsgs/missing-inner-boundary_decoded.xml?rev=894645&r1=894644&r2=894645&view=diff
==============================================================================
Binary files - no diff available.

Added: james/mime4j/branches/cycleclean/core/src/test/resources/testmsgs/missing-inner-start-boundary.msg
URL: http://svn.apache.org/viewvc/james/mime4j/branches/cycleclean/core/src/test/resources/testmsgs/missing-inner-start-boundary.msg?rev=894645&view=auto
==============================================================================
--- james/mime4j/branches/cycleclean/core/src/test/resources/testmsgs/missing-inner-start-boundary.msg
(added)
+++ james/mime4j/branches/cycleclean/core/src/test/resources/testmsgs/missing-inner-start-boundary.msg
Wed Dec 30 15:22:10 2009
@@ -0,0 +1,17 @@
+Content-Type: multipart/mixed; boundary="outer-boundary"
+
+Outer preamble
+
+--outer-boundary
+Content-Type: text/plain
+
+Foo
+
+--outer-boundary
+Content-Type: multipart/alternative; boundary="inner-boundary"
+
+AAA
+
+--inner-boundary--
+--outer-boundary--
+Outer epilouge

Added: james/mime4j/branches/cycleclean/core/src/test/resources/testmsgs/missing-inner-start-boundary.out
URL: http://svn.apache.org/viewvc/james/mime4j/branches/cycleclean/core/src/test/resources/testmsgs/missing-inner-start-boundary.out?rev=894645&view=auto
==============================================================================
--- james/mime4j/branches/cycleclean/core/src/test/resources/testmsgs/missing-inner-start-boundary.out
(added)
+++ james/mime4j/branches/cycleclean/core/src/test/resources/testmsgs/missing-inner-start-boundary.out
Wed Dec 30 15:22:10 2009
@@ -0,0 +1,18 @@
+Content-Type: multipart/mixed; boundary="outer-boundary"
+
+Outer preamble
+
+--outer-boundary
+Content-Type: text/plain
+
+Foo
+
+--outer-boundary
+Content-Type: multipart/alternative; boundary="inner-boundary"
+
+AAA
+
+--inner-boundary--
+
+--outer-boundary--
+Outer epilouge

Added: james/mime4j/branches/cycleclean/core/src/test/resources/testmsgs/missing-inner-start-boundary.xml
URL: http://svn.apache.org/viewvc/james/mime4j/branches/cycleclean/core/src/test/resources/testmsgs/missing-inner-start-boundary.xml?rev=894645&view=auto
==============================================================================
--- james/mime4j/branches/cycleclean/core/src/test/resources/testmsgs/missing-inner-start-boundary.xml
(added)
+++ james/mime4j/branches/cycleclean/core/src/test/resources/testmsgs/missing-inner-start-boundary.xml
Wed Dec 30 15:22:10 2009
@@ -0,0 +1,36 @@
+<message>
+<header>
+<field>
+Content-Type: multipart/mixed; boundary="outer-boundary"</field>
+</header>
+<multipart>
+<preamble>
+Outer preamble
+</preamble>
+<body-part>
+<header>
+<field>
+Content-Type: text/plain</field>
+</header>
+<body>
+Foo
+</body>
+</body-part>
+<body-part>
+<header>
+<field>
+Content-Type: multipart/alternative; boundary="inner-boundary"</field>
+</header>
+<multipart>
+<preamble>
+AAA
+</preamble>
+<epilogue>
+</epilogue>
+</multipart>
+</body-part>
+<epilogue>
+Outer epilouge
+</epilogue>
+</multipart>
+</message>

Propchange: james/mime4j/branches/cycleclean/core/src/test/resources/testmsgs/missing-inner-start-boundary.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: james/mime4j/branches/cycleclean/core/src/test/resources/testmsgs/missing-inner-start-boundary.xml
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: james/mime4j/branches/cycleclean/core/src/test/resources/testmsgs/missing-inner-start-boundary_decoded.xml
URL: http://svn.apache.org/viewvc/james/mime4j/branches/cycleclean/core/src/test/resources/testmsgs/missing-inner-start-boundary_decoded.xml?rev=894645&view=auto
==============================================================================
--- james/mime4j/branches/cycleclean/core/src/test/resources/testmsgs/missing-inner-start-boundary_decoded.xml
(added)
+++ james/mime4j/branches/cycleclean/core/src/test/resources/testmsgs/missing-inner-start-boundary_decoded.xml
Wed Dec 30 15:22:10 2009
@@ -0,0 +1,34 @@
+<message>
+<header>
+<field>
+Content-Type: multipart/mixed; boundary="outer-boundary"</field>
+</header>
+<multipart>
+<preamble>
+Outer preamble
+</preamble>
+<body-part>
+<header>
+<field>
+Content-Type: text/plain</field>
+</header>
+<text-body name="missing-inner-start-boundary_decoded_1_1.txt"/>
+</body-part>
+<body-part>
+<header>
+<field>
+Content-Type: multipart/alternative; boundary="inner-boundary"</field>
+</header>
+<multipart>
+<preamble>
+AAA
+</preamble>
+<epilogue>
+</epilogue>
+</multipart>
+</body-part>
+<epilogue>
+Outer epilouge
+</epilogue>
+</multipart>
+</message>

Propchange: james/mime4j/branches/cycleclean/core/src/test/resources/testmsgs/missing-inner-start-boundary_decoded.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: james/mime4j/branches/cycleclean/core/src/test/resources/testmsgs/missing-inner-start-boundary_decoded.xml
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: james/mime4j/branches/cycleclean/core/src/test/resources/testmsgs/missing-inner-start-boundary_decoded_1_1.txt
URL: http://svn.apache.org/viewvc/james/mime4j/branches/cycleclean/core/src/test/resources/testmsgs/missing-inner-start-boundary_decoded_1_1.txt?rev=894645&view=auto
==============================================================================
--- james/mime4j/branches/cycleclean/core/src/test/resources/testmsgs/missing-inner-start-boundary_decoded_1_1.txt
(added)
+++ james/mime4j/branches/cycleclean/core/src/test/resources/testmsgs/missing-inner-start-boundary_decoded_1_1.txt
Wed Dec 30 15:22:10 2009
@@ -0,0 +1 @@
+Foo

Propchange: james/mime4j/branches/cycleclean/core/src/test/resources/testmsgs/missing-inner-start-boundary_decoded_1_1.txt
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: james/mime4j/branches/cycleclean/core/src/test/resources/testmsgs/missing-inner-start-boundary_decoded_1_1.txt
------------------------------------------------------------------------------
    svn:mime-type = text/plain



Mime
View raw message