james-mime4j-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r1177724 - in /james/mime4j/trunk/core/src: main/java/org/apache/james/mime4j/stream/RawField.java test/java/org/apache/james/mime4j/stream/RawFieldTest.java
Date Fri, 30 Sep 2011 16:26:45 GMT
Author: olegk
Date: Fri Sep 30 16:26:45 2011
New Revision: 1177724

URL: http://svn.apache.org/viewvc?rev=1177724&view=rev
Log:
MIME4J-203: RawField#getBody does not correctly handle TAB character after the body delimiter

Modified:
    james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/stream/RawField.java
    james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/stream/RawFieldTest.java

Modified: james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/stream/RawField.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/stream/RawField.java?rev=1177724&r1=1177723&r2=1177724&view=diff
==============================================================================
--- james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/stream/RawField.java (original)
+++ james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/stream/RawField.java Fri
Sep 30 16:26:45 2011
@@ -20,6 +20,7 @@
 package org.apache.james.mime4j.stream;
 
 import org.apache.james.mime4j.util.ByteSequence;
+import org.apache.james.mime4j.util.CharsetUtil;
 import org.apache.james.mime4j.util.ContentUtil;
 import org.apache.james.mime4j.util.MimeUtil;
 
@@ -65,7 +66,9 @@ public final class RawField implements F
         if (raw != null) {
             int len = raw.length();
             int off = delimiterIdx + 1;
-            if (len > off + 1 && (raw.byteAt(off) & 0xff) == 0x20) off++;
+            if (len > off + 1 && (CharsetUtil.isWhitespace((char) (raw.byteAt(off)
& 0xff)))) {
+                off++;
+            }
             return MimeUtil.unfold(ContentUtil.decode(raw, off, len - off));
         }
         return null;

Modified: james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/stream/RawFieldTest.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/stream/RawFieldTest.java?rev=1177724&r1=1177723&r2=1177724&view=diff
==============================================================================
--- james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/stream/RawFieldTest.java
(original)
+++ james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/stream/RawFieldTest.java
Fri Sep 30 16:26:45 2011
@@ -51,4 +51,14 @@ public class RawFieldTest extends TestCa
         Assert.assertEquals("raw: ", field2.toString());
     }
 
+    public void testTabAfterDelimiter() throws Exception {
+        String s = "raw:\tstuff;\r\n  more stuff";
+        ByteSequence raw = ContentUtil.encode(s);
+        RawField field = new RawField(raw, 3, "raw", null);
+        Assert.assertSame(raw, field.getRaw());
+        Assert.assertEquals("raw", field.getName());
+        Assert.assertEquals("stuff;  more stuff", field.getBody());
+        Assert.assertEquals(s, field.toString());
+    }
+    
 }



Mime
View raw message