commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 31161] New: - URLCodec.decode() corrupts characters > 127 in unencoded strings
Date Fri, 10 Sep 2004 13:32:57 GMT
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=31161>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=31161

URLCodec.decode() corrupts characters > 127 in unencoded strings

           Summary: URLCodec.decode() corrupts characters > 127 in unencoded
                    strings
           Product: Commons
           Version: 1.3 Final
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: Normal
          Priority: Other
         Component: Codec
        AssignedTo: commons-dev@jakarta.apache.org
        ReportedBy: hannes@helma.at


If URLCodec.decode() is called with a String that contains unencoded characters
in the 128-255 range, these characters are corrupted. The reason for this is in
the way characters that don't need decoding are passed from the source to the
target string:

            int b = bytes[i];
            
            (...)
     
            buffer.write(b);

If a character code is > 127, it results in integer b being in the -128..-1
range, and when it's lowest byte is written to the buffer it's something else
than the original one. 

I think the fix would be to add 256 to b if b is less than zero.

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message