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

java.net.URL does not perform url encoding/decoding

    Details

    • Subcomponent:
    • CPU:
      sparc
    • OS:
      solaris_2.5.1

      Description



      Name: yyC67448 Date: 01/29/98



      The java.net.URL class does not perform url encoding/decoding, so the
      java.net.URL.equals, java.net.URL.sameFile methods return false on URLs, that
      are equal modulo url encoding.
      The java.net.URL constuctor also does not throw any exceptions on non-urlencoded
      parameters, thus creating an objects in an invalid state.

      Here is the simple test demonstrating the bug:

      -------------------------------- Test.java -----------------------------
      import java.net.*;

      class test
      {

        public static void main(String args[])
        {
        URL url = null;
        URL url1 = null;
        
        try {
          url = new URL("http://web2.javasoft.com/some+file.html");
          url1 = new URL("http://web2.javasoft.com/some%20file.html");
        } catch(Exception e)
        {
          System.out.println("Unexpected exception :" + e);
          System.exit(-1);
        }

        if(url.sameFile(url1))
        {
          System.out.println("OKAY");
          System.exit(0);
        }
        else
        {
          System.out.println("Failed. ");
          System.exit(-1);
        }
      }

      }

      ---------------------- Output from the test --------------------
      Failed.
      -----------------------------------------------------------------

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

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                brenaudsunw Benjamin Renaud (Inactive)
                Reporter:
                duke J. Duke (Inactive)
              • Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Imported:
                  Indexed: