--- old/test/java/util/Base64/TestBase64.java 2013-01-31 13:06:04.000000000 -0800 +++ new/test/java/util/Base64/TestBase64.java 2013-01-31 13:06:04.000000000 -0800 @@ -22,7 +22,7 @@ */ /** - * @test 4235519 8004212 8005394 + * @test 4235519 8004212 8005394 8007298 * @summary tests java.util.Base64 */ @@ -109,6 +109,9 @@ // test return value from decode(ByteBuffer, ByteBuffer) testDecBufRet(); + + // test single-non-base64 character for mime decoding + testSingleNonBase64MimeDec(); } private static sun.misc.BASE64Encoder sunmisc = new sun.misc.BASE64Encoder(); @@ -356,6 +359,19 @@ } catch (IllegalArgumentException iae) {} } + // single-non-base64-char should be ignored for mime decoding, but + // iae for basic decoding + private static void testSingleNonBase64MimeDec() throws Throwable { + for (String nonBase64 : new String[] {"#", "(", "!", "\\", "-", "_"}) { + if (Base64.getMimeDecoder().decode(nonBase64).length != 0) { + throw new RuntimeException("non-base64 char is not ignored"); + } + try { + Base64.getDecoder().decode(nonBase64); + throw new RuntimeException("No IAE for single non-base64 char"); + } catch (IllegalArgumentException iae) {} + } + } private static void testDecBufRet() throws Throwable { Random rnd = new java.util.Random();