Hi,
as mark pointed out my last attachment was empty.
This is the right one.
I checked that there are no regressions in mauve URL tests.
Here is the changelog entry again:
2005-10-07 Robert Schuster <[EMAIL PROTECTED]>
* java/net/URLStreamHandler.java:
(toExternalForm): Remove superfluous leading slashes from URL
paths.
Mark Wielaard wrote:
> Hi Robert,
>
> On Mon, 2005-10-10 at 00:31 +0200, Robert Schuster wrote:
>
>>as discussed on IRC the indenting of the last patch was wrong. This has been
>>fixed.
>
>
> Actually this version had an empty .diff attached.
>
> BTW. Did you run this against mauve?
>
> Cheers,
>
> Mark
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> Classpath-patches mailing list
> [email protected]
> http://lists.gnu.org/mailman/listinfo/classpath-patches
Index: java/net/URLStreamHandler.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/net/URLStreamHandler.java,v
retrieving revision 1.35
diff -u -r1.35 URLStreamHandler.java
--- java/net/URLStreamHandler.java 2 Oct 2005 22:58:41 -0000 1.35
+++ java/net/URLStreamHandler.java 9 Oct 2005 22:31:21 -0000
@@ -520,7 +520,25 @@
sb.append("//").append(authority);
}
- sb.append(file);
+ // If we have superfluous leading slashes (that means, at least 2)
+ // we subsequently remove them and add a filepath with only one
+ // slash. In case that the filepath had none or one slash it is
+ // appended unchanged.
+ // By doing this we prevent that an URL with many superfluous
+ // leading slashes in the filepath degenerates into an URL
+ // where parts of the path become the host. Without that code
+ // new URL(new URL("file:////home/foo").toString()) would result
+ // in an URL instance which points to file://home/foo .
+ if ( file.startsWith("//") )
+ {
+ int slash = 1;
+ while ( file.charAt(slash+1) == '/' )
+ slash++;
+
+ sb.append(file.substring(slash));
+ }
+ else
+ sb.append(file);
if (ref != null)
sb.append('#').append(ref);
_______________________________________________
Classpath-patches mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/classpath-patches