[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [cp-patches] RFC: prevent URL degeneration - v2b
From: |
Robert Schuster |
Subject: |
Re: [cp-patches] RFC: prevent URL degeneration - v2b |
Date: |
Mon, 10 Oct 2005 02:55:51 +0200 |
User-agent: |
Mozilla/5.0 (X11; U; Linux i686; de-AT; rv:1.7.12) Gecko/20051005 |
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 <address@hidden>
* 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
> address@hidden
> 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);
- [cp-patches] RFC: prevent URL degeneration, Robert Schuster, 2005/10/09
- Re: [cp-patches] RFC: prevent URL degeneration - v2, Robert Schuster, 2005/10/09
- Re: [cp-patches] RFC: prevent URL degeneration - v2, Mark Wielaard, 2005/10/09
- Re: [cp-patches] RFC: prevent URL degeneration - v2b,
Robert Schuster <=
- Re: [cp-patches] RFC: prevent URL degeneration - v2b, Mark Wielaard, 2005/10/10
- Re: [cp-patches] RFC: prevent URL degeneration - v2b, Chris Burdess, 2005/10/10
- Re: [cp-patches] RFC: prevent URL degeneration - v2b, Mark Wielaard, 2005/10/10
- Re: [cp-patches] RFC: prevent URL degeneration - v3, Robert Schuster, 2005/10/10
- Re: [cp-patches] RFC: prevent URL degeneration - v3, Robert Schuster, 2005/10/13
- Re: [cp-patches] RFC: prevent URL degeneration - v3, Mark Wielaard, 2005/10/14
- Re: [cp-patches] RFC: prevent URL degeneration - v3, Mark Wielaard, 2005/10/14
Re: [cp-patches] RFC: prevent URL degeneration, Chris Burdess, 2005/10/10