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

URL with user and no password throws unexpected exception

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P3 P3
    • None
    • 1.3.0
    • core-libs
    • None
    • sparc
    • solaris_8

      The URL: ftp://user@password@server/file
      will cause the constructor for FtpURLConnection to throw
      StringIndexOutOfBoundsException. This was not expected.

      The code assumes that if a user is specified in the URL
      then there will be a colon used to specify the password.

           public FtpURLConnection(URL url) {
               super(url);
               host = url.getHost();
               String userInfo = url.getUserInfo();
       
               if (userInfo != null) { // get the user and password
                   int delimiter = userInfo.indexOf(':');
                   user = userInfo.substring(0, delimiter++);
                   password = userInfo.substring(delimiter);
               }
           }

      Bug 4450673 has a stack trace of this problem.

      % java -version
      java version "1.3.0"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0)
      Java HotSpot(TM) Client VM (build 1.3.0, mixed mode)

            alanb Alan Bateman
            duke J. Duke
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: