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

java.net.URLEncode.encode(s, enc) treats an empty encoding name as "UTF-8"

    XMLWordPrintable

Details

    • beta
    • sparc
    • solaris_2.6

    Description



      Name: dfR10049 Date: 12/06/2000




      Javadoc for java.net.URLEncode.encode(String s, String enc) states:

         Parameters:
              s - String to be translated.
              enc - The name of a supported character encoding. A value of null will result in
              UTF-8.
          Throws:
              UnsupportedEncodingException - If the named encoding is not supported

      Spec for character encoding states that:
            The empty string is not a legal encoding name.

      But in the current implementation an empty encoding name treats as UTF-8.

      src/java/net/URLEncoder.java:

          public static String encode(String s, String enc)
      throws UnsupportedEncodingException {
        
            ...
       
      if ( (enc == null) || (enc.length() == 0))
      enc = "UTF-8";
          }

      Implementation should be fixed to be consistent with spec or this behavior should
      be reflected in Javadoc.


      ======================================================================

      Name: dfR10049 Date: 12/07/2000



      The same words are acceptable for java.net.URLDecoder class

      ======================================================================

      Attachments

        Activity

          People

            michaelm Michael McMahon
            fdasunw Fda Fda (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: