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

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

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P3
    • Resolution: Not an Issue
    • Affects Version/s: 1.3.0
    • Fix Version/s: None
    • Component/s: core-libs
    • Labels:
    • Subcomponent:
    • CPU:
      sparc
    • OS:
      solaris_2.6

      Description



      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

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

        Attachments

          Activity

            People

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

              Dates

              • Created:
                Updated:
                Resolved:
                Imported:
                Indexed: