|
Quick Lists
|
|
Bug ID:
|
4394817
|
|
Votes
|
0
|
|
Synopsis
|
URL constructor throws java.lang.StringIndexOutOfBoundsException
|
|
Category
|
java:classes_net
|
|
Reported Against
|
1.3
, 1.3.1_06
|
|
Release Fixed
|
1.3.1_10
|
|
State
|
10-Fix Delivered,
Verified,
bug
|
|
Priority:
|
3-Medium
|
|
Related Bugs
|
|
|
Submit Date
|
04-DEC-2000
|
|
Description
|
java version "1.3.0"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0)
Java HotSpot(TM) Client VM (build 1.3.0, mixed mode)
The URL constructor throws a java.lang.StringIndexOutOfBoundsException given the
following URL:
http://www.javasoft.com/jdc/community/chat/index.html#javalive?frontpage-jdc
It can be tested with the following code:
public class Test
{
public static void
main(String[] args) throws Exception
{
System.out.println(new java.net.URL(args[0]).toString());
}
}
(Review ID: 112994)
======================================================================
|
|
Work Around
|
None
======================================================================
|
|
Evaluation
|
The problem is in URLStreamHandler.parseURL(). If the URL contains
a fragment then parseURL() is given a limit that excludes the
fragment (from parsing). If in addition, there is a query inside the
fragment then the following piece of code erroneously tries to
remove the query even though it is past the limit. The
spec.subString() call is given a beginIndex parameter that comes
after the endIndex.
// FIX: should not assume query if opaque
// Strip off the query part
if (start < limit) {
int queryStart = spec.indexOf('?');
queryOnly = queryStart == start;
if (queryStart != -1) {
query = spec.substring(queryStart+1, limit);
if (limit > queryStart)
limit = queryStart;
spec = spec.substring(0, queryStart);
}
}
Incidentally, the problem is with generic URL parsing and is not OS dependent.
xxxxx@xxxxx 2000-12-05
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
|
|
Comments
|
PLEASE NOTE: JDK6 is formerly known as Project Mustang
|
|
|
 |