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

REGRESSION: URI.resolve is unescaping spaces

XMLWordPrintable

    • b40
    • x86
    • windows_xp



      Name: gm110360 Date: 02/09/2004


      FULL PRODUCT VERSION :
      java version "1.5.0-beta"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-beta-b31)
      Java HotSpot(TM) Client VM (build 1.5.0-beta-b31, mixed mode)

      ADDITIONAL OS VERSION INFORMATION :
      Microsoft Windows XP [Version 5.1.2600]

      A DESCRIPTION OF THE PROBLEM :
      Situation:
      Have a file name with spaces as a URI. created with URI.create(string)
      file:/C:/Documents%20and%20Settings/MLambert.NT/.jpluck2/default.jxl
      Using URI.resolve(string) to make a new URI. In this case it is an empty string.
      Under 1.4, URI.resolve("").toString() returned
      file:/C:/Documents%20and%20Settings/MLambert.NT/.jpluck2/
      under 1.5 it returns
      file:/C:/Documents and Settings/MLambert.NT/.jpluck2/


      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      See example

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      See description
      ACTUAL -
      See description

      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      Caused by: java.net.URISyntaxException: Illegal character in path at index 18: file:/C:/Documents and Settings/MLambert.NT/.jpluck2/
              at java.net.URI$Parser.fail(URI.java:2810)
              at java.net.URI$Parser.checkChars(URI.java:2983)
              at java.net.URI$Parser.parseHierarchical(URI.java:3067)
              at java.net.URI$Parser.parse(URI.java:3015)
              at java.net.URI.<init>(URI.java:577)
              at java.net.URI.create(URI.java:839)


      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import java.net.URI;

      /*
       * URITest.java
       *
       * Created on February 4, 2004, 3:46 PM
       */

      /**
       *
       * @author MLambert
       */
      public class URITest
      {
          
          /** Creates a new instance of URITest */
          public URITest()
          {
          }
          
          /**
           * @param args the command line arguments
           */
          public static void main(String[] args)
          {
              String uri = "";
              URI tempU;
              String systemId = "file:/C:/Documents%20and%20Settings/MLambert.NT/.jpluck2/default.jxl";
                  tempU = URI.create(systemId);
                  System.out.println(tempU.toString());
                  tempU = tempU.resolve(uri);
                  System.out.println(tempU.toString());
              
              int i = 0;
          }
          
      }

      ---------- END SOURCE ----------

      Release Regression From : 1.4.2_03
      The above release value was the last known release where this
      bug was known to work. Since then there has been a regression.

      (Incident Review ID: 237262)
      ======================================================================

            michaelm Michael McMahon
            gmanwanisunw Girish Manwani (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: