james-mime4j-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From b...@apache.org
Subject svn commit: r937685 - in /james/mime4j/trunk/core/src: main/java/org/apache/james/mime4j/parser/MimeStreamParser.java main/java/org/apache/james/mime4j/stream/MimeTokenStream.java test/java/org/apache/james/mime4j/stream/MultipartTokensTest.java
Date Sat, 24 Apr 2010 19:40:43 GMT
Author: bago
Date: Sat Apr 24 19:40:43 2010
New Revision: 937685

URL: http://svn.apache.org/viewvc?rev=937685&view=rev
Log:
Make sure headless parsing in MimeTokenStream starts from the first body token and not with
the unexpected T_END_HEADER, also change MimeStreamParser to avoid waiting for that event
(MIME4J-153 and MIME4J-128)

Modified:
    james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/parser/MimeStreamParser.java
    james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/stream/MimeTokenStream.java
    james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/stream/MultipartTokensTest.java

Modified: james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/parser/MimeStreamParser.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/parser/MimeStreamParser.java?rev=937685&r1=937684&r2=937685&view=diff
==============================================================================
--- james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/parser/MimeStreamParser.java
(original)
+++ james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/parser/MimeStreamParser.java
Sat Apr 24 19:40:43 2010
@@ -119,6 +119,7 @@ public class MimeStreamParser {
             handler.startMessage();
             handler.startHeader();
             handler.field(new RawField("Content-Type", mimeEntityConfig.getDefaultContentType()));
+            handler.endHeader();
         } else {
             mimeTokenStream.parse(inputStream);
         }

Modified: james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/stream/MimeTokenStream.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/stream/MimeTokenStream.java?rev=937685&r1=937684&r2=937685&view=diff
==============================================================================
--- james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/stream/MimeTokenStream.java
(original)
+++ james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/stream/MimeTokenStream.java
Sat Apr 24 19:40:43 2010
@@ -146,6 +146,15 @@ public class MimeTokenStream implements 
             throw new IllegalArgumentException(ex.getMessage());
         }
         doParse(stream, newBodyDescriptor, T_END_HEADER);
+        try {
+            next();
+        } catch (IOException e) {
+            // Should never happend: the first next after END_HEADER does not produce IO
+            throw new IllegalStateException(e);
+        } catch (MimeException e) {
+            // This should never happen
+            throw new IllegalStateException(e);
+        }
     }
 
     /**

Modified: james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/stream/MultipartTokensTest.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/stream/MultipartTokensTest.java?rev=937685&r1=937684&r2=937685&view=diff
==============================================================================
--- james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/stream/MultipartTokensTest.java
(original)
+++ james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/stream/MultipartTokensTest.java
Sat Apr 24 19:40:43 2010
@@ -279,7 +279,12 @@ public class MultipartTokensTest extends
                 "multipart/mixed;boundary=1729");
         // see https://issues.apache.org/jira/browse/MIME4J-153
         // checkState(MimeTokenStream.T_END_HEADER);
-        checkState(MimeTokenStream.T_START_MULTIPART);
+        
+        // see https://issues.apache.org/jira/browse/MIME4J-153
+        // checkState(MimeTokenStream.T_START_MULTIPART);
+        
+        // actually T_START_MULTIPART is the first state, but the 
+        // checkState method calls next() before checking.
         checkState(MimeTokenStream.T_PREAMBLE);
         checkState(MimeTokenStream.T_START_BODYPART);
         checkState(MimeTokenStream.T_START_HEADER);



Mime
View raw message