Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8176043

java.util.Base64 mime decoder does not ignore illegal characters during decoding

    • x86_64
    • linux_ubuntu

      FULL PRODUCT VERSION :
      java version "1.8.0_121"
      Java(TM) SE Runtime Environment (build 1.8.0_121-b13)
      Java HotSpot(TM) 64-Bit Server VM (build 25.121-b13, mixed mode)

      A DESCRIPTION OF THE PROBLEM :
      The specification for java.util.Base64 MIME decoder says: "All line separators or other characters not found in the base64 alphabet table are ignored in decoding operation." This does not hold for example for input "TQ=*" which throws the following exception:

      Exception in thread "main" java.lang.IllegalArgumentException: Input byte array has wrong 4-byte ending unit
      at java.util.Base64$Decoder.decode0(Base64.java:704)
      at java.util.Base64$Decoder.decode(Base64.java:526)
      at java.util.Base64$Decoder.decode(Base64.java:549)

      REGRESSION. Last worked in version 8u112


      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      public static void main(String[] args) {
        Base64.getMimeDecoder().decode("TQ=*");
        // or
        Base64.getMimeDecoder().decode("TQ=");
      }

      ---------- END SOURCE ----------

            sherman Xueming Shen
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: