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

java.net.URL(String spec) creates an incorrect URL in JDK 1.3

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Not an Issue
    • Icon: P3 P3
    • None
    • 1.3.0
    • core-libs
    • sparc
    • solaris_2.6



      Name: ksC84122 Date: 07/02/99


      JDK 1.3 java.net.URL(String spec) constructs an incorrect URL
      if parameter spec contains a file name followed by "/../".
      It does not reduce the spec and java.net.URL methods can not resolve such a url.

      To set up the test example, please create any file like "anyfile.txt" in some
      directory like "/tmp" and change the following line in the test case accordingly:
         String URLDIR = "file:/tmp/anyfile.txt/../";

      A test example which demonstrates this problem.
      ===== test.java ========
      import java.net.*;
      import java.io.*;

      public class test {

          public static void main (String argv[]) {

              URL url = null;
      String URLDIR = "file:/tmp/anyfile.txt/../";

              try {
                  url = new URL(URLDIR);
                  System.out.println(url);
              } catch(MalformedURLException e) {
                  System.out.println("FAIL: MalformedURLException: parsing of URL failed:\n"
                      + URLDIR);
              }
              
              try {
                  System.out.println("content: " + url.openConnection().getContent());
              } catch (IOException ioe) {
                  System.out.println("error openning connection");
              }
              
              return;
          }
      }

      ========= Sample run (JDK1.3) ==========
      #>java test
      file:/tmp/anyfile.txt/../
      error openning connection

      ========= Sample run (JDK1.2.2) ==========
      #>java test
      file:/tmp/
      content: java.io.ByteArrayInputStream@b812b0d1

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

            jdn Jeffrey Nisewanger (Inactive)
            skosunw Sko Sko (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: