This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
Absolute URL parsing bug
- From: Andrew Haley <aph at redhat dot com>
- To: GCJ Patches <java-patches at gcc dot gnu dot org>, classpath patches <classpath-patches at gnu dot org>
- Date: Fri, 1 Jul 2005 17:48:22 +0100
- Subject: Absolute URL parsing bug
This URL is an absolute URL because its path begins with a "/":
"jar:file:/usr/src/redhat/BUILD/jonas-4.3.3/jonas/output/JONAS_4_3_3/examples/webservices/beans/ws/temp/ejbjars/ws.jar!/META-INF/wsdl/ssbEndpoint.wsdl"
[ An absolute file URL can look like:
absoluteURI = "file" ":" abs_path
abs_path = "/" path_segments
That is, there is no need for "//". And indeed, the URL spec in the
SDK docs says 'If the spec's path component begins with a slash
character "/" then the path is treated as absolute...' ]
But we parse the spec looking for "//" to determine if a URL is
absolute, and this is wrong. So, I suggest this patch.
This bug was found because it breaks the JOnAS build.
Andrew.
2005-07-01 Andrew Haley <aph@redhat.com>
* java/net/URL.java: Look only for "/" at the start of an absolute
path, not "//".
Index: java/net/URL.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/net/URL.java,v
retrieving revision 1.51
diff -p -2 -u -r1.51 URL.java
--- java/net/URL.java 27 Apr 2005 20:10:07 -0000 1.51
+++ java/net/URL.java 1 Jul 2005 16:39:22 -0000
@@ -389,10 +389,11 @@ public final class URL implements Serial
// If this is an absolute URL, then ignore context completely.
- // An absolute URL must have chars prior to "://" but cannot have a colon
- // right after the "://". The second colon is for an optional port value
+ // If this is an absolute URL, then ignore context completely.
+ // An absolute URL must have chars prior to ":/" but cannot have a colon
+ // right after "://". The second colon is for an optional port value
// and implies that the host from the context is used if available.
int colon;
int slash = spec.indexOf('/');
- if ((colon = spec.indexOf("://", 1)) > 0
+ if ((colon = spec.indexOf(":/", 1)) > 0
&& ((colon < slash || slash < 0))
&& ! spec.regionMatches(colon, "://:", 0, 4))