commit | 2cd8c1dd4d9c2938e976efc007bf0543eff23a90 | [log] [tgz] |
---|---|---|
author | Sebastian Bazley <sebb@apache.org> | Wed Mar 20 16:37:13 2013 +0000 |
committer | Sebastian Bazley <sebb@apache.org> | Wed Mar 20 16:37:13 2013 +0000 |
tree | 6a0b79df94b82bc2ed1275d136d222d28d2290f2 | |
parent | 28c4b9626a340a770a4ff02fa8536ff7877296f3 [diff] |
Ignore non-Base64 bytes git-svn-id: https://svn.apache.org/repos/asf/commons/proper/fileupload/trunk@1458936 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/src/main/java/org/apache/commons/fileupload/util/mime/Base64Decoder.java b/src/main/java/org/apache/commons/fileupload/util/mime/Base64Decoder.java index 98bb54a..ea51361 100644 --- a/src/main/java/org/apache/commons/fileupload/util/mime/Base64Decoder.java +++ b/src/main/java/org/apache/commons/fileupload/util/mime/Base64Decoder.java
@@ -106,7 +106,7 @@ } 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) {
diff --git a/src/test/java/org/apache/commons/fileupload/util/mime/Base64DecoderTestCase.java b/src/test/java/org/apache/commons/fileupload/util/mime/Base64DecoderTestCase.java index a58ed99..5e4bf74 100644 --- a/src/test/java/org/apache/commons/fileupload/util/mime/Base64DecoderTestCase.java +++ b/src/test/java/org/apache/commons/fileupload/util/mime/Base64DecoderTestCase.java
@@ -79,14 +79,11 @@ } /** - * 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)