cvs commit: jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/net URL.java
billbarker2004/06/19 17:08:15 Modified:util/java/org/apache/tomcat/util/net URL.java Log: Improve parsing of the scheme component of the URI to closer match the RFC. Revision ChangesPath 1.8 +12 -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.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- URL.java 24 Feb 2004 08:50:05 - 1.7 +++ URL.java 20 Jun 2004 00:08:15 - 1.8 @@ -106,8 +106,8 @@ } // Parse out the new protocol -for (i = start; !aRef (i limit) - ((c = spec.charAt(i)) != '/'); i++) { +for (i = start; !aRef (i limit) ; i++) { +c = spec.charAt(i); if (c == ':') { String s = spec.substring(start, i).toLowerCase(); // Assume all protocols are valid @@ -116,7 +116,7 @@ break; } else if( c == '#' ) { aRef = true; -} else if( c == '?' ) { +} else if( !isSchemeChar((char)c) ) { break; } } @@ -719,5 +719,13 @@ } +/** + * Determine if the character is allowed in the scheme of a URI. + * See RFC 2396, Section 3.1 + */ +public static boolean isSchemeChar(char c) { +return Character.isLetterOrDigit(c) || +c == '+' || c == '-' || c == '.'; +} } - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: cvs commit: jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/net URL.java
- Original Message - From: [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Thursday, June 13, 2002 10:34 PM Subject: cvs commit: jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/net URL.java billbarker2002/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:[EMAIL PROTECTED]/ 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. I have no objection to applying this to o.a.c.u.URL (this is just a re-packaged version of that class). However, with Remy doing so many releases, I thought I should ask before hacking the 4.x files. ;-) Like with 3.3 it seems that 4.x ignores the resulting (in the current code) MalformedURLException (from the ':'), and passes on the original URL string. As such (like in 3.3) it doesn't fix anything functionally. -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
cvs commit: jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/net URL.java
billbarker2002/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:[EMAIL PROTECTED]/ 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 ChangesPath 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 - 1.1 +++ URL.java 14 Jun 2002 05:34:23 - 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:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]