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

ISO2022CN and ISO2022KR converters throw exception in response to illegal escape

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 1.4.0
    • 1.3.0
    • core-libs

      The ISO2022CN and ISO2022KR converters do not handle invalid escape sequences correctly. They throw an ArrayIndexOutOfBoundsException when illegal/malformed
      escapes are encountered within an input stream. Note: This is one of a number
      of bugs resulting from a distillation of BugID 4296969, Incorrect behaviour of
      several character converters.

      The following test case will demonstrate this behaviour:

      /*
       * Runtime exceptions generated when illegal ISO2022 escapes
       * are provided within an input stream to be decoded
       */

      public class InvalidEscapes {
       
        public static void main(String[] args){

              for (int i = 0; i < encodings.length; i++){
                  test(encodings[i]);
              }

              try {
                  byte[] bb = new byte[] {(byte)0x1b, (byte)')', (byte)'x'};
                  String str = new String(bb,"ISO2022CN");
              } catch (Throwable th){
                  System.err.println("ISO2022CN error " + th);
              }

              try {
                  byte[] bb = new byte[] {(byte)0x1b, (byte)')', (byte)'x'};
                  String str = new String(bb,"ISO2022KR");
              } catch (Throwable th){
                  System.err.println("ISO2022KR error " + th);
              }

          }
       }

      Ian.Little@Irleland 3/23/2001.

            ilittlesunw Ian Little (Inactive)
            ilittlesunw Ian Little (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: