james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nik...@apache.org
Subject svn commit: r678373 - in /james/mime4j/trunk/src: main/java/org/apache/james/mime4j/util/CodecUtil.java test/java/org/apache/james/mime4j/util/CodecUtilTest.java
Date Mon, 21 Jul 2008 09:23:31 GMT
Author: niklas
Date: Mon Jul 21 02:23:31 2008
New Revision: 678373

URL: http://svn.apache.org/viewvc?rev=678373&view=rev
Log:
Fix for MIME4J-61: Large inputs will not cause ArrayIndexOutOfBoundsException anymore when
encoded using quoted printable.

Modified:
    james/mime4j/trunk/src/main/java/org/apache/james/mime4j/util/CodecUtil.java
    james/mime4j/trunk/src/test/java/org/apache/james/mime4j/util/CodecUtilTest.java

Modified: james/mime4j/trunk/src/main/java/org/apache/james/mime4j/util/CodecUtil.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/src/main/java/org/apache/james/mime4j/util/CodecUtil.java?rev=678373&r1=678372&r2=678373&view=diff
==============================================================================
--- james/mime4j/trunk/src/main/java/org/apache/james/mime4j/util/CodecUtil.java (original)
+++ james/mime4j/trunk/src/main/java/org/apache/james/mime4j/util/CodecUtil.java Mon Jul 21
02:23:31 2008
@@ -146,11 +146,9 @@
         }
         
         private void write(byte next) throws IOException {
-            outBuffer[outputIndex] = next;
+            outBuffer[outputIndex++] = next;
             if (outputIndex >= outBuffer.length) {
                 flushOutput();
-            } else {
-                outputIndex++;
             }
         }
         

Modified: james/mime4j/trunk/src/test/java/org/apache/james/mime4j/util/CodecUtilTest.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/src/test/java/org/apache/james/mime4j/util/CodecUtilTest.java?rev=678373&r1=678372&r2=678373&view=diff
==============================================================================
--- james/mime4j/trunk/src/test/java/org/apache/james/mime4j/util/CodecUtilTest.java (original)
+++ james/mime4j/trunk/src/test/java/org/apache/james/mime4j/util/CodecUtilTest.java Mon Jul
21 02:23:31 2008
@@ -21,6 +21,7 @@
 
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
+import java.io.InputStream;
 
 import org.apache.james.mime4j.ExampleMail;
 
@@ -44,6 +45,20 @@
         assertEquals(content, out.toByteArray());
     }
     
+    public void testEncodeQuotedPrintableLargeInput() throws Exception {
+        StringBuffer sb = new StringBuffer();
+        for (int i = 0; i < 1024 * 5; i++) {
+            sb.append((char) ('0' + (i % 10)));
+        }
+        String expected = sb.toString().replaceAll("(\\d{75})", "$1=\r\n");
+        
+        InputStream in = new ByteArrayInputStream(sb.toString().getBytes("US-ASCII"));
+        ByteArrayOutputStream out = new ByteArrayOutputStream();
+        CodecUtil.encodeQuotedPrintableBinary(in, out);
+        String actual = new String(out.toByteArray(), "US-ASCII");
+        assertEquals(expected, actual);
+    }
+    
     private void assertEquals(byte[] expected, byte[] actual) {
         StringBuffer buffer = new StringBuffer(expected.length);
         assertEquals(expected.length, actual.length);



---------------------------------------------------------------------
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