You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by bi...@apache.org on 2004/06/20 02:08:15 UTC
cvs commit: jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/net URL.java
billbarker 2004/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 Changes Path
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 -0000 1.7
+++ URL.java 20 Jun 2004 00:08:15 -0000 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: tomcat-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org