tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From billbar...@apache.org
Subject cvs commit: jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/net URL.java
Date Fri, 14 Jun 2002 05:34:23 GMT
billbarker    2002/06/13 22:34:23

  Modified:    util/java/org/apache/tomcat/util/net URL.java
  Log:
  Teach URL how to parse userInfo.
  
  This allows URL to parse a string of the form:
  ftp://user:pass@ftp.mycompany.com/
  
  This actually doesn't fix any Tomcat problems (assuming that the string is correct to start
with), and this class is only used by TC33. I just sleep easier if the URL is parsed correctly.
  
  Revision  Changes    Path
  1.2       +8 -4      jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/net/URL.java
  
  Index: URL.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/net/URL.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- URL.java	5 Apr 2002 17:43:33 -0000	1.1
  +++ URL.java	14 Jun 2002 05:34:23 -0000	1.2
  @@ -695,7 +695,11 @@
                   start = limit;
               }
               if (authority.length() > 0) {
  -                int colon = authority.indexOf(':');
  +                int at = authority.indexOf('@');
  +                if( at >= 0 ) {
  +                    userInfo = authority.substring(0,at);
  +                }
  +                int colon = authority.indexOf(':', at+1);
                   if (colon >= 0) {
                       try {
                           port =
  @@ -703,9 +707,9 @@
                       } catch (NumberFormatException e) {
                           throw new MalformedURLException(e.toString());
                       }
  -                    host = authority.substring(0, colon);
  +                    host = authority.substring(at+1, colon);
                   } else {
  -                    host = authority;
  +                    host = authority.substring(at+1);
                       port = -1;
                   }
               }
  
  
  

--
To unsubscribe, e-mail:   <mailto:tomcat-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:tomcat-dev-help@jakarta.apache.org>


Mime
View raw message