-
Bug
-
Resolution: Duplicate
-
P3
-
None
-
6
-
x86
-
solaris_2.5.1
A DESCRIPTION OF THE REGRESSION :
When converting a filename containing a valid percent-encoding sequence to a URI via File.toURI(), jdk 1.4 and 1.5 will escape the percent characters in the URI, and unescape them during URI.getPath().
jdk1.6 does not escape the percent chars, and thus when getPath or new File(URI) is called, the encoded sequence is decoded to not correspond to the original file.
This also affects simple File->URI->File roundtripping.
Run the supplied test case to see the results. You may supply a character sequence on the command line, for example "%5c" is handled fine by 5.0u6, but is converted to "\" by mustang.
When the sequence "%ff" is used, it is handled fine by 5.0u6, but after the round trip is converted to "%FF".
REPRODUCIBLE TESTCASE OR STEPS TO REPRODUCE:
import java.io.File;
public class MustangURITest {
public static void main(String[] args) throws Exception {
String confusion = (args.length > 0) ? args[0] : "%5c";
String name = "asdf" + confusion + "test.xml";
File f = new File(name).getCanonicalFile();
File f2 = new File(f.toURI());
// Check that roundtrip is OK
System.out.println("URI is " + f.toURI());
System.out.println(((f.equals(f2)) ? "PASS " : "FAIL ") + f + " vs " + f2);
// Same thing via getPath()
String filestr = f.toString();
String uripath = f.toURI().getPath();
System.out.println(((filestr.equals(uripath)) ? "PASS " : "FAIL ") + filestr + " vs " + uripath);
}
}
RELEASE LAST WORKED:
5.0 Update 6
RELEASE TEST FAILS:
mustang-beta
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Round trip should produce the same name as used as input:
[len@noir volatile]$ /usr/local/java/jdk1.5/bin/java MustangURITest "%5c"
URI is file:/home2/len/reeltwo_sandboxes/volatile/asdf%255ctest.xml
PASS /home2/len/reeltwo_sandboxes/volatile/asdf%5ctest.xml vs /home2/len/reeltwo_sandboxes/volatile/asdf%5ctest.xml
PASS /home2/len/reeltwo_sandboxes/volatile/asdf%5ctest.xml vs /home2/len/reeltwo_sandboxes/volatile/asdf%5ctest.xml
[len@noir volatile]$ /usr/local/java/jdk1.5/bin/java MustangURITest "%ff"
URI is file:/home2/len/reeltwo_sandboxes/volatile/asdf%25fftest.xml
PASS /home2/len/reeltwo_sandboxes/volatile/asdf%fftest.xml vs /home2/len/reeltwo_sandboxes/volatile/asdf%fftest.xml
PASS /home2/len/reeltwo_sandboxes/volatile/asdf%fftest.xml vs /home2/len/reeltwo_sandboxes/volatile/asdf%fftest.xml
ACTUAL -
[len@noir volatile]$ /usr/local/java/jdk1.6/bin/java MustangURITest "%5c"
URI is file:/home2/len/reeltwo_sandboxes/volatile/asdf%5ctest.xml
FAIL /home2/len/reeltwo_sandboxes/volatile/asdf%5ctest.xml vs /home2/len/reeltwo_sandboxes/volatile/asdf\test.xml
FAIL /home2/len/reeltwo_sandboxes/volatile/asdf%5ctest.xml vs /home2/len/reeltwo_sandboxes/volatile/asdf\test.xml
[len@noir volatile]$ /usr/local/java/jdk1.6/bin/java MustangURITest "%ff"
URI is file:/home2/len/reeltwo_sandboxes/volatile/asdf%fftest.xml
FAIL /home2/len/reeltwo_sandboxes/volatile/asdf%fftest.xml vs /home2/len/reeltwo_sandboxes/volatile/asdf%FFtest.xml
FAIL /home2/len/reeltwo_sandboxes/volatile/asdf%fftest.xml vs /home2/len/reeltwo_sandboxes/volatile/asdf%FFtest.xml
OBSERVED APPLICATION IMPACT:
We have software that uses URI's internally for referencing documents stored in various locations, some of which are Files. This regression breaks the ability to read such referenced files.
(FYI, I am using Linux IA32, Fedora FC4, but I doubt it's specific to this OS)
Release Regression From : 5.0u6
The above release value was the last known release where this
bug was known to work. Since then there has been a regression.
When converting a filename containing a valid percent-encoding sequence to a URI via File.toURI(), jdk 1.4 and 1.5 will escape the percent characters in the URI, and unescape them during URI.getPath().
jdk1.6 does not escape the percent chars, and thus when getPath or new File(URI) is called, the encoded sequence is decoded to not correspond to the original file.
This also affects simple File->URI->File roundtripping.
Run the supplied test case to see the results. You may supply a character sequence on the command line, for example "%5c" is handled fine by 5.0u6, but is converted to "\" by mustang.
When the sequence "%ff" is used, it is handled fine by 5.0u6, but after the round trip is converted to "%FF".
REPRODUCIBLE TESTCASE OR STEPS TO REPRODUCE:
import java.io.File;
public class MustangURITest {
public static void main(String[] args) throws Exception {
String confusion = (args.length > 0) ? args[0] : "%5c";
String name = "asdf" + confusion + "test.xml";
File f = new File(name).getCanonicalFile();
File f2 = new File(f.toURI());
// Check that roundtrip is OK
System.out.println("URI is " + f.toURI());
System.out.println(((f.equals(f2)) ? "PASS " : "FAIL ") + f + " vs " + f2);
// Same thing via getPath()
String filestr = f.toString();
String uripath = f.toURI().getPath();
System.out.println(((filestr.equals(uripath)) ? "PASS " : "FAIL ") + filestr + " vs " + uripath);
}
}
RELEASE LAST WORKED:
5.0 Update 6
RELEASE TEST FAILS:
mustang-beta
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Round trip should produce the same name as used as input:
[len@noir volatile]$ /usr/local/java/jdk1.5/bin/java MustangURITest "%5c"
URI is file:/home2/len/reeltwo_sandboxes/volatile/asdf%255ctest.xml
PASS /home2/len/reeltwo_sandboxes/volatile/asdf%5ctest.xml vs /home2/len/reeltwo_sandboxes/volatile/asdf%5ctest.xml
PASS /home2/len/reeltwo_sandboxes/volatile/asdf%5ctest.xml vs /home2/len/reeltwo_sandboxes/volatile/asdf%5ctest.xml
[len@noir volatile]$ /usr/local/java/jdk1.5/bin/java MustangURITest "%ff"
URI is file:/home2/len/reeltwo_sandboxes/volatile/asdf%25fftest.xml
PASS /home2/len/reeltwo_sandboxes/volatile/asdf%fftest.xml vs /home2/len/reeltwo_sandboxes/volatile/asdf%fftest.xml
PASS /home2/len/reeltwo_sandboxes/volatile/asdf%fftest.xml vs /home2/len/reeltwo_sandboxes/volatile/asdf%fftest.xml
ACTUAL -
[len@noir volatile]$ /usr/local/java/jdk1.6/bin/java MustangURITest "%5c"
URI is file:/home2/len/reeltwo_sandboxes/volatile/asdf%5ctest.xml
FAIL /home2/len/reeltwo_sandboxes/volatile/asdf%5ctest.xml vs /home2/len/reeltwo_sandboxes/volatile/asdf\test.xml
FAIL /home2/len/reeltwo_sandboxes/volatile/asdf%5ctest.xml vs /home2/len/reeltwo_sandboxes/volatile/asdf\test.xml
[len@noir volatile]$ /usr/local/java/jdk1.6/bin/java MustangURITest "%ff"
URI is file:/home2/len/reeltwo_sandboxes/volatile/asdf%fftest.xml
FAIL /home2/len/reeltwo_sandboxes/volatile/asdf%fftest.xml vs /home2/len/reeltwo_sandboxes/volatile/asdf%FFtest.xml
FAIL /home2/len/reeltwo_sandboxes/volatile/asdf%fftest.xml vs /home2/len/reeltwo_sandboxes/volatile/asdf%FFtest.xml
OBSERVED APPLICATION IMPACT:
We have software that uses URI's internally for referencing documents stored in various locations, some of which are Files. This regression breaks the ability to read such referenced files.
(FYI, I am using Linux IA32, Fedora FC4, but I doubt it's specific to this OS)
Release Regression From : 5.0u6
The above release value was the last known release where this
bug was known to work. Since then there has been a regression.
- duplicates
-
JDK-6394131 Rollback URI class to Tiger version
- Resolved