|
Quick Lists
|
|
Bug ID:
|
4488596
|
|
Votes
|
0
|
|
Synopsis
|
URLEncoder.encode() does not always take the low 8 bits of character
|
|
Category
|
java:classes_net
|
|
Reported Against
|
1.2.2_08
|
|
Release Fixed
|
|
|
State
|
11-Closed, duplicate of 4257115,
bug
|
|
Priority:
|
3-Medium
|
|
Related Bugs
|
4257115
,
4488606
|
|
Submit Date
|
06-AUG-2001
|
|
Description
|
javadocs say 'All other characters are converted into the 3-character string
%xy, where xy is the two-digit hexadecimal representation of the lower
8-bits of the character.'
Problem was seen trying to round trip Arabic text on a Sol8 system with a
default LANG of 'ar' (8859-6) through UTF-8 to URLEncoded and then all the
way back. The URLEncode decode was mangling the encoded text due to the
interaction with the non-english default charset.
But the code is:
OutputStreamWriter writer = new OutputStreamWriter(buf);
which uses the default encoding of the system property file.encoding to do
the encoding. If the char needs encoding, a sequence of bytes is written to
the outputstream rather than just the low 8 bits. The use of the writer is also unnecessary. See suggested fix for alternate code without the writer.
Will be filing the related bug in URLDecoder.decode() for related problem.
Seen in 1.2.2 and in 1.3.
|
|
Work Around
|
N/A
|
|
Evaluation
|
In JDK1.4 (J2SE 1.4), URLEncoder and URLDecoder APIs have been redesigned and the methods reimplemented. The problems mentioned by the description should go away. Please verify this.
xxxxx@xxxxx 2001-08-07
I have attached a test case that shows the problem, and the fix in 1.4.
I'm going to close as a duplicate of 4257115 since that was the bug that
fixed this issue.
xxxxx@xxxxx 2001-08-07
|
|
Comments
|
PLEASE NOTE: JDK6 is formerly known as Project Mustang
|
|
|
 |