commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject svn commit: r1063922 - in /commons/proper/codec/trunk/src: java/org/apache/commons/codec/binary/Base64.java test/org/apache/commons/codec/binary/Base64Test.java
Date Wed, 26 Jan 2011 23:40:26 GMT
Author: sebb
Date: Wed Jan 26 23:40:25 2011
New Revision: 1063922

URL: http://svn.apache.org/viewvc?rev=1063922&view=rev
Log:
CODEC-112 Base64.encodeBase64(byte[] binaryData, boolean isChunked, boolean urlSafe, int maxResultSize)
throws IAE for valid maxResultSize if isChunked is false

Modified:
    commons/proper/codec/trunk/src/java/org/apache/commons/codec/binary/Base64.java
    commons/proper/codec/trunk/src/test/org/apache/commons/codec/binary/Base64Test.java

Modified: commons/proper/codec/trunk/src/java/org/apache/commons/codec/binary/Base64.java
URL: http://svn.apache.org/viewvc/commons/proper/codec/trunk/src/java/org/apache/commons/codec/binary/Base64.java?rev=1063922&r1=1063921&r2=1063922&view=diff
==============================================================================
--- commons/proper/codec/trunk/src/java/org/apache/commons/codec/binary/Base64.java (original)
+++ commons/proper/codec/trunk/src/java/org/apache/commons/codec/binary/Base64.java Wed Jan
26 23:40:25 2011
@@ -824,7 +824,7 @@ public class Base64 implements BinaryEnc
             return binaryData;
         }
 
-        long len = getEncodeLength(binaryData, MIME_CHUNK_SIZE, CHUNK_SEPARATOR);
+        long len = getEncodeLength(binaryData, isChunked ? MIME_CHUNK_SIZE : 0, CHUNK_SEPARATOR);
         if (len > maxResultSize) {
             throw new IllegalArgumentException("Input array too big, the output array would
be bigger (" +
                 len +

Modified: commons/proper/codec/trunk/src/test/org/apache/commons/codec/binary/Base64Test.java
URL: http://svn.apache.org/viewvc/commons/proper/codec/trunk/src/test/org/apache/commons/codec/binary/Base64Test.java?rev=1063922&r1=1063921&r2=1063922&view=diff
==============================================================================
--- commons/proper/codec/trunk/src/test/org/apache/commons/codec/binary/Base64Test.java (original)
+++ commons/proper/codec/trunk/src/test/org/apache/commons/codec/binary/Base64Test.java Wed
Jan 26 23:40:25 2011
@@ -336,13 +336,19 @@ public class Base64Test extends TestCase
         testEncodeOverMaxSize(1);
         testEncodeOverMaxSize(2);
     }
+    
+    public void testCodec112() { // size calculation assumes always chunked
+        byte[] in = new byte[] {0};
+        byte[] out=Base64.encodeBase64(in);
+        Base64.encodeBase64(in, false, false, out.length);
+    }
 
     private void testEncodeOverMaxSize(int maxSize) throws Exception {
         try {
             Base64.encodeBase64(Base64TestData.DECODED, true, false, maxSize);
             fail("Expected " + IllegalArgumentException.class.getName());
         } catch (IllegalArgumentException e) {
-            // Expceted
+            // Expected
         }
     }
 



Mime
View raw message