Description
Mime decoder does not ignore non-Base64 chars that appear after padding ('=')
import java.util.Base64;
public class CharToIgnoreAtTheEnd {
public static void main(String[] args) {
Base64.getMimeDecoder().decode("bGVhc3VyZS4=$");
}
}
The output is
Exception in thread "main" java.lang.IllegalArgumentException: Input byte array has wrong 4-byte ending unit
at java.util.Base64$Decoder.decode0(Base64.java:1080)
at java.util.Base64$Decoder.decode(Base64.java:686)
at java.util.Base64$Decoder.decode(Base64.java:709)
at CharToIgnoreAtTheEnd.main(CharToIgnoreAtTheEnd.java:6)
The following JCK tests will fail due to this issue:
api/java_util/Base64/Decoder/index.html#MimeDec_NonBase64CharsIgnored[validInput_ignoredCharAtTheEnd]
api/java_util/Base64/Decoder/index.html#MimeDec_NonBase64CharsIgnored[lineSeparatorInTheEnd]
api/java_util/Base64/index.html#Samples[phrase_01_decodeToByteArray]
import java.util.Base64;
public class CharToIgnoreAtTheEnd {
public static void main(String[] args) {
Base64.getMimeDecoder().decode("bGVhc3VyZS4=$");
}
}
The output is
Exception in thread "main" java.lang.IllegalArgumentException: Input byte array has wrong 4-byte ending unit
at java.util.Base64$Decoder.decode0(Base64.java:1080)
at java.util.Base64$Decoder.decode(Base64.java:686)
at java.util.Base64$Decoder.decode(Base64.java:709)
at CharToIgnoreAtTheEnd.main(CharToIgnoreAtTheEnd.java:6)
The following JCK tests will fail due to this issue:
api/java_util/Base64/Decoder/index.html#MimeDec_NonBase64CharsIgnored[validInput_ignoredCharAtTheEnd]
api/java_util/Base64/Decoder/index.html#MimeDec_NonBase64CharsIgnored[lineSeparatorInTheEnd]
api/java_util/Base64/index.html#Samples[phrase_01_decodeToByteArray]
Attachments
Issue Links
- duplicates
-
JDK-8006530 Base64.getMimeDecoder().decode() throws exception for non-base64 character after padding =
- Closed
- relates to
-
JDK-8006530 Base64.getMimeDecoder().decode() throws exception for non-base64 character after padding =
- Closed
-
JDK-8259896 Base64 MIME decoder should allow unrecognised characters within padding.
- Open