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

URLDecoder.decode() should not do charset conversion

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P3 P3
    • None
    • 1.2.2_08
    • core-libs
    • None
    • sparc
    • solaris_2.6

      decode() has this section at the end of it:

              // Undo conversion to external encoding
              String result = sb.toString();
              byte[] inputBytes = result.getBytes("8859_1");
              return new String(inputBytes);

      but URLEncoder.encode() OutputStreamWriter() uses the default constructor
      so it does not specify what the charset used is, so it is not necessarily
      have to be 8859_1. Since URLEncoder.encode() is 'supposedly' just taking
      the low 8bits and encoding them, and this is just reversing that, then
      this step is not needed. The end of this function should just be:

              return sb.toString();

            michaelm Michael McMahon
            duke J. Duke
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: