-
Bug
-
Resolution: Unresolved
-
P3
-
None
-
6, 6u1
-
x86
-
solaris_2.5.1, solaris_nevada
FULL PRODUCT VERSION :
java version "1.6.0_01"
Java(TM) SE Runtime Environment (build 1.6.0_01-b06)
Java HotSpot(TM) Client VM (build 1.6.0_01-b06, mixed mode, sharing)
ADDITIONAL OS VERSION INFORMATION :
SunOS 5.11 snv_61 i86pc i386 i86pc
A DESCRIPTION OF THE PROBLEM :
when normalizing URIs with multiple slashes
using java.net.URI method normalize,
it works like follows:
http://host/seg1//seg2 -> http://host/seg1/seg2
^^ ^
which is wrong. According to javadoc, it should only
replace unnecessary "." and ".." segments:
--quote--
Normalization is the process of removing unnecessary "." and ".." segments from
the path component of a hierarchical URI. Each "." segment is simply removed. A
".." segment is removed only if it is preceded by a non-".." segment.
Normalization has no effect upon opaque URIs.
--quote--
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
following code:
--cuthere--
URI baseURI = new URI("http://host/seg1//seg2");
System.out.println("baseURI.toString() = " + baseURI.toString());
System.out.println("baseURI.normalize().toString() = " +
baseURI.normalize().toString());
--cuthere--
produces:
--cuthere--
baseURI.toString() = http://host/seg1//seg2
baseURI.normalize().toString() = http://host/seg1/seg2
--cuthere--
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
baseURI.toString() = http://host/seg1//seg2
baseURI.normalize().toString() = http://host/seg1//seg2
ACTUAL -
baseURI.toString() = http://host/seg1//seg2
baseURI.normalize().toString() = http://host/seg1/seg2
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.net.URI;
import java.net.URISyntaxException;
/**
*
* @author japod
*/
public class UriNormalizeIssue {
/** Creates a new instance of Main */
public UriNormalizeIssue() {
}
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
try {
URI baseURI = new URI("http://host/seg1//seg2");
System.out.println("baseURI.toString() = " + baseURI.toString());
System.out.println("baseURI.normalize().toString() = " + baseURI.normalize().toString());
} catch (URISyntaxException ex) {
ex.printStackTrace();
}
}
}
---------- END SOURCE ----------
java version "1.6.0_01"
Java(TM) SE Runtime Environment (build 1.6.0_01-b06)
Java HotSpot(TM) Client VM (build 1.6.0_01-b06, mixed mode, sharing)
ADDITIONAL OS VERSION INFORMATION :
SunOS 5.11 snv_61 i86pc i386 i86pc
A DESCRIPTION OF THE PROBLEM :
when normalizing URIs with multiple slashes
using java.net.URI method normalize,
it works like follows:
http://host/seg1//seg2 -> http://host/seg1/seg2
^^ ^
which is wrong. According to javadoc, it should only
replace unnecessary "." and ".." segments:
--quote--
Normalization is the process of removing unnecessary "." and ".." segments from
the path component of a hierarchical URI. Each "." segment is simply removed. A
".." segment is removed only if it is preceded by a non-".." segment.
Normalization has no effect upon opaque URIs.
--quote--
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
following code:
--cuthere--
URI baseURI = new URI("http://host/seg1//seg2");
System.out.println("baseURI.toString() = " + baseURI.toString());
System.out.println("baseURI.normalize().toString() = " +
baseURI.normalize().toString());
--cuthere--
produces:
--cuthere--
baseURI.toString() = http://host/seg1//seg2
baseURI.normalize().toString() = http://host/seg1/seg2
--cuthere--
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
baseURI.toString() = http://host/seg1//seg2
baseURI.normalize().toString() = http://host/seg1//seg2
ACTUAL -
baseURI.toString() = http://host/seg1//seg2
baseURI.normalize().toString() = http://host/seg1/seg2
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.net.URI;
import java.net.URISyntaxException;
/**
*
* @author japod
*/
public class UriNormalizeIssue {
/** Creates a new instance of Main */
public UriNormalizeIssue() {
}
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
try {
URI baseURI = new URI("http://host/seg1//seg2");
System.out.println("baseURI.toString() = " + baseURI.toString());
System.out.println("baseURI.normalize().toString() = " + baseURI.normalize().toString());
} catch (URISyntaxException ex) {
ex.printStackTrace();
}
}
}
---------- END SOURCE ----------