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

invalid URL (no authority component) not detected by URL() constructor

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P4 P4
    • None
    • 1.3.0
    • core-libs
    • None
    • generic
    • solaris_9

      daniel.daugherty@Eng 1999-08-02

      The following java programs illustrates the bug:

      File repro3a.java:

      import java.net.*;

      public class repro3a {
          public static void main(String[] args) {
      try {
      //
      // According to Section 3.2 of RFC 2396, when '//' is
      // used to indicate an authority component, either a
      // server or reg_name token must follow.
      //
      URL url = new URL("http://");
      System.err.println("Test FAILed:"
      + " URL constructor did not throw exception.");
      } catch (MalformedURLException e) {
      System.out.println("Test PASSed: URL constructor threw exception.");
      // Expect MalformedURLException: no authority: http://
      System.out.println(e.getMessage());
      }
          }
      }


      File repro3b.java:

      import java.net.*;

      public class repro3b {
          public static void main(String[] args) {
      try {
      //
      // According to Section 3.2 of RFC 2396, when '//' is
      // used to indicate an authority component, either a
      // server or reg_name token must follow. The abs_path
      // token (the third slash) can follow the missing server
      // or reg_name token.
      //
      URL url = new URL("http:///");
      System.err.println("Test FAILed:"
      + " URL constructor did not throw exception.");
      } catch (MalformedURLException e) {
      System.out.println("Test PASSed: URL constructor threw exception.");
      // Expect MalformedURLException: no authority: http:///
      System.out.println(e.getMessage());
      }
          }
      }

            jccollet Jean-Christophe Collet (Inactive)
            dcubed Daniel Daugherty
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: