james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rdon...@apache.org
Subject svn commit: r674620 - in /james/mime4j/trunk/src: main/java/org/apache/james/mime4j/ test/java/org/apache/james/mime4j/
Date Mon, 07 Jul 2008 20:23:15 GMT
Author: rdonkin
Date: Mon Jul  7 13:23:15 2008
New Revision: 674620

URL: http://svn.apache.org/viewvc?rev=674620&view=rev
Log:
Added new recursion mode.

Modified:
    james/mime4j/trunk/src/main/java/org/apache/james/mime4j/MimeEntity.java
    james/mime4j/trunk/src/main/java/org/apache/james/mime4j/MimeTokenStream.java
    james/mime4j/trunk/src/main/java/org/apache/james/mime4j/RecursionMode.java
    james/mime4j/trunk/src/test/java/org/apache/james/mime4j/ExampleMail.java

Modified: james/mime4j/trunk/src/main/java/org/apache/james/mime4j/MimeEntity.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/src/main/java/org/apache/james/mime4j/MimeEntity.java?rev=674620&r1=674619&r2=674620&view=diff
==============================================================================
--- james/mime4j/trunk/src/main/java/org/apache/james/mime4j/MimeEntity.java (original)
+++ james/mime4j/trunk/src/main/java/org/apache/james/mime4j/MimeEntity.java Mon Jul  7 13:23:15
2008
@@ -93,7 +93,9 @@
             break;
         case EntityStates.T_END_HEADER:
             String mimeType = body.getMimeType();
-            if (MimeUtil.isMultipart(mimeType)) {
+            if (recursionMode == RecursionMode.M_FLAT) {
+                state = EntityStates.T_BODY;
+            } else if (MimeUtil.isMultipart(mimeType)) {
                 state = EntityStates.T_START_MULTIPART;
                 clearMimeStream();
             } else if (recursionMode != RecursionMode.M_NO_RECURSE 

Modified: james/mime4j/trunk/src/main/java/org/apache/james/mime4j/MimeTokenStream.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/src/main/java/org/apache/james/mime4j/MimeTokenStream.java?rev=674620&r1=674619&r2=674620&view=diff
==============================================================================
--- james/mime4j/trunk/src/main/java/org/apache/james/mime4j/MimeTokenStream.java (original)
+++ james/mime4j/trunk/src/main/java/org/apache/james/mime4j/MimeTokenStream.java Mon Jul
 7 13:23:15 2008
@@ -156,6 +156,7 @@
             currentStateMachine = rawentity;
             break;
         case M_NO_RECURSE:
+        case M_FLAT:
             // expected to be called only at start of paring
         case M_RECURSE:
             MimeEntity mimeentity = new MimeEntity(

Modified: james/mime4j/trunk/src/main/java/org/apache/james/mime4j/RecursionMode.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/src/main/java/org/apache/james/mime4j/RecursionMode.java?rev=674620&r1=674619&r2=674620&view=diff
==============================================================================
--- james/mime4j/trunk/src/main/java/org/apache/james/mime4j/RecursionMode.java (original)
+++ james/mime4j/trunk/src/main/java/org/apache/james/mime4j/RecursionMode.java Mon Jul  7
13:23:15 2008
@@ -39,5 +39,11 @@
      * @see #getRecursionMode() 
      */
     public static final int M_RAW = 2;
+    /**
+     * Do not recurse <code>message/rfc822</code> parts
+     * and treat multiparts as a single flat body. 
+     * @see #getRecursionMode()
+     */
+    public static final int M_FLAT = 3;
     
 }

Modified: james/mime4j/trunk/src/test/java/org/apache/james/mime4j/ExampleMail.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/src/test/java/org/apache/james/mime4j/ExampleMail.java?rev=674620&r1=674619&r2=674620&view=diff
==============================================================================
--- james/mime4j/trunk/src/test/java/org/apache/james/mime4j/ExampleMail.java (original)
+++ james/mime4j/trunk/src/test/java/org/apache/james/mime4j/ExampleMail.java Mon Jul  7 13:23:15
2008
@@ -23,12 +23,112 @@
 
 public class ExampleMail {
     
+    public static final String MIME_MULTIPART_EMBEDDED_MESSAGES_INNER_MULTIPART_MIXED = "--4.66920160910299\r\n"
+ 
+            "Content-Type: image/gif\r\n" + 
+            "Content-Transfer-Encoding: base64\r\n" + 
+            "MIME-Version: 1.0\r\n" + 
+            "Content-ID: 238478934723847238947892374\r\n" + 
+            "Content-Description: Bogus Image Data\r\n" + 
+            "\r\n" + 
+            "ABCDFEGHIJKLMNO\r\n" + 
+            "\r\n" + 
+            "--4.66920160910299\r\n" + 
+            "Content-Type: message/rfc822\r\n" + 
+            "\r\n" + 
+            "From: Timothy Tayler <timothy@example.org>\r\n" + 
+            "To: John Smith <john@example.org>\r\n" + 
+            "Date: Sat, 16 Feb 2008 12:00:00 +0000 (GMT)\r\n" + 
+            "Subject: Another Example Email\r\n" + 
+            "Content-Type: multipart/mixed;boundary=2.50290787509\r\n" + 
+            "\r\n" + 
+            "Yet another preamble\r\n" + 
+            "\r\n" + 
+            "--2.50290787509\r\n" + 
+            "Content-Type: text/plain\r\n" + 
+            "\r\n" + 
+            "Rhubard AND Custard!\r\n" + 
+            "\r\n" + 
+            "--2.50290787509\r\n" + 
+            "Content-Type: multipart/alternative;boundary=3.243F6A8885A308D3\r\n" + 
+            "\r\n" + 
+            "--3.243F6A8885A308D3\r\n" + 
+            "Content-Type: text/plain\r\n" + 
+            "\r\n" + 
+            "Rhubard?Custard?\r\n" + 
+            "\r\n" + 
+            "--3.243F6A8885A308D3\r\n" + 
+            "\r\n" + 
+            "Content-Type: text/richtext\r\n" + 
+            "\r\n" + 
+            "Rhubard?Custard?\r\n" + 
+            "\r\n" + 
+            "--3.243F6A8885A308D3--\r\n" + 
+            "\r\n" + 
+            "--2.50290787509--\r\n" + 
+            "\r\n" + 
+            "--4.66920160910299--";
+
+    public static final String MIME_MULTIPART_EMBEDDED_MESSAGES_INNER_MAIL = "From: Timothy
Tayler <timothy@example.org>\r\n" + 
+            "To: Samual Smith <samual@example.org>\r\n" + 
+            "Date: Thu, 14 Feb 2008 12:00:00 +0000 (GMT)\r\n" + 
+            "Subject: A Multipart Alternative Email\r\n" + 
+            "Content-Type: multipart/alternative;boundary=42\r\n" + 
+            "\r\n" + 
+            "This message has a premable\r\n" + 
+            "\r\n" + 
+            "--42\r\n" + 
+            "Content-Type: text/plain; charset=US-ASCII\r\n" + 
+            "\r\n" + 
+            "Custard!\r\n" + 
+            "\r\n" + 
+            "--42\r\n" + 
+            "Content-Type: application/octet-stream\r\n" + 
+            "\r\n" + 
+            "CUSTARDCUSTARDCUSTARD\r\n" + 
+            "\r\n" + 
+            "--42--\r\n";
+
+    public static final String MIME_MULTIPART_EMBEDDED_MESSAGES_BODY = "Start with a preamble\r\n"
+ 
+            "\r\n" + 
+            "--1729\r\n" + 
+            "Content-Type: text/plain; charset=US-ASCII\r\n" + 
+            "\r\n" + 
+            "Rhubarb!\r\n" + 
+            "\r\n" + 
+            "--1729\r\n" + 
+            "Content-Type: application/octet-stream\r\n" + 
+            "Content-Transfer-Encoding: base64\r\n" + 
+            "\r\n" + 
+            "987654321AHPLA\r\n" + 
+            "\r\n" + 
+            "--1729\r\n" + 
+            "Content-Type: message/rfc822\r\n" + 
+            "\r\n" + 
+            MIME_MULTIPART_EMBEDDED_MESSAGES_INNER_MAIL + 
+            "\r\n" + 
+            "--1729\r\n" + 
+            "Content-Type: multipart/mixed; boundary=4.66920160910299\r\n" + 
+            "\r\n" + 
+            MIME_MULTIPART_EMBEDDED_MESSAGES_INNER_MULTIPART_MIXED + "\r\n" +
+            "--1729--\r\n" + 
+            "\r\n";
+    
     public static final String MD5_CONTENT = "Q2hlY2sgSW50ZWdyaXR5IQ==";
     public static final String CONTENT_DESCRIPTION = "Blah blah blah";
     public static final String CONTENT_ID = "<f470f68e0803061002n22bc4124he14015a4b6d6327f@mail.gmail.com>";
     public static final Charset US_ASCII = Charset.forName("US-ASCII");
     public static final Charset LATIN1 = Charset.forName("ISO-8859-1");
     
+    public static final String MIME_MULTIPART_EMBEDDED_MESSAGES = 
+        "From: Timothy Tayler <timothy@example.org>\r\n" + 
+        "To: Samual Smith <samual@example.org>\r\n" + 
+        "Date: Thu, 14 Feb 2008 12:00:00 +0000 (GMT)\r\n" + 
+        "Subject: A Multipart Email\r\n" + 
+        "Content-Type: multipart/mixed;boundary=1729\r\n" + 
+        "\r\n" + 
+        MIME_MULTIPART_EMBEDDED_MESSAGES_BODY; 
+
+    
     public static final String MULTIPART_WITH_CONTENT_LOCATION = 
         "From: Timothy Tayler <timothy@example.org>\r\n" +
         "To: Samual Smith <samual@example.org>\r\n" +
@@ -524,7 +624,8 @@
     public static final byte[] ONE_PART_MIME_ASCII_COMMENT_IN_MIME_VERSION_BYTES = US_ASCII.encode(ONE_PART_MIME_ASCII_COMMENT_IN_MIME_VERSION).array();
     public static final byte[] ONE_PART_MIME_ASCII_MIME_VERSION_SPANS_TWO_LINES_BYTES = US_ASCII.encode(ONE_PART_MIME_ASCII_MIME_VERSION_SPANS_TWO_LINES).array();
     public static final byte[] MAIL_WITH_RFC822_PART_BYTES = ascii(MAIL_WITH_RFC822_PART);
-
+    public static final byte[] MIME_MULTIPART_EMBEDDED_MESSAGES_BYTES = ascii(MIME_MULTIPART_EMBEDDED_MESSAGES);
+    
     public static final byte[] ascii(String text) {
         
         return US_ASCII.encode(text).array();



---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org


Mime
View raw message