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

Incorrect UTF8 conversion for sequence fc 80 80 8f bf bf

    XMLWordPrintable

Details

    • Bug
    • Status: Closed
    • P4
    • Resolution: Fixed
    • 7
    • 8
    • core-libs
    • b14
    • generic
    • generic
    • Verified

    Description

      SYNOPSIS
      --------
      Incorrect UTF8 conversion for sequence fc 80 80 8f bf bf

      OPERATING SYSTEM
      ----------------
      All

      FULL JDK VERSION
      ----------------
      Java 6 (tested with 1.6.0_26)
      Java 7 (tested with GA / b147)

      PROBLEM DESCRIPTION from LICENSEE
      ---------------------------------
      The UTF8 specification states that the maximal valid subpart should be replaced by a single fffd before moving to process the next one. In this case FC is invalid, therefore each subsequent byte should be treated as single byte.

      TESTCASE
      --------
      public class RegTest {
          public static void main (String args[]) throws Exception {
                  byte[] test1 = new byte[] {(byte)0xfc, (byte)0x80, (byte)0x80, (byte)0x8f, (byte)0xbf, (byte)0xbf};
                  String s1 = stringToHex(new String(test1, "UTF8"));
                  System.out.println(s1);
          }

          public static String stringToHex( String base ) {
              StringBuffer buffer = new StringBuffer();
              int intValue;
              for (int x = 0; x < base.length(); x ++) {
                  intValue = base.charAt(x);
                  String hex = Integer.toHexString(intValue);
                  if (hex.length() == 1) {
                      buffer.append("0" + hex + " ");
                  } else {
                      buffer.append(hex + " ");
                  }
              }
              return buffer.toString();
          }
      }

      REPRODUCTION INSTRUCTIONS
      -------------------------
      1. javac RegTest.java
      2. java RegTest

      Actual Output:
      fffd

      Expected Output:
      fffd fffd fffd fffd fffd fffd

      Attachments

        Activity

          People

            sherman Xueming Shen
            dkorbel David Korbel (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: