commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject svn commit: r1458936 - in /commons/proper/fileupload/trunk/src: main/java/org/apache/commons/fileupload/util/mime/Base64Decoder.java test/java/org/apache/commons/fileupload/util/mime/Base64DecoderTestCase.java
Date Wed, 20 Mar 2013 16:37:14 GMT
Author: sebb
Date: Wed Mar 20 16:37:13 2013
New Revision: 1458936

URL: http://svn.apache.org/r1458936
Log:
Ignore non-Base64 bytes

Modified:
    commons/proper/fileupload/trunk/src/main/java/org/apache/commons/fileupload/util/mime/Base64Decoder.java
    commons/proper/fileupload/trunk/src/test/java/org/apache/commons/fileupload/util/mime/Base64DecoderTestCase.java

Modified: commons/proper/fileupload/trunk/src/main/java/org/apache/commons/fileupload/util/mime/Base64Decoder.java
URL: http://svn.apache.org/viewvc/commons/proper/fileupload/trunk/src/main/java/org/apache/commons/fileupload/util/mime/Base64Decoder.java?rev=1458936&r1=1458935&r2=1458936&view=diff
==============================================================================
--- commons/proper/fileupload/trunk/src/main/java/org/apache/commons/fileupload/util/mime/Base64Decoder.java
(original)
+++ commons/proper/fileupload/trunk/src/main/java/org/apache/commons/fileupload/util/mime/Base64Decoder.java
Wed Mar 20 16:37:13 2013
@@ -106,7 +106,7 @@ final class Base64Decoder {
             }
             final byte d = DECODING_TABLE[MASK_BYTE_UNSIGNED & b];
             if (d == INVALID_BYTE) {
-                throw new IOException("Invalid Base64 byte: " + b);
+                continue; // Ignore invalid bytes
             }
             cache[cachedBytes++] = d;
             if (cachedBytes == INPUT_BYTES_PER_CHUNK) {

Modified: commons/proper/fileupload/trunk/src/test/java/org/apache/commons/fileupload/util/mime/Base64DecoderTestCase.java
URL: http://svn.apache.org/viewvc/commons/proper/fileupload/trunk/src/test/java/org/apache/commons/fileupload/util/mime/Base64DecoderTestCase.java?rev=1458936&r1=1458935&r2=1458936&view=diff
==============================================================================
--- commons/proper/fileupload/trunk/src/test/java/org/apache/commons/fileupload/util/mime/Base64DecoderTestCase.java
(original)
+++ commons/proper/fileupload/trunk/src/test/java/org/apache/commons/fileupload/util/mime/Base64DecoderTestCase.java
Wed Mar 20 16:37:13 2013
@@ -79,14 +79,11 @@ public final class Base64DecoderTestCase
     }
 
     /**
-     * Throws IOException for non-BASE64 bytes.
-     *
-     * @throws Exception
+     * Ignores non-BASE64 bytes.
      */
-    @Test(expected = IOException.class)
+    @Test
     public void nonBase64Bytes() throws Exception {
-        final byte[] x = new byte[]{'n', 'A', (byte) 0x9c};
-        Base64Decoder.decode(x, new ByteArrayOutputStream());
+        assertEncoded("Hello World", "S?G!V%sbG 8g\rV\t\n29ybGQ*=");
     }
 
     @Test(expected = IOException.class)



Mime
View raw message