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

URI (multiparam) constructor throws URISyntaxException when path contains []

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P4
    • Resolution: Duplicate
    • Affects Version/s: 7u72, 8u25
    • Fix Version/s: tbd
    • Component/s: core-libs
    • Labels:
    • Subcomponent:
    • CPU:
      x86_64
    • OS:
      windows_7

      Description

      FULL PRODUCT VERSION :
      java version "1.8.0_25"
      Java(TM) SE Runtime Environment (build 1.8.0_25-b18)
      Java HotSpot(TM) Client VM (build 25.25-b02, mixed mode, sharing)

      ADDITIONAL OS VERSION INFORMATION :
      Microsoft Windows [Wersja 6.1.7601]

      A DESCRIPTION OF THE PROBLEM :
      Acording to documentation multi parameter java.net.URI constructors should escape any illegal uri characters. But this seems not to be the case for [] (square brackets) in path.

      Try to run the following code:

      import java.net.URI;

      public class BugReproduction {
         public static void main(String[] args) throws Exception {
      new URI("file","/temp/a[1].txt", null);
         }
      }

      According to documentation it should be working fine, all illegal characters should be escaped/quoted. But instead it throws:

      Exception in thread "main" java.net.URISyntaxException: Illegal character in path at index 11: file:/temp/[1].txt
      at java.net.URI$Parser.fail(URI.java:2829)
      at java.net.URI$Parser.checkChars(URI.java:3002)
      at java.net.URI$Parser.parseHierarchical(URI.java:3086)
      at java.net.URI$Parser.parse(URI.java:3034)
      at java.net.URI.<init>(URI.java:824)


      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Try to run the following code:

      import java.net.URI;

      public class BugReproduction {
         public static void main(String[] args) throws Exception {
      new URI("file","/temp/a[1].txt", null);
         }
      }

      According to documentation it should be working fine, all illegal characters should be escaped/quoted. But instead it throws:

      Exception in thread "main" java.net.URISyntaxException: Illegal character in path at index 11: file:/temp/[1].txt
      at java.net.URI$Parser.fail(URI.java:2829)
      at java.net.URI$Parser.checkChars(URI.java:3002)
      at java.net.URI$Parser.parseHierarchical(URI.java:3086)
      at java.net.URI$Parser.parse(URI.java:3034)
      at java.net.URI.<init>(URI.java:824)


      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      No exception is thrown
      ACTUAL -
      Exception in thread "main" java.net.URISyntaxException: Illegal character in path at index 11: file:/temp/[1].txt
      at java.net.URI$Parser.fail(URI.java:2829)
      at java.net.URI$Parser.checkChars(URI.java:3002)
      at java.net.URI$Parser.parseHierarchical(URI.java:3086)
      at java.net.URI$Parser.parse(URI.java:3034)
      at java.net.URI.<init>(URI.java:824)


      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      Exception in thread "main" java.net.URISyntaxException: Illegal character in path at index 11: file:/temp/[1].txt
      at java.net.URI$Parser.fail(URI.java:2829)
      at java.net.URI$Parser.checkChars(URI.java:3002)
      at java.net.URI$Parser.parseHierarchical(URI.java:3086)
      at java.net.URI$Parser.parse(URI.java:3034)
      at java.net.URI.<init>(URI.java:824)


      REPRODUCIBILITY :
      This bug can be reproduced always.

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

      public class BugReproduction {
         public static void main(String[] args) throws Exception {
      new URI("file","/temp/a[1].txt", null);
         }
      }

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

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                webbuggrp Webbug Group
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: