Hi, I noticed that the URL function in libgcj's java.net.URL does not properly process requests like: URL("http://domain.com", "/redir?http://domain2.com/index.html"); This is because at the start of the function, context is set to null if spec contains a :// anywhere, but even in the comment at the top of that function it is mentioned that: /* A protocol is defined by the doc as the substring before a ':' * as long as the ':' occurs before any '/'. Hence I submit the following diff against CVS: --- URL.java 31 Dec 2003 10:55:40 -0000 1.34 +++ URL.java 2 Feb 2004 01:18:04 -0000 @@ -379,12 +379,12 @@ // 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 // and implies that the host from the context is used if available. - int colon; + int colon, slash; if ((colon = spec.indexOf("://", 1)) > 0 && + ((colon < (slash = spec.indexOf('/')) || slash < 0)) && ! spec.regionMatches(colon, "://:", 0, 4)) context = null; - int slash; if ((colon = spec.indexOf(':')) > 0 && (colon < (slash = spec.indexOf('/')) || slash < 0)) { My gcc version information: Configured with: ../gcc/configure --enable-threads=posix --prefix=/opt/gcc --enable-shared --enable-languages=c++,java Thread model: posix gcc version 3.5.0 20040121 (experimental)
Created attachment 5641 [details] Patch against gcc/libjava/java/net/URL.java This patch will rectify the problem mentioned in the bug report... it's probably not as efficient as it could be.
Confirmed, gcj patches should be sent to gcc-patches and java-patches.
Subject: Bug 13972 CVSROOT: /cvs/gcc Module name: gcc Changes by: mkoch@gcc.gnu.org 2005-01-11 20:40:11 Modified files: libjava : ChangeLog libjava/java/net: URL.java Log message: 2005-01-11 Michael Koch <konqueror@gmx.de> PR libgcj/13972 * java/net/URL.java (URL): Handle specs like "/redir?http://domain2.com/index.html" which start with a slash. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libjava/ChangeLog.diff?cvsroot=gcc&r1=1.3284&r2=1.3285 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libjava/java/net/URL.java.diff?cvsroot=gcc&r1=1.44&r2=1.45
Fixed on the mainline for 4.0.0.