This is the mail archive of the java-patches@gcc.gnu.org mailing list for the Java project.
| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
| Other format: | [Raw text] | |
Hi People,
The change to URLStreamHandler.parseURL of this patch:
2004-04-22 Jeroen Frijters <jeroen@sumatra.nl>
* java/net/URLStreamHandler.java
(parseURL): Convert the file path to using '/' instead of native
file separator.
...causes a StringIndexOutOfBoundsException for the attached
testcase on MinGW on the mainline because of this block of code:
int lastSlash = file.lastIndexOf('/');
file =
file.substring(0, lastSlash) + '/' + spec.substring(start, end);
...because file = ".\" on Win32. The solution seems to be to
canonicalize both the file portion of the URL and not just the spec
if the file: protocol is used.
Tested with the attached testcase on i686-pc-mingw32 and i686-pc-linux-gnu.
Additionally tested against the libjava testsuite and Mauve for i686-pc-linux-gnu.
(Is this the right list or do I need to send these sort of things
to the Classpath folks too?)
-- Mohan
http://www.thisiscool.com/
http://www.animalsong.org/
ChangeLog
2004-06-26 Mohan Embar <gnustuff@thisiscool.com>
* java/net/URLStreamHandler.java (parseURL): Canonicalize
file portion of URL in addition to spec for file: protocol.
Index: java/net/URLStreamHandler.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/net/URLStreamHandler.java,v
retrieving revision 1.29
diff -u -2 -r1.29 URLStreamHandler.java
--- java/net/URLStreamHandler.java 5 May 2004 08:51:04 -0000 1.29
+++ java/net/URLStreamHandler.java 27 Jun 2004 19:17:14 -0000
@@ -132,6 +132,10 @@
// On Windows we need to change \ to / for file URLs
- if (url.getProtocol().equals("file"))
- spec = spec.replace(File.separatorChar, '/');
+ char separator = File.separatorChar;
+ if (url.getProtocol().equals("file") && separator != '/')
+ {
+ file = file.replace(separator, '/');
+ spec = spec.replace(separator, '/');
+ }
if (spec.regionMatches(start, "//", 0, 2))
@@ -217,5 +221,5 @@
boolean endsWithSlash = file.charAt(file.length() - 1) == '/';
file = new File(file).getCanonicalPath();
- file = file.replace(File.separatorChar, '/');
+ file = file.replace(separator, '/');
if (endsWithSlash && file.charAt(file.length() - 1) != '/')
file += '/';
Attachment:
ResourceAsStream.tar.bz2
Description: application/bzip2
| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |